Duplicate key in table, or Table not found errors in Schema Update section of Startup process

お困りですか?

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

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

問題

When upgrading Bamboo, you see INFO and ERROR lines such as the following in the atlassian-bamboo.log

2017-03-28 09:48:22,618 INFO [localhost-startStop-1] [DatabaseMetaData] HHH000262: Table not found: QUICK_FILTERS
...
2017-03-28 09:48:25,175 ERROR [localhost-startStop-1] [SchemaUpdate] HHH000388: Unsuccessful: alter table BRS_CONSUMED_SUBSCRIPTION add constraint FK_l4tpi519m59qhdvh4qx2cjp2n foreign key (CONSUMER_RESULTSUMMARY_ID) references BUILDRESULTSUMMARY (BUILDRESULTSUMMARY_ID)
2017-03-28 09:48:25,175 ERROR [localhost-startStop-1] [SchemaUpdate] Can't write; duplicate key in table '#sql-1620_1fb7d'


原因

Bamboo does a schema check (and auto correct) on every startup to ensure its integrity. A fixed set of commands are run and afterwards, if the database is configured correctly, the errors may still appear.


検証

You can validate that the foreign keys are already in the tables to ensure everything is correct as per the error above. And then, you can safely ignore these errors

  1. Locate an unsuccessful alter command in the logs:

    alter table BRS_CONSUMED_SUBSCRIPTION add constraint FK_l4tpi519m59qhdvh4qx2cjp2n foreign key (CONSUMER_RESULTSUMMARY_ID) references BUILDRESULTSUMMARY (BUILDRESULTSUMMARY_ID)
  2. Run the following command in the Bamboo database:

    show create table BRS_CONSUMED_SUBSCRIPTION;
  3. Look for a line in the output referring to the constraint being added:

    ...
    CONSTRAINT `FK_l4tpi519m59qhdvh4qx2cjp2n` FOREIGN KEY (`CONSUMER_RESULTSUMMARY_ID`) REFERENCES `buildresultsummary` (`BUILDRESULTSUMMARY_ID`)
    ...


To check the remaining Table not found errors, you can run queries using the tables listed in the errors. Below are some examples based on database type:

MySQL

show tables like 'QUICK_FILTERS';


PostgreSQL

\dt 'QUICK_FILTERS'


MS SQL

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES 
           WHERE TABLE_NAME = N'QUICK_FILTERS')
BEGIN
  PRINT 'Table Exists'
END


Oracle

SHOW TABLES LIKE 'QUICK_FILTERS';




最終更新日 2022 年 4 月 18 日

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

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