Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-19276

Failure in H2 database migration script for Bitbucket fails on using database password

      Issue Summary

      H2 database migration is required when upgrading Bitbucket  from versions below 8.8 to Bitbucket 8.8+ as Migrate H2 database from 1.x to 2.1. The migration script gives following error when H2 database is associated with the password

      RUNSCRIPT FROM 'h2_script.sql'  FROM_1X -password XXXXXX [42000-214]
      	at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
      	at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
      	at org.h2.message.DbException.get(DbException.java:223)
      	at org.h2.message.DbException.get(DbException.java:199)
      	at org.h2.message.DbException.getSyntaxError(DbException.java:247)
      	at org.h2.command.Parser.getSyntaxError(Parser.java:898)
      	at org.h2.command.Parser.prepareCommand(Parser.java:572)
      	at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631)
      	at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554)
      	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116)
      	at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:237)
      	at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223)
      	at org.h2.tools.RunScript.processRunscript(RunScript.java:273)
      	at org.h2.tools.RunScript.runTool(RunScript.java:137)
      	at org.h2.tools.RunScript.main(RunScript.java:66) 
      

       H2 database password is set using JDBC_PASSWORD  env variable during the script execution.

      This is reproducible on Data Center: (yes) 

      Steps to Reproduce

      1. Set the password for H2 database sa user
      2. Try to migrate the H2 database using the steps mentioned in guide Migrate H2 database from 1.x to 2.1. Set the JDBC-PASSWORD env variable and execute the script
        export JDBC_PASSWORD=NEW_PASSWORD 
        BITBUCKET_HOME=<Home directory> SOURCE_INST_DIR=<Old installation directory> ./h2-migrate-db-file.sh 
      3. Script execution prints following error, but still prints the success message
        RUNSCRIPT FROM 'h2_script.sql'  FROM_1X -password XXXXXX [42000-214]
        	at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
        	at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
        	at org.h2.message.DbException.get(DbException.java:223)
        	at org.h2.message.DbException.get(DbException.java:199)
        	at org.h2.message.DbException.getSyntaxError(DbException.java:247)
        	at org.h2.command.Parser.getSyntaxError(Parser.java:898)
        	at org.h2.command.Parser.prepareCommand(Parser.java:572)
        	at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631)
        	at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554)
        	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116)
        	at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:237)
        	at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223)
        	at org.h2.tools.RunScript.processRunscript(RunScript.java:273)
        	at org.h2.tools.RunScript.runTool(RunScript.java:137)
        	at org.h2.tools.RunScript.main(RunScript.java:66)
        + [[ 0 -eq 0 ]]
        + [[ -f /home/ubuntu/bbmirror/shared/data/db.mv.db ]]
        + echo 'Run script finished, DB file generated successfully at /home/ubuntu/bbmirror/shared/data/db.mv.db'
        Run script finished, DB file generated successfully at /home/ubuntu/bbmirror/shared/data/db.mv.db
        + rm -rf h2_script.sql 
      4. Database db.mv.db is created but there is no data present in it

      Expected Results

      Script should be executed successfully and DB db.mv.db should include data

      Actual Results

      The below exception is thrown in the xxxxxxx.log file:

      RUNSCRIPT FROM 'h2_script.sql'  FROM_1X -password NEW_PASSWORD [42000-214]
      	at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)
      	at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
      	at org.h2.message.DbException.get(DbException.java:223)
      	at org.h2.message.DbException.get(DbException.java:199)
      	at org.h2.message.DbException.getSyntaxError(DbException.java:247)
      	at org.h2.command.Parser.getSyntaxError(Parser.java:898)
      	at org.h2.command.Parser.prepareCommand(Parser.java:572)
      	at org.h2.engine.SessionLocal.prepareLocal(SessionLocal.java:631)
      	at org.h2.engine.SessionLocal.prepareCommand(SessionLocal.java:554)
      	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1116)
      	at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:237)
      	at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223)
      	at org.h2.tools.RunScript.processRunscript(RunScript.java:273)
      	at org.h2.tools.RunScript.runTool(RunScript.java:137)
      	at org.h2.tools.RunScript.main(RunScript.java:66)  

      Workaround

      Set the blank default password for H2 database before triggering the migration and then run the migration script.

              mgoyal2@atlassian.com Manish
              57730852f533 Jaya Mantri
              Affected customers:
              0 This affects my team
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: