Bamboo 6.8 version installation with MS SQL server getting Cannot insert duplicate key in object 'db
Asked by Gowse shaik:

Bamboo 6.8 version installation with MS SQL server getting "Cannot insert duplicate key in object 'dbo.CWD_DIRECTORY'"  
Below is the error , i got. appreciate your input.  

Caused by: java.sql.BatchUpdateException: Violation of UNIQUE KEY constraint 'uk_dir_l_name'. Cannot insert duplicate key in object 'dbo.CWD_DIRECTORY'. The duplicate key value is (bamboo internal directory).  
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:1824)  
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:2544)  
at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:118)  
... 209 more  
2024-03-05 11:00:43,454 ERROR \[http-nio-8085-exec-18\] \[FiveOhOh\] 500 Exception was thrown.  
org.springframework.dao.DataIntegrityViolationException: could not execute batch; SQL \[insert into CWD_DIRECTORY (DIRECTORY_NAME, LOWER_DIRECTORY_NAME, CREATED_DATE, UPDATED_DATE, ACTIVE, DESCRIPTION, IMPL_CLASS, LOWER_IMPL_CLASS, DIRECTORY_TYPE, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\]; constraint \[null\]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute batch  
at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:247)  

<br />

<br />

Caused by: org.hibernate.exception.ConstraintViolationException: could not execute batch  
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:112)  
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)  
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)  

<br />

<br />

Caused by: java.sql.BatchUpdateException: Violation of UNIQUE KEY constraint 'uk_dir_l_name'. Cannot insert duplicate key in object 'dbo.CWD_DIRECTORY'. The duplicate key value is (bamboo internal directory).  
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:1824)  
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:2544)  
at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:118)  

<br />

<br />

<br />


Answers:
author: Jyothi Charupalli
body: Hi Gowse,

Welcome to the Atlassian Community!

During Bamboo setup double clicking on some of the steps when creating an admin user causes these kinds of errors and issues.

From the provided logs we can see the errors are caused by primary key violation "uk_dir_l_name" which is caused by a duplicate entry in the database table "CWD_DIRECTORY".

This is explained in this BUG report: <https://jira.atlassian.com/browse/BAM-21032>. This BUG got fixed in Bamboo 8.1.1 version. We suggest you install the latest versions of Bamboo to not get affected by this BUG.

In case you want to install Bamboo 6.8 Version(EOL version) only for any upgrade of Bamboo or cloning the instance, the workaround would be to re-create your environment with the new $BAMBOO_HOME directory and new database.

Regards,

Jyothi Charupalli

**\*\*please don't forget to Accept the answer if your query was answered\*\***


Tags: ms-sql