Bamboo 9 startup fails on "Validate not using in memory database" upgrade task

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: High
    • 9.0.1, 9.1.0
    • Affects Version/s: 9.0.0
    • Component/s: Upgrading
    • None
    • 2
    • Severity 2 - Major

      Issue Summary

      Bamboo 9 startup fails on the upgrade task "2 : Validate not using in memory database" when a DB datasource hibernate.connection.datasource is in use instead of a DB URL hibernate.connection.url

      Steps to Reproduce

      1. Configure Bamboo to use a DB Datasource [1] [2]– Use hibernate.connection.datasource instead of hibernate.connection.url in the bamboo-cfg.xml for DB connection details
      2. Start Bamboo 9.0

      Expected Results

      The upgrade task validation should pass

      Actual Results

      The Bamboo bootstrap upgrade task #2 fails on the DB check whilst evaluating a DB data source. The current code expects that hibernate.connection.url is present in the bamboo-cfg.xml, however, if a data source is in use no hibernate.connection.url is provided and it fails with the below Null Pointer Exception:

      2022-09-25 06:59:06,366 INFO [main] [BootstrapUpgradeManagerImpl] -----------------------------------------------------
      2022-09-25 06:59:06,366 INFO [main] [BootstrapUpgradeManagerImpl] 2 : Validate not using in memory database (bootstrap)
      2022-09-25 06:59:06,367 INFO [main] [BootstrapUpgradeManagerImpl] -----------------------------------------------------
      2022-09-25 06:59:06,367 ERROR [main] [BootstrapUpgradeManagerImpl] Task 2 failed
      java.lang.NullPointerException: null
          at com.atlassian.bamboo.upgrade.tasks.validation.RequirePersistentDatabase.doUpgrade(RequirePersistentDatabase.java:23) ~[atlassian-bamboo-web-9.0.0.jar:?]
          at com.atlassian.bamboo.upgrade.BootstrapUpgradeManagerImpl.runValidationTask(BootstrapUpgradeManagerImpl.java:131) ~[atlassian-bamboo-upgrader-9.0.0.jar:?]
          at com.atlassian.bamboo.upgrade.BootstrapUpgradeManagerImpl.lambda$runValidationTasks$0(BootstrapUpgradeManagerImpl.java:89) ~[atlassian-bamboo-upgrader-9.0.0.jar:?]
          at com.atlassian.bamboo.upgrade.AbstractUpgradeManager.forEachTask(AbstractUpgradeManager.java:195) ~[atlassian-bamboo-upgrader-9.0.0.jar:?]
          at com.atlassian.bamboo.upgrade.BootstrapUpgradeManagerImpl.runValidationTasks(BootstrapUpgradeManagerImpl.java:89) ~[atlassian-bamboo-upgrader-9.0.0.jar:?]
          at com.atlassian.bamboo.setup.DefaultBootstrapManager.runValidationTasks(DefaultBootstrapManager.java:483) ~[atlassian-bamboo-web-9.0.0.jar:?]
          a
      ...
      

      The upgrade validation task looks for the hibernate.connection.url string exclusively:

      package com.atlassian.bamboo.upgrade.tasks.validation;
      
      import com.atlassian.bamboo.setup.BambooApplicationConfig;
      import com.atlassian.bamboo.upgrade.AbstractBootstrapUpgradeTask;
      import com.atlassian.bamboo.upgrade.exception.ValidationException;
      import org.apache.commons.lang3.StringUtils;
      import org.apache.log4j.Logger;
      
      import javax.inject.Inject;
      
      public class RequirePersistentDatabase extends AbstractBootstrapUpgradeTask {
          private static final Logger log = Logger.getLogger(RequirePersistentDatabase.class);
      
          @Inject
          private BambooApplicationConfig bambooApplicationConfig;
      
          public RequirePersistentDatabase() {
              super("2", "Validate not using in memory database");
          }
      
          @Override
          public void doUpgrade() throws Exception {
              final String dbUrl = StringUtils.defaultIfBlank(bambooApplicationConfig.getProperty("hibernate.connection.url").toString(), "");
              if (dbUrl.contains("jdbc:h2:mem:")) {
                  throw new ValidationException("Using in memory database is not allowed.");
              }
          }
      } 
      

      Workarounds

      • Option 1: Make Bamboo ignore the upgrade Task during its bootstrap:
        • Stop Bamboo
        • Backup $BAMBOO_INSTALL/atlassian-bamboo/WEB-INF/classes/upgrades.xml
        • Comment the following line $BAMBOO_INSTALL/atlassian-bamboo/WEB-INF/classes/upgrades.xml
          <!-- upgrade build="2" build-min="0" build-max="999999" class="com.atlassian.bamboo.upgrade.tasks.validation.RequirePersistentDatabase"/ -->
          
        • Start Bamboo

      OR

      • Option 2: Modify the Bamboo server configuration to use a DB URL hibernate.connection.url instead of a Datasource hibernate.connection.datasource
        • Stop Bamboo
        • Backup $BAMBOO_HOME/bamboo.cfg.xml
        • Edit $BAMBOO_HOME/bamboo.cfg.xml and replace the hibernate.connection.datasource entry with its equivalent hibernate.connection.url, hibernate.connection.username, hibernate.connection.password, hibernate.connection.driver_class, hibernate.connection.provider_class. Details on the connection string can be found on the following pages:
        • Start Bamboo

            Assignee:
            Mateusz Szmal
            Reporter:
            Anik Sengupta
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: