-
Bug
-
Resolution: Fixed
-
Low
-
8.18.0, 8.9.10
-
1
-
Severity 3 - Minor
-
3
-
-
RtB - Service ops & Tech entropy
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
- Set the password for H2 database sa user
- 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
- 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
- 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.