Bamboo fails to start due to invalid branch keys

Still need help?

The Atlassian Community is here for you.

Ask the community

Problem

Bamboo fails to start, with the message"Bamboo bootstrap failed"appearing in the UI. The following errors are found in the logs during startup:

2015-05-05 11:59:46,533 11:59:46,471 INFO [main] [DefaultBootstrapManager] Running pre-bootstrap validation tasks
2015-05-05 11:59:46,533 INFO [main] [AbstractUpgradeManager] -----------------------------------------------------------------
2015-05-05 11:59:46,533 INFO [main] [AbstractUpgradeManager] 4300 : Make sure there's single row in HIBERNATE_UNIQUE_KEY table
2015-05-05 11:59:46,533 INFO [main] [AbstractUpgradeManager] -----------------------------------------------------------------
2015-05-05 11:59:46,538 INFO [main] [NamingHelper] JNDI InitialContext properties:{}
2015-05-05 11:59:46,542 INFO [main] [DatasourceConnectionProvider] Using datasource: java:comp/env/jdbc/DefaultDS
2015-05-05 11:59:46,549 INFO [main] [AbstractUpgradeManager] Completed task 4300 successfully.
2015-05-05 11:59:46,549 INFO [main] [AbstractUpgradeManager] -------------------------------------------------------------------------
2015-05-05 11:59:46,549 INFO [main] [AbstractUpgradeManager] 4410 : Make sure that all branch keys start with their master's chain key
2015-05-05 11:59:46,549 INFO [main] [AbstractUpgradeManager] -------------------------------------------------------------------------
2015-05-05 11:59:46,550 INFO [main] [NamingHelper] JNDI InitialContext properties:{}
2015-05-05 11:59:46,550 INFO [main] [DatasourceConnectionProvider] Using datasource: java:comp/env/jdbc/DefaultDS
2015-05-05 11:59:46,565 INFO [main] [AbstractUpgradeManager] Completed task 4410 with errors.
@400000005548a8c21af72ce4 2015-05-05 12:25:44,452 FATAL [main] [DefaultBootstrapManager] Pre-bootstrap validation tests failed: [Task for build 4410 failed:, com.atlassian.bamboo.upgrade.tasks.validation.BranchKeyStartsWithMastersChainKey: There are invalid branch keys in the BUILD table: [MYPROJECT-MYPLAN0, MYPROJECT-MYPLAN1]]
2015-05-05 11:59:46,567 INFO [main] [lifecycle] Using bamboo.home: /data/jirastudio/bamboo/home
2015-05-05 11:59:46,580 INFO [main] [UpgradeLauncher] UpgradeLauncher not performed since the application has not been setup yet.
2015-05-05 11:59:46,587 INFO [main] [BambooInitialData] Starting Bamboo Initial Data Setup
2015-05-05 11:59:46,967 INFO [main] [SetupUtilityBean] Creating the directory structure...

In the above log extract, the problematic branches are identified by this line:

There are invalid branch keys in the BUILD table: [MYPROJECT-MYPLAN0, MYPROJECT-MYPLAN1]


Environment

If you are experiencing this on a version of Bamboo more recent than 5.12.0.2 you are more than likely hitting the below bug instead and should consult the workaround on the bug report: BAM-18596 - Getting issue details... STATUS

  • Affects Bamboo 5.12.0.2 or older

Cause

Each plan and branch plan in Bamboo exists as an individual record in the BUILD table. An important piece of data in each BUILD record is its BUILD.FULL_KEY column value, which contains both the parent project key and the master plan key. When Bamboo starts up it performs some basic validation to ensure each branch plan's FULL_KEY value starts with the master plan's FULL_KEY value.

When moving a plan to another project, or changing a plan key, all of the master and branch plan BUILD.FULL_KEY values are updated to match the new project or plan key. Due to the bug  BAM-15524 - Getting issue details... STATUS , Bamboo versions prior to 5.12.0.2 may see this operation fail mid-way through. This results in some branch plans not being updated with a new FULL_KEY value, which causes the above validation to fail and results in the startup error.

Resolution

Update the invalid BUILD.FULL_KEY values back to their original (pre-move) value. We will also update the BUILD.BUILD_KEY values as they may also be affected, although invalid BUILD_KEY values should not affect the startup process.

Please note that if multiple, separate plans were affected, you may need to repeat these steps to fix each plan. 

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

  1. Using one of the invalid branch keys mentioned in the error, run the following SQL to identify the master branch plan record. In this example, we will use BRANCH-KEY0

    SELECT MASTER_ID
      FROM BUILD
     WHERE FULL_KEY='MYPROJECT-MYPLAN0';
  2. Using the MASTER_ID value from the previous query, find the current FULL_KEY value from the master branch. In this example, our MASTER_ID result from the previous query was 12345

    SELECT FULL_KEY
      FROM BUILD 
     WHERE BUILD_ID=12345;
  3. Note down the FULL_KEY value from the above query. In this example, the result was MYNEWPROJECT-MYPLAN. Here we can now see that the inconsistency has occurred because the FULL_KEY value of the branch plans do not start with MYNEWPROJECT-MYPLAN, which has caused the branch key validation to fail.

    If your Bamboo is currently online (maybe you followed the workaround in BAM-15524 - Getting issue details... STATUS ), please shutdown Bamboo before making any database modifications.

  4. Update the branch plan records that were moved, including the master plan, back to their original pre-rename values. This will effectively undo the move operation. In our example, we want to change any instances of MYNEWPROJECT-MYPLAN back to MYPROJECT-MYPLAN:

    UPDATE BUILD
       SET FULL_KEY = REPLACE(FULL_KEY, 'MYNEWPROJECT-MYPLAN', 'MYPROJECT-MYPLAN'),
           BUILDKEY = REPLACE(BUILDKEY, 'MYNEWPROJECT-MYPLAN', 'MYPROJECT-MYPLAN')
     WHERE (MASTER_ID=12345 OR BUILD_ID=12345)
       AND FULL_KEY LIKE 'MYNEWPROJECT-MYPLAN%';
  5. Start Bamboo, go to Bamboo Admin >> System >> Indexing and perform a full reindex.

Last modified on Jan 16, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.