Database Corruption - query did not return a unique result
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Symptoms
After unsuccessful cloning of a plan (by creating a new project), Bamboo gives an error message every time a user tries to work with that project:
1
2
3
4
5
6
7
8
9
10
11
12
2012-03-06 14:01:11,147 WARN [qtp2583282-18] [HibernateObjectDao] Unable to get project with key MYKEY
net.sf.hibernate.NonUniqueResultException: query did not return a unique result: 2
at net.sf.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:559)
at net.sf.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:385)
at com.atlassian.bamboo.project.ProjectHibernateDao$4.doInHibernate(ProjectHibernateDao.java:90)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:370)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)
at com.atlassian.bamboo.project.ProjectHibernateDao.getProjectByKey(ProjectHibernateDao.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
Cause
Somehow there were 2 projects added with the same Project_key (might be a result of a strange double click).
Resolution
After running this SQL query, we find out the involved "PROJECT_ID"s:
1 2 3 4 5 6
select * from PROJECT where PROJECT_KEY ='MYKEY'; |PROJECT_ID|CREATED_DATE |UPDATED_DATE |PROJECT_KEY|TITLE |DESCRIPTION|MARKED_FOR_DELETION| --------------------------------------------------------------------------------------------------------------------- |10420225 |2012-03-05 15:48:03.697|2012-03-05 15:48:03.697|MYKEY |My Feedback| |0 | |10420226 |2012-03-05 15:48:03.710|2012-03-05 15:48:03.710|MYKEY |My Feedback| |0 |
Project_ID is being used in two tables: BUILD and BUILDRESULTSUMMARY_LABEL.
In order to find out which row should be deleted (the one that isn't linked from any of those tables), run these SQL queries to check if there are any rows that don't have a matching Project_ID:
1 2
select * from buildresultsummary_label where project_id not in (select project_id from Project); select * from build where project_id not in (select project_id from Project);
After getting the results of the previous queries, you should be able to tell which one is linked(this should stay) and which one isn't(needs to be removed). If none of the rows are linked, you can delete the second one by following the next steps.
Stop your Bamboo server, and make sure that you have backed up your Bamboo database before making any changes to the DB.
Make sure that you have a backup of your Bamboo DB and run this SQL query to delete the row that isn't linked (or the second row):
1
DELETE from PROJECT where PROJECT_ID=10420226;
Start your Bamboo server.
Was this helpful?