Database Corruption - Cleaning the Artifact Definitions manually

お困りですか?

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

コミュニティに質問

症状

Bamboo logs contains errors like this:

Export has failed. Errors encountered while exporting: No row with the given identifier exists: 40271880, of class: com.atlassian.bamboo.plan.artifact.ArtifactDefinitionImpl; nested exception is net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 40271880, of class: com.atlassian.bamboo.plan.artifact.ArtifactDefinitionImpl.

2012-01-24 22:31:09,100 ERROR [qtp31149935-239] [Export] org.springframework.orm.hibernate.HibernateObjectRetrievalFailureException: No row with the given identifier exists: 40271880, of class: com.atlassian.bamboo.plan.artifact.ArtifactDefinitionImpl; nested exception is net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 40271880, of class: com.atlassian.bamboo.plan.artifact.ArtifactDefinitionImpl
org.springframework.orm.hibernate.HibernateObjectRetrievalFailureException: No row with the given identifier exists: 40271880, of class: com.atlassian.bamboo.plan.artifact.ArtifactDefinitionImpl; nested exception is net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 40271880, of class: com.atlassian.bamboo.plan.artifact.ArtifactDefinitionImpl
Caused by: net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 40271880, of class: com.atlassian.bamboo.plan.artifact.ArtifactDefinitionImpl
        at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
        at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1962)
        at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
        at net.sf.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:108)
        at net.sf.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:79)
        at net.sf.hibernate.loader.Loader.list(Loader.java:1045)
...

原因

Somehow Bamboo server didn't delete artifact definitions, and this caused database corruption, which was noticed when trying to export (Administration -> Export).

ソリューション

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 which don't exist. Make sure that you have a Bamboo database backup, and follow the steps below:

  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)
  2. Run these SELECT queries to find out where exactly the corruption exists:

    select * from ARTIFACT_DEFINITION where ARTIFACT_DEFINITION_ID = 40271880;
    select * from ARTIFACT_SUBSCRIPTION where ARTIFACT_DEFINITION_ID = 40271880;
    select * from artifact_definition where PRODUCER_JOB_ID not in (select build_id from build);
    select * from artifact_subscription where CONSUMER_JOB_ID not in (select build_id from build);
    select * from artifact_subscription where ARTIFACT_DEFINITION_ID not in (select ARTIFACT_DEFINITION_ID from ARTIFACT_DEFINITION);
  3. Shut down Bamboo and delete the rows mentioned in the previous step. For example, if the third SELECT statement returns some rows, then run the corresponding DELETE statement:

    delete from artifact_definition where PRODUCER_JOB_ID not in (select build_id from build);
  4. Start Bamboo, and if there are any other errors, go to step 1.

 

The whole idea behind these SQL queries is to clean the database step by step based on the error that Bamboo shows after each deletion step.

 

最終更新日 2013 年 7 月 5 日

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

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