Bug 1206088 - Resource group cannot be deleted if more then one bundle version is deployed on it
Summary: Resource group cannot be deleted if more then one bundle version is deployed ...
Keywords:
Status: NEW
Alias: None
Product: RHQ Project
Classification: Other
Component: Provisioning, Resource Grouping
Version: 4.12
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: Nobody
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 1206084
TreeView+ depends on / blocked
 
Reported: 2015-03-26 09:55 UTC by bkramer
Modified: 2022-03-31 04:28 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description bkramer 2015-03-26 09:55:52 UTC
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):
RHQ 4.12

How reproducible:
Always

Steps to Reproduce:

1. From RHQ UI create new recursive compatible resource group that contains two or more EAP instances;
2. Navigate to Bundle in RHQ UI and upload a bundle;
3. Deploy bundle to the destination that is using resource group created in the step 1;
4. From RHQ 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 RHQ 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 RHQ 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 RHQ 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.

Comment 1 bkramer 2015-03-26 10:14:41 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.