Bamboo upgrade task 60803 fails with duplicate entry for key PRIMARY

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Bamboo upgrade to version 6.8 or higher fails with a violation constraint during upgrade task 60803, and the following errors can be found inside the <Bamboo server home directory>/logs/atlassian-bamboo.log files:

 com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '13434930' for key 'PRIMARY'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 
2022-12-05 13:45:57,202 FATAL [localhost-startStop-1] [UpgradeLauncher] Upgrade task error: Task for build 60803 failed with exception: could not execute statement; SQL [n/a]; constraint [PRIMARY]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
1290 

Environment

Bamboo version < 6.8 attempting to upgrade to version 6.8 or higher.

Diagnosis

Check whether the existing Bamboo database has the  crowd_deleted_entity table, and if it contains data.

Cause

As part of the upgrade task 60803, Bamboo is copying data from the acl_entry  table to the newly created crowd_deleted_entity table in order to perform some cleanup that became required after the introduction of Embedded Crowd in Bamboo 6.6. This table is created during the upgrade process. Bamboo attempts to perform the following during the upgrade process:

ACL_ENTRYCOPYCROWD_DELETED_ENTITY
typeentity_type
sidentity_name

Bamboo versions older than 6.8 do not have a crowd_deleted_entity table; it gets created during the 60803 upgrade task while moving to a newer version of Bamboo.

  • If you attempted a Bamboo upgrade in the current instance in the past and didn't complete it, the database could have some data copied from the acl_entry table. 
  • This can also happen if you attempted a Bamboo upgrade to a version > 6.8 and decided to stop for some reason and restore the database. The restore process might have not dropped the table crowd_deleted_entity that was created during the upgrade attempt.

Solution

Option 1

The problem manifests generally when either the backup you have taken is not a true pre-upgrade Bamboo database backup and contains the table or when you restore it, you're restoring over an old database that has this table and the database restore tool is not removing it. For example, if you perform a database restore on MySQL, it will not drop tables that exist in the target database that don't exist in the SQL dump.

It is recommended to :

  1. Examine your database backup and first understand if CROWD_DELETED_ENTITY table is present within it
  2. If is not present in the backup, but is still there after you restore it it suggests that you're not restoring to an empty target database and you should be restoring to an empty target database in this scenario.
  3. If the table is present in the database backup, the backup has been created either mid upgrade or post upgrade failure and it's not your pre-upgrade snapshot that you should be rolling back to.

Option 2

The recommended route is to understand why your database restore of a version of Bamboo < 6.8 is keeping the CROWD_DELETED_ENTITY table post restore a.k.a Option 1 however if you're completely stuck, you may attempt to just manually delete the table and proceed but please be aware – it does suggest something is not as expected with regards to how your upgrade or rollbacks were performed and there may be further issues down the line.

  1. Stop Bamboo.
  2. Stop the DB.
  3. Create a full backup of the database, Bamboo Home, and Bamboo Install folders.
  4. Delete the CROWD_DELETED_ENTITY table from the DB.
  5. Start Bamboo with your current version and validate its operation.
  6. Once you verify everything is working, proceed with the upgrade to Bamboo.

Last modified on Jan 11, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.