-
Bug
-
Resolution: Fixed
-
Low
-
3.6.0
-
None
-
1
-
Severity 3 - Minor
-
Issue Summary
"Unique constraint violation" error while switching applink in the Crowd-connected application. Following error is seen when SQL logging is enabled:
Error seen with SQL debug logging
2019-11-25 18:01:56,195 http-nio-8095-exec-14 DEBUG [org.hibernate.SQL] insert into cwd_application_attribute (application_id, attribute_name, attribute_value) values (?, ?, ?) 2019-11-25 18:01:56,195 http-nio-8095-exec-14 TRACE [type.descriptor.sql.BasicBinder] binding parameter [1] as [BIGINT] - [37879809] 2019-11-25 18:01:56,195 http-nio-8095-exec-14 TRACE [type.descriptor.sql.BasicBinder] binding parameter [2] as [VARCHAR] - [applicationLinkId] 2019-11-25 18:01:56,195 http-nio-8095-exec-14 TRACE [type.descriptor.sql.BasicBinder] binding parameter [3] as [VARCHAR] - [3c66e104-82c6-3ad3-a663-2b055e5fe0a0] 2019-11-25 18:01:56,203 http-nio-8095-exec-14 ERROR [jdbc.batch.internal.BatchingBatch] HHH000315: Exception executing batch [java.sql.BatchUpdateException: ORA-00001: unique constraint (AWS_CROWD.SYS_C005244) violated ], SQL: insert into cwd_application_attribute (application_id, attribute_name, attribute_value) values (?, ?, ?)
We can see from the database, that the attribute_value attribute in the cwd_application_attribute is null.
SELECT * FROM cwd_application_attribute WHERE application_id = '37879809' and attribute_name = 'applicationLinkId';
(37879809,null,'applicationLinkId');
The issue is limited to only the Oracle database.
Steps to Reproduce
- Chose a Crowd-connected application.
- Select the relevant applink for the application for Crowd to communicate with the application.
- Save the settings
- Edit the application again and change the applink to deselect the earlier chosen applink. eg: From Bitbuket to select application link - save is successful.
- Hit Save, save is successful.- Notice the error
- Try to select the Application Link again: Hit Save - Notice the error
Expected Results
We should be able to deselect the applink without any issues.
Actual Results
The below exception is thrown
2019-11-28 15:07:20,477 http-nio-8095-exec-13 ERROR [jdbc.batch.internal.BatchingBatch] HHH000315: Exception executing batch [java.sql.BatchUpdateException: ORA-00001: unique constraint (AWS_CROWD.SYS_C005244) violated ], SQL: insert into cwd_application_attribute (application_id, attribute_name, attribute_value) values (?, ?, ?) 2019-11-28 15:07:20,479 http-nio-8095-exec-13 WARN [engine.jdbc.spi.SqlExceptionHelper] SQL Error: 1, SQLState: 23000 2019-11-28 15:07:20,479 http-nio-8095-exec-13 ERROR [engine.jdbc.spi.SqlExceptionHelper] ORA-00001: unique constraint (AWS_CROWD.SYS_C005244) violated 2019-11-28 15:07:20,479 http-nio-8095-exec-13 WARN [engine.jdbc.spi.SqlExceptionHelper] SQL Error: 1, SQLState: 23000 2019-11-28 15:07:20,479 http-nio-8095-exec-13 ERROR [engine.jdbc.spi.SqlExceptionHelper] ORA-00001: unique constraint (AWS_CROWD.SYS_C005244) violated 2019-11-28 15:07:20,484 http-nio-8095-exec-13 ERROR [org.hibernate.internal.ExceptionMapperStandardImpl] HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute batch] 2019-11-28 15:07:20,488 http-nio-8095-exec-13 ERROR [crowd.xwork.interceptors.TransactionalInvocation] Action /console/secure/application/update.action (UpdateApplication.execute()) is already completed and can not be committed again. 2019-11-28 15:07:20,955 http-nio-8095-exec-13 ERROR [500ErrorPage] Exception caught in 500 page could not execute batch; SQL [insert into cwd_application_attribute (application_id, attribute_name, attribute_value) values (?, ?, ?)]; constraint [AWS_CROWD.SYS_C005244]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute batch org.springframework.dao.DataIntegrityViolationException: could not execute batch; SQL [insert into cwd_application_attribute (application_id, attribute_name, attribute_value) values (?, ?, ?)]; constraint [AWS_CROWD.SYS_C005244]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute batch at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:241) at org.springframework.orm.hibernate5.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:755) at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:594) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:765) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:734) at com.atlassian.crowd.xwork.interceptors.TransactionalInvocation.commitOrRollbackTransaction(TransactionalInvocation.java:80)
Workaround
There are 2 possible workarounds for now:
- Once the applink is chosen for the application, do not change it to select application link to deselect the applink.
- You can also use the following SQL query to manually add the applink to the application:
UPDATE cwd_application_attribute SET attribute_value = '<application-link-ID>' WHERE application_id = '<application-ID>' and attribute_name = 'applicationLinkId';
The application-link-ID is of the application link which you are trying to choose for the application. The application-ID is of the Crowd-connected application.
Example query:UPDATE cwd_application_attribute SET attribute_value = '3c66e104-82c6-3ad3-a663-2b055e5fe0a0' WHERE application_id = '37879809' and attribute_name = 'applicationLinkId';
Extras
A screenshot of the exception thrown from a test in another similar setup: