Database Corruption - Bamboo export fails

お困りですか?

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

コミュニティに質問

症状

2012-03-19 23:45:45,668 ERROR [qtp17707667-1572044] [AbstractResultSummaryMapper] Could not export com.atlassian.bamboo.resultsummary.BuildResultsSummaryImpl@2c0cd545
net.sf.hibernate.LazyInitializationException: Exception initializing proxy: [com.atlassian.bamboo.chains.ChainResultsSummaryImpl#2031621]
    at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:64)
    at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:164)
    at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
    at com.atlassian.bamboo.chains.ChainResultsSummaryImpl$$EnhancerByCGLIB$$aa64ec38.getCustomBuildData(<generated>)
    at com.atlassian.bamboo.plan.trigger.TriggerManagerImpl.getTriggerReason(TriggerManagerImpl.java:73)
    at com.atlassian.bamboo.resultsummary.BuildResultsSummaryImpl.getTriggerReason(BuildResultsSummaryImpl.java:101)
    at com.atlassian.bamboo.migration.stream.AbstractResultSummaryMapper.exportProperties(AbstractResultSummaryMapper.java:163)
    at com.atlassian.bamboo.migration.stream.BuildResultSummaryMapper.exportProperties(BuildResultSummaryMapper.java:45)
...
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:450)
    at java.lang.Thread.run(Thread.java:619)
Caused by: net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 2031621, of class: com.atlassian.bamboo.chains.ChainResultsSummaryImpl
    at net.sf.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:24)
    at net.sf.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1944)
    at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:53)
    at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:60)
    ... 210 more

 

ソリューション

The resolution of this type of database corruptions can be running SQL queries to delete the records from the database that refer to the fields that don't exist. Make sure that you have a Bamboo databse backup before running any changing queries against Bamboo DB.

For Bamboo 4.1.2 and 4.4.5, follow these steps:

Please keep in mind that there may be database schema changes between versions, so some queries may require tweaking.

  1. Run Bamboo, and see on which field it is failing (usually Bamboo shows the table names, column names and the names of the constraints involved).
    The error message in this example is:

    2013-07-30 15:11:50,791 ERROR [qtp8984226-619] [LazyInitializer] Exception initializing proxy
    net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 30474293, of class: com.atlassian.bamboo.chains.ChainResultsSummaryImpl
    	at net.sf.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:24)
    	at net.sf.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:1948)
    	at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:53)
    	at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:60)
    	at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:164)
    	at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
    	at com.atlassian.bamboo.chains.ChainResultsSummaryImpl$$EnhancerByCGLIB$$71df301.getCustomBuildData(<generated>)
    	at com.atlassian.bamboo.plan.trigger.TriggerManagerImpl.getTriggerReason(TriggerManagerImpl.java:75)
    	at com.atlassian.bamboo.resultsummary.BuildResultsSummaryImpl.getTriggerReason(BuildResultsSummaryImpl.java:143)
    	at com.atlassian.bamboo.migration.stream.AbstractResultSummaryMapper.exportProperties(AbstractResultSummaryMapper.java:186)
    	at com.atlassian.bamboo.migration.stream.BuildResultSummaryMapper.exportProperties(BuildResultSummaryMapper.java:54)
    	at com.atlassian.bamboo.migration.stream.BuildResultSummaryMapper.exportProperties(BuildResultSummaryMapper.java:19)
    	at com.atlassian.bamboo.migration.BambooStAXMappingHelperAbstractImpl.exportXml(BambooStAXMappingHelperAbstractImpl.java:98)
    	at com.atlassian.bamboo.migration.BambooStAXMappingHelperAbstractImpl.exportXml(BambooStAXMappingHelperAbstractImpl.java:81)
    	at com.atlassian.bamboo.migration.stream.AbstractResultSummaryMapper.access$000(AbstractResultSummaryMapper.java:55)
    	at com.atlassian.bamboo.migration.stream.AbstractResultSummaryMapper$2.apply(AbstractResultSummaryMapper.java:406)
    	at com.atlassian.bamboo.migration.stream.AbstractResultSummaryMapper$2.apply(AbstractResultSummaryMapper.java:397)
    	at com.atlassian.bamboo.resultsummary.BuildResultsSummaryHibernateDao$36.nextScrollableResult(BuildResultsSummaryHibernateDao.java:1273)
    	at org.springframework.orm.hibernate.ScrollHibernateCallback.doInHibernate(ScrollHibernateCallback.java:54)
    	at org.springframework.orm.hibernate.ScrollHibernateCallback.doInHibernate(ScrollHibernateCallback.java:13)
    	.......
    		at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
    	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1331)
    	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:477)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
    	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
    	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
    	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
    	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
    	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    	at org.eclipse.jetty.server.Server.handle(Server.java:349)
    	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
    	at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
    	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
    	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:857)
    	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
    	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
    	at java.lang.Thread.run(Thread.java:662)
  2. Run this SELECT query to find out the corrupted build results:

    select buildresultsummary_id, chain_result from BUILDRESULTSUMMARY where BUILD_TYPE = 'BUILD' and chain_result not in (select buildresultsummary_id from BUILDRESULTSUMMARY);
    +-----------------------+--------------+
    | buildresultsummary_id | chain_result |
    +-----------------------+--------------+
    |              30474294 |     30474293 |
    +-----------------------+--------------+
    1 row in set (0.01 sec)
  3. Shut down Bamboo and delete the rows mentioned in the previous step:

    DELETE FROM BUILDRESULTSUMMARY WHERE chain_result IN (30474293);
    Query OK, 1 row affected (0.06 sec)
  4. Then, run these SQL queries to remove the rest of the corruptions:

    select buildresultsummary_id from BUILDRESULTSUMMARY where BUILD_TYPE = 'BUILD' and chain_result not in (select buildresultsummary_id from BUILDRESULTSUMMARY);
    Empty set (0.01 sec)
    
    DELETE FROM BUILDRESULTSUMMARY_CUSTOMDATA WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY);
    Query OK, 0 rows affected (0.04 sec)
    
    DELETE FROM BRS_LINKEDJIRAISSUES WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY);
    Query OK, 0 rows affected (0.00 sec)
    
    DELETE FROM COMMIT_FILES WHERE commit_id IN (SELECT commit_id FROM USER_COMMIT WHERE repository_changeset_id IN (SELECT repository_changeset_id FROM REPOSITORY_CHANGESET WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY)));
    Query OK, 30414 rows affected (1.06 sec)
    
    DELETE FROM USER_COMMIT WHERE repository_changeset_id IN (SELECT repository_changeset_id FROM REPOSITORY_CHANGESET WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY));
    Query OK, 1547 rows affected (0.09 sec)
    
    DELETE FROM TEST_ERROR WHERE result_id IN (SELECT test_case_result_id FROM TEST_CASE_RESULT WHERE test_case_id IN (SELECT test_case_id FROM TEST_CASE WHERE test_class_id IN (SELECT test_class_id FROM TEST_CLASS_RESULT WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY))));
    Query OK, 0 rows affected (0.38 sec)
    
    DELETE FROM TEST_CASE_RESULT WHERE test_case_id IN (SELECT test_case_id FROM TEST_CASE WHERE test_class_id IN (SELECT test_class_id FROM TEST_CLASS_RESULT WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY)));
    Query OK, 0 rows affected (0.05 sec)
    
    DELETE FROM TEST_CASE WHERE test_class_id IN (SELECT test_class_id FROM TEST_CLASS_RESULT WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY));
    Query OK, 0 rows affected (0.33 sec)
    
    DELETE FROM TEST_CLASS_RESULT WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM BUILDRESULTSUMMARY);
    Query OK, 0 rows affected (0.00 sec)
    
    DELETE FROM BUILDRESULTSUMMARY_LABEL WHERE label_id NOT IN (SELECT label_id FROM LABEL);
    Query OK, 0 rows affected (0.00 sec)
     
    delete from repository_changeset where BUILDRESULTSUMMARY_ID not in (select BUILDRESULTSUMMARY_ID from buildresultsummary);
  5. Start Bamboo, and if there are any other errors, go to step 1.

For Bamboo 3.4.x, follow these steps:

ここをクリックして展開...
  1. Run Bamboo, and see on which field it is failing (usually Bamboo shows the table names, column names and the names of the constraints involved) - in this particular case, it fails on Buildresultsummary table.
  2. Run this SELECT query to find out the corrupted build results:

    SELECT buildresultsummary_id FROM buildresultsummary WHERE BUILD_TYPE = 'BUILD' AND chain_result NOT IN (SELECT buildresultsummary_id FROM buildresultsummary);
    
    +-----------------------+
    | buildresultsummary_id |
    +-----------------------+
    |              99948956 |
    |              99948959 |
    |              99948963 |
    |              99948957 |
    |              99948960 |
    |              99948968 |
    |              99948974 |
    +-----------------------+
    7 rows in set (0.11 sec)
  3. Shut down Bamboo and delete the rows mentioned in the previous step:

    DELETE FROM buildresultsummary WHERE chain_result IN (99948956, 99948959, 99948963, 99948957, 99948960, 99948968, 99948974);
    
  4. Then, run these SQL queries to remove the rest of the corruptions:

    DELETE FROM buildresultsummary_customdata WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary);
    
    DELETE FROM brs_linkedjiraissues WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary);
    
    DELETE FROM commit_files WHERE commit_id IN (SELECT commit_id FROM user_commit WHERE repository_changeset_id IN (SELECT repository_changeset_id FROM repository_changeset WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary)));
    
    DELETE FROM user_commit WHERE repository_changeset_id IN (SELECT repository_changeset_id FROM repository_changeset WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary));
    
    DELETE FROM test_error WHERE result_id IN (SELECT test_case_result_id FROM test_case_result WHERE test_case_id IN (SELECT test_case_id FROM test_case WHERE test_class_id IN (SELECT test_class_id FROM test_class_result WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary))));
    
    DELETE FROM test_case_result WHERE test_case_id IN (SELECT test_case_id FROM test_case WHERE test_class_id IN (SELECT test_class_id FROM test_class_result WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary)));
    
    DELETE FROM test_case WHERE test_class_id IN (SELECT test_class_id FROM test_class_result WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary));
    
    DELETE FROM test_class_result WHERE buildresultsummary_id NOT IN (SELECT buildresultsummary_id FROM buildresultsummary);
    
    DELETE FROM buildresultsummary_label WHERE label_id NOT IN (SELECT label_id FROM label);
  5. Start Bamboo, and if there are any other errors, go to step 1.

For older Bamboo major releases like 3.2, follow these steps:

ここをクリックして展開...

  1. Run Bamboo, and see on which field it is failing (usually Bamboo shows the table names, column names and the names of the constraints involved) - in this particular case, it fails on Buildresultsummary table.
  2. Run these SELECT query to find out the corrupted build results:

    mysql> select buildresultsummary_id from buildresultsummary where BUILD_TYPE = 'BUILD' and chain_result not in (select buildresultsummary_id from buildresultsummary);
    +-----------------------+
    | BUILDRESULTSUMMARY_ID |
    +-----------------------+
    |               2031622 |
    |               2297484 |
    |               2297485 |
    |               2297486 |
    |               2297487 |
    |               2297488 |
    |               2297489 |
    |               2297490 |
    |               2297491 |
    +-----------------------+
    9 rows in set (0.27 sec)
  3. Shut down Bamboo and delete the rows mentioned in the previous step.

    delete from buildresultsummary where buildresultsummary_id in (2031622, 2297484, 2297485, 2297486, 2297487, 2297488, 2297489, 2297490, 2297491);
  4. Then, run these SQL queries to remove the rest of the corruptions:

    delete from TEST_CLASS_RESULT where buildresultsummary_id not in 
    (select buildresultsummary_id from buildresultsummary);
    
    delete from TEST_CASE_RESULT where TEST_CLASS_RESULT_ID in 
    (select TEST_CLASS_RESULT_ID from TEST_CLASS_RESULT where buildresultsummary_id not in 
    (select buildresultsummary_id from buildresultsummary)); 
    
    delete from TEST_ERROR where RESULT_ID in 
    (select TEST_CASE_RESULT_ID from TEST_CASE_RESULT where TEST_CLASS_RESULT_ID in 
    (select TEST_CLASS_RESULT_ID from TEST_CLASS_RESULT where buildresultsummary_id not in 
    (select buildresultsummary_id from buildresultsummary))); 
    
    delete from BRS_LINKEDJIRAISSUES where buildresultsummary_id not in 
    (select buildresultsummary_id from buildresultsummary);
    
    delete from BRS_ARTIFACT_LINK where BuildResultSummary_id not in 
    (select buildresultsummary_id from buildresultsummary );
    
    delete from BRS_ARTIFACT_LINK where ProducerJobResult_id not in 
    (select buildresultsummary_id from buildresultsummary );
    
    delete from BRS_CONSUMED_SUBSCRIPTION where consumer_resultsummary_id not in 
    (select buildresultsummary_id from buildresultsummary);
    
    delete from BRS_CONSUMED_SUBSCRIPTION where artifact_link_id not in 
    (select artifact_link_id from BRS_ARTIFACT_LINK);
    
    delete from BUILDRESULTSUMMARY_LABEL where BuildResultSummary_id not in
    (select buildresultsummary_id from buildresultsummary);
    
    delete from BUILDRESULTSUMMARY_CUSTOMDATA where BuildResultSummary_id not in
    (select buildresultsummary_id from buildresultsummary);
    
    delete from USER_COMMIT where BUILDRESULTSUMMARY_ID not in
    (select buildresultsummary_id from buildresultsummary);
    
    delete from COMMIT_FILES where COMMIT_ID in 
    (select COMMIT_ID from USER_COMMIT where BUILDRESULTSUMMARY_ID not in
    (select buildresultsummary_id from buildresultsummary));
    
    delete from USER_COMMENT where BUILDRESULTSUMMARY_ID not in
    (select buildresultsummary_id from buildresultsummary);
    
    delete from variable_substitution where BUILDRESULTSUMMARY_ID not in
    (select buildresultsummary_id from buildresultsummary);
  5. Start Bamboo, and if there are any other errors, go to step 1.
最終更新日 2016 年 4 月 27 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.