Database Corruption - query did not return a unique result


アトラシアン コミュニティをご利用ください。



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:

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(
    at net.sf.hibernate.impl.CriteriaImpl.uniqueResult(
    at com.atlassian.bamboo.project.ProjectHibernateDao$4.doInHibernate(
    at org.springframework.orm.hibernate.HibernateTemplate.execute(
    at org.springframework.orm.hibernate.HibernateTemplate.execute(
    at com.atlassian.bamboo.project.ProjectHibernateDao.getProjectByKey(
    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)


Somehow there were 2 projects added with the same Project_key (might be a result of a strange double click).


  1. After running this SQL query, we find out the involved "PROJECT_ID"s:

    select * from PROJECT where PROJECT_KEY ='MYKEY';
    |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                  |


  2. Project_ID is being used in two tables: BUILD and BUILDRESULTSUMMARY_LABEL.

  3. 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:

    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);
  4. 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.
  5. Stop your Bamboo server, and make sure that you have backed up your Bamboo database before making any changes to the DB.
  6. 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):

    DELETE from PROJECT where PROJECT_ID=10420226;
  7. Start your Bamboo server.

最終更新日: 2019 年 12 月 31 日


Powered by Confluence and Scroll Viewport.