Bug 738799
| Summary: | deleting a group alertdef containing >1000 member alertdefs fails with "SQLException: ORA-01795: maximum number of expressions in a list is 1000" error | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Other] RHQ Project | Reporter: | Ian Springer <ian.springer> | ||||
| Component: | Core UI | Assignee: | Thomas Segismont <tsegismo> | ||||
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Mike Foley <mfoley> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | high | ||||||
| Version: | 4.1 | CC: | ccrouch, genman, hrupp, tsegismo | ||||
| Target Milestone: | --- | Keywords: | NeedsTestCase | ||||
| Target Release: | RHQ 4.10 | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2014-04-23 12:30:11 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Bug Depends On: | |||||||
| Bug Blocks: | 720762, 620933 | ||||||
| Attachments: |
|
||||||
|
Description
Ian Springer
2011-09-15 20:25:46 UTC
Still seen in RHQ 4.9
00:31:33,836 ERROR [org.jboss.as.ejb3.invocation] (http-/0.0.0.0:7081-1) JBAS014134: EJB Invocation failed on component GroupDefinitionManagerBean for method public abstract void org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal.calculateGroupMembership(org.rhq.core.domain.auth.Subject,int) throws org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException,org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionDeleteException,org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionNotFoundException,org.rhq.core.domain.resource.group.InvalidExpressionException: javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]
at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.2.0.Alpha1-redhat-4.jar:7.2.0.Alpha1-redhat-4]
at org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal$$$view161.calculateGroupMembership(Unknown Source) [rhq-server.jar:4.9.0]
at org.rhq.enterprise.gui.coregui.server.gwt.ResourceGroupGWTServiceImpl.recalculateGroupDefinitions(ResourceGroupGWTServiceImpl.java:168)
....
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1397) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:108) [hibernate-entitymanager-4.2.0.CR1.jar:4.2.0.CR1]
at org.rhq.enterprise.server.alert.GroupAlertDefinitionManagerBean.removeGroupMemberAlertDefinitions(GroupAlertDefinitionManagerBean.java:424) [rhq-server.jar:4.9.0]
....
Caused by: java.sql.SQLSyntaxErrorException: ORA-01795: maximum number of expressions in a list is 1000
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440) [ojdbc6.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) [ojdbc6.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837) [ojdbc6.jar:11.2.0.2.0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445) [ojdbc6.jar:11.2.0.2.0]
Simple patch:
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rh
index 6f322ca..ab3e7df 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/GroupAlertDefinitionManagerBean.java
@@ -118,13 +117,20 @@ public int removeGroupAlertDefinitions(Subject subject, Integer[] groupAlertDefi
* break the Hibernate relationships used for navigating between the groupAlertDefinition and the
* children alertDefinitions so that the async deletion mechanism can delete without FK violations
*/
- if (allChildDefinitionIds.size() > 0) {
+ breakLinks(allChildDefinitionIds);
+
+ return modified;
+ }
+
+ private void breakLinks(List<Integer> ids) {
Query breakLinksQuery = entityManager.createNamedQuery(AlertDefinition.QUERY_UPDATE_SET_PARENTS_NULL);
- breakLinksQuery.setParameter("childrenDefinitionIds", allChildDefinitionIds);
+ while (!ids.isEmpty()) {
+ // fix for Oracle > 1000 entries
+ List<Integer> subList = ids.subList(0, Math.min(500, ids.size()));
+ breakLinksQuery.setParameter("childrenDefinitionIds", subList);
breakLinksQuery.executeUpdate();
+ subList.clear(); // removes entries from parent, too
}
-
- return modified;
}
@SuppressWarnings("unchecked")
@@ -419,9 +425,7 @@ public void removeGroupMemberAlertDefinitions(Subject subject, int resourceGroup
}
// 2) break all of the references to the group
- Query breakLinksQuery = entityManager.createNamedQuery(AlertDefinition.QUERY_UPDATE_SET_PARENTS_NULL);
- breakLinksQuery.setParameter("childrenDefinitionIds", allMemberAlertDefinitionIds);
- breakLinksQuery.executeUpdate();
+ breakLinks(allMemberAlertDefinitionIds);
alertDefinitions.clear();
allMemberAlertDefinitionIds.clear();
Created attachment 862835 [details]
CLI Script to setup inventory
This script will:
* manually import some "PortService" resources;
* create a compatible group;
* add the resources to the group
Fixed in master
commit 31b21eaf98e98dd8cd820af94e0444695b097ce5
Author: Elias Ross <genman>
Date: Tue Feb 18 10:40:02 2014 +0100
Applied patch provided by Elias and added an itest
Bulk closing of 4.10 issues. If an issue is not solved for you, please open a new BZ (or clone the existing one) with a version designator of 4.10. |