Description of problem: Resource group cannot be deleted if more then one bundle version is deployed on it. When trying to delete resource group in the environment that is using Oracle database the following exception will be thrown: ************************************************* 09:32:06,579 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-10) SQL Error: 2292, SQLState: 23000 09:32:06,579 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-10) ORA-02292: integrity constraint (RHQADMIN.SYS_C0016515) violated - child record found 09:32:06,580 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-10) SQL Error: 2292, SQLState: 23000 09:32:06,580 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-10) ORA-02292: integrity constraint (RHQADMIN.SYS_C0016515) violated - child record found 09:32:06,585 ERROR [org.hibernate.engine.jdbc.batch.internal.BatchingBatch] (http-/0.0.0.0:7080-10) HHH000315: Exception executing batch [could not execute batch] 09:32:06,586 WARN [com.arjuna.ats.arjuna] (http-/0.0.0.0:7080-10) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffa87c2d5b:6004142:54f86e18:99d08, org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@4f3baa50 >: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute batch at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387) [hibernate-entitymanager-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310) [hibernate-entitymanager-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316) [hibernate-entitymanager-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] ... at org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal$$$view78.deleteResourceGroups(Unknown Source) [rhq-server.jar:4.12.0.JON330GA-redhat-1] at org.rhq.coregui.server.gwt.ResourceGroupGWTServiceImpl.deleteResourceGroups(ResourceGroupGWTServiceImpl.java:120) ... at org.rhq.coregui.server.gwt.AbstractGWTServiceImpl.service(AbstractGWTServiceImpl.java:88) ... at org.rhq.helpers.rtfilter.filter.RtFilter.doFilter(RtFilter.java:125) [rhq-rtfilter-4.12.0.JON330GA.jar:4.12.0.JON330GA] ... at org.rhq.coregui.server.filter.CacheControlFilter.doFilter(CacheControlFilter.java:71) ... Caused by: org.hibernate.exception.ConstraintViolationException: could not execute batch ... Caused by: java.sql.BatchUpdateException: ORA-02292: integrity constraint (RHQADMIN.SYS_C0016515) violated - child record found at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:11190) [ojdbc6-12.1.0.1.0.jar:12.1.0.1.0] at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:244) [ojdbc6-12.1.0.1.0.jar:12.1.0.1.0] at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:708) at org.jboss.jca.adapters.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:1077) at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:113) [hibernate-core-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] ... 79 more ************************************************* When running Postgres: ************************************************* 08:56:44,865 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-2) SQL Error: 0, SQLState: 23503 08:56:44,865 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-2) Batch entry 0 delete from RHQ_BUNDLE_DEPLOYMENT where ID=10041 was aborted. Call getNextException to see the cause. 08:56:44,866 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-2) SQL Error: 0, SQLState: 23503 08:56:44,866 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/0.0.0.0:7080-2) ERROR: update or delete on table "rhq_bundle_deployment" violates foreign key constraint "rhq_bundle_deployment_replaced_bundle_deployment_id_fkey" on table "rhq_bundle_deployment" Detail: Key (id)=(10041) is still referenced from table "rhq_bundle_deployment". 08:56:44,869 ERROR [org.hibernate.engine.jdbc.batch.internal.BatchingBatch] (http-/0.0.0.0:7080-2) HHH000315: Exception executing batch [could not execute batch] 08:56:44,872 WARN [com.arjuna.ats.arjuna] (http-/0.0.0.0:7080-2) ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffff0a210135:-301810a6:5513c310:5f8a, org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@609266df >: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute batch at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387) [hibernate-entitymanager-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310) [hibernate-entitymanager-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316) [hibernate-entitymanager-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] ... at org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal$$$view78.deleteResourceGroups(Unknown Source) [rhq-server.jar:4.12.0.JON330GA] at org.rhq.coregui.server.gwt.ResourceGroupGWTServiceImpl.deleteResourceGroups(ResourceGroupGWTServiceImpl.java:120) ... at org.rhq.coregui.server.gwt.AbstractGWTServiceImpl.service(AbstractGWTServiceImpl.java:87) ... at org.rhq.helpers.rtfilter.filter.RtFilter.doFilter(RtFilter.java:125) [rhq-rtfilter-4.12.0.JON330GA.jar:4.12.0.JON330GA] ... at org.rhq.coregui.server.filter.CacheControlFilter.doFilter(CacheControlFilter.java:71) ... Caused by: org.hibernate.exception.ConstraintViolationException: could not execute batch ... Caused by: java.sql.BatchUpdateException: Batch entry 0 delete from RHQ_BUNDLE_DEPLOYMENT where ID=10041 was aborted. Call getNextException to see the cause. at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2746) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1887) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:405) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2893) at sun.reflect.GeneratedMethodAccessor123.invoke(Unknown Source) [:1.7.0_51] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_51] at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_51] at org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection$StatementHandler.invoke(AbstractJdbc23PooledConnection.java:453) at com.sun.proxy.$Proxy106.executeBatch(Unknown Source) at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:708) at org.jboss.jca.adapters.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:1077) at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:113) [hibernate-core-4.2.14.SP1-redhat-1.jar:4.2.14.SP1-redhat-1] ... 79 more ************************************************* Version-Release number of selected component (if applicable): JBoss ON 3.3.0 How reproducible: Always Steps to Reproduce: 1. From JBoss ON UI create new recursive compatible resource group that contains two or more EAP instances; 2. Navigate to Bundle in JBoss ON UI and upload a bundle; 3. Deploy bundle to the destination that is using resource group created in the step 1; 4. From JBoss ON UI -> Inventory -> Compatible Groups -> select group from step 1 and press "Delete" button; 5. This group will be deleted (no exception is thrown) and bundle destination that is referenced with this group will be deleted too; 6. Create another recursive compatible resource group that contains two or more EAP instances; 7. Navigate to Bundle in JBoss ON UI and upload few versions of the bundle; 8. Deploy bundle versions to the destination that is using resource group created in the step 6; 9. From JBoss ON UI -> Inventory -> Compatible Groups -> select group from step 6 and press "Delete" button; Actual results: Resource group will be empty but error pop up message will be shown "Failed to delete selected resource groups" and above exceptions will be thrown in the server.log file. Also, bundle destinations that are referenced with this group are still shown in the JBoss ON UI; Expected results: The error pop up message should tell the user they must delete the associated bundle destinations or perhaps ask them if the destinations should also be deleted. Additional info: The workaround would be to delete the bundle destinations from the UI and then delete the resource group.
Deletion of the resource group should work in the same way no matter if we have only one bundle version deployed or more of them. In both case, we should at least tell users what will happen (all bundle destinations will be deleted) if they continue with deletion of the resource group (and delete everything if user confirms it) or tell them to delete the associated bundle destination prior to resource group deletion.
Fixed in the master (requires DB-upgrade): commit 62a728544bdb9cc70ae5d624135995ae45e35b5b Author: Michael Burman <miburman> Date: Tue Sep 15 18:20:46 2015 +0300 [BZ 1206084] Cascade delete the replaced bundle ids on RHQ_BUNDLE_DEPLOYMENT table
The original commit from Comment 4 forgot to bump schema version branch: master link: https://github.com/rhq-project/rhq/commit/da7816eef time: 2015-09-18 10:10:33 +0200 commit: da7816eefcd8705d4f22a5d84ae1596de1e78cbd author: Libor Zoubek - lzoubek message: [BZ 1206084] Cascade delete the replaced bundle ids on RHQ_BUNDLE_DEPLOYMENT table Bump schema version
Available for review in https://github.com/rhq-project/rhq/pull/186 (merging target is release/jon3.3.x) commit a7fc733a19cc5b06003e53f2b2e312c27c16ee7d Author: Michael Burman <miburman> Date: Wed Oct 14 16:44:28 2015 +0300 [BZ 1206084] Delete all the BundleDestinations before removing ResourceGroup
Merged to release/jon3.3.x
Moving to ON_QA as available to test with the following brew build: JON Cumulative patch build: https://brewweb.devel.redhat.com/buildinfo?buildID=469635 *Note: jon-server-patch-3.3.0.GA.zip maps to DR01 build of jon-server-3.3.0.GA-update-05.zip.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2016-0118.html