"Query did not return a unique result: 2" error in Bamboo when marking plans as favorite
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
Summary
Bamboo gives an error message every time a user tries to mark plans as favorite: query did not return a unique result: 2.
Diagnosis
The following error can be seen in the logs:
1
2
3
4
5
6
7
8
9
2012-08-03 10:49:59,915 ERROR [730902023@qtp-2005327631-18171] [FiveOhOh] 500 Exception was thrown.
org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590)
at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)
at com.atlassian.bamboo.labels.LabelHibernateDao.findLabelByNameAndNamespace(LabelHibernateDao.java:35)
at sun.reflect.GeneratedMethodAccessor471.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Cause
Somehow there were 2 rows added to BUILDRESULTSUMMARY_LABEL and LABEL tables.
Solution
In order to find out what table is involved, How to Enable Detailed SQL Logging and reproduce the problem. After, immediately shut down your Bamboo server and check the last logs. You will see the involved table(s).
In this specific case let's say we saw that querying LABEL table failed. Running this SQL query we confirm that there are 2 records somehow inserted into LABEL table that have the same value in the 'NAME' field:
1
select * from label where namespace='problematic_user_name';
Next, note that LABEL_ID is used only in BUILDRESULTSUMMARY_LABEL table.
In order to find out which row should be deleted (the one that isn't linked from BUILDRESULTSUMMARY_LABEL), run this SQL query (change (id1,id2) with a list of the label IDs received from the previous query):
1
select * from BUILDRESULTSUMMARY_LABEL where LABEL_ID in (id1,id2);
After getting the results of the previous query, follow the next steps to delete the duplicate rows and leave only one.
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. Next, run this SQL query to delete the row that isn't linked from BUILDRESULTSUMMARY_LABEL and LABEL tables (there might be duplicates in both tables):
1 2 3
delete FROM BUILDRESULTSUMMARY_LABEL where LABEL_ID=<id2>; delete from label where LABEL_ID=<id2>;
Start your Bamboo server.
Was this helpful?