Build fail with duplicate key value error for AO tables

お困りですか?

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

コミュニティに質問

問題

Build fail with the following appears in the atlassian-bamboo.log

2018-06-04 06:22:03,752 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-2] [BambooPluginUtils] Error while executing com.atlassian.bamboo.brokenbuildtracker.BrokenBuildPostProcessor
com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library:
Database:
	- name:PostgreSQL
	- version:9.1.18
	- minor version:1
	- major version:9
Driver:
	- name:PostgreSQL Native Driver
	- version:PostgreSQL 9.4.1209

org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "AO_7A45FB_AOTRACKING_RESULT_pkey"
  Detail: Key ("RESULT_ID")=(49324) already exists.
...
2018-06-04 06:07:00,815 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-7] [BambooPluginUtils] Error while executing com.atlassian.bamboo.brokenbuildtracker.BrokenBuildPostProcessor
com.atlassian.activeobjects.internal.ActiveObjectsSqlException: There was a SQL exception thrown by the Active Objects library:
Database:
	- name:PostgreSQL
	- version:9.1.18
	- minor version:1
	- major version:9
Driver:
	- name:PostgreSQL Native Driver
	- version:PostgreSQL 9.4.1209

org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "AO_7A45FB_AOTRACKING_ENTRY_pkey"
  Detail: Key ("TRACKING_ID")=(12522) already exists.

原因

PostgreSQL database server might have restarted when Bamboo is still running causing data inconsistency.

ソリューション

  1. Shutdown Bamboo
  2. Backup database for rollback purposes
  3. Run the following SQL queries:

    SELECT MAX("TRACKING_ID") AS "lastTrackingID" FROM "AO_7A45FB_AOTRACKING_ENTRY";
    SELECT MAX("RESULT_ID") AS "lastResultID" FROM "AO_7A45FB_AOTRACKING_RESULT";
  4. Run the following SQL queries depending on the above results:

    SELECT SETVAL('"AO_7A45FB_AOTRACKING_ENTRY_TRACKING_ID_seq"',lastTrackingID);
    SELECT SETVAL('"AO_7A45FB_AOTRACKING_RESULT_RESULT_ID_seq"',lastResultID);

    Replace lastTrackingID and lastResultID with the results in Step 3

  5. Restart Bamboo


最終更新日 2018 年 7 月 10 日

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

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