Database Migration Failing

16 views
Skip to first unread message

Ash

unread,
Oct 22, 2024, 8:51:19 PM10/22/24
to go-cd
Hi,  I am trying to migrate gocd from 19.2.0 to latest version and trying to backup the database and insert into new postgress SQL.
When running db migration script, I am getting following error

./gocd-database-migrator --insert --source-db-url='jdbc:h2:/var/tmp/cruise'  --source-db-user='sa'  --target-db-url='jdbc:h2:/var/tmp/gocd/newdb/cruise' --target-db-user='target-sa' --target-db-password='target-sa
-password'


ERROR

INFO: No `--source-db-driver-class` is specified. Setting `--source-db-driver-class='org.h2.Driver'`.
INFO: No `--target-db-driver-class` specified. Setting `--target-db-driver-class='org.h2.Driver'`.
2024-10-23 09:52:27,032 INFO  [main] DbSync:77 - Using dialect H2 for source database.
2024-10-23 09:52:27,100 INFO  [main] DbSync:78 - Using dialect H2 for target database.
Reading change scripts from directory /apps/installs/gocd-database-migrator-1.0.4/h2deltas...
dbdeploy v2.11
Changes currently applied to database:
  1..90, 221001, 230001..230009, 240001, 240002, 300001..300011, 1202001..1202003, 1203002..1203005, 1301001, 1302001, 1303001..1303004, 1304001, 1401001, 1403001, 1403002, 1501001..1501003, 1502001, 1503001, 1503002, 1606001, 1606002, 1607001, 1610001, 1701001, 1702001, 1704001..1704003, 1708001, 1801001..1801007, 1802001, 1802002, 1804001, 1805001, 1807001, 1807002, 1808001, 1808002, 1901001, 1902001..1902008
Scripts available:
  1..90, 221001, 230001..230009, 240001, 240002, 300001..300011, 1202001..1202003, 1203002..1203005, 1301001, 1302001, 1303001..1303004, 1304001, 1401001, 1403001, 1403002, 1501001..1501003, 1502001, 1503001, 1503002, 1606001, 1606002, 1607001, 1610001, 1701001, 1702001, 1704001..1704003, 1708001, 1801001..1801007, 1802001, 1802002, 1804001, 1805001, 1807001, 1807002, 1808001, 1808002, 1901001, 1902001..1902008, 1903001..1903003, 1909001, 1910001..1910006
To be applied:
  1903001..1903003, 1909001, 1910001..1910006
2024-10-23 09:52:27,191 ERROR [main] DbSync:99 - null
org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NullPointerException: Cannot invoke ""org.h2.index.Index.getRowCountApproximation()"" because ""this.scanIndex"" is null"; SQL statement:


--------------- Fragment begins: #1903001: 1903001_add_status_and_message_to_server_backup.sql ---------------
INSERT INTO changelog (change_number, delta_set, start_dt, applied_by, description) VALUES (1903001, 'DDL', CURRENT_TIMESTAMP, USER(), '1903001_add_status_and_message_to_server_backup.sql'); [50000-200]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:505)
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
        at org.h2.message.DbException.get(DbException.java:194)
        at org.h2.message.DbException.convert(DbException.java:347)
        at org.h2.command.Command.executeUpdate(Command.java:259)
        at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)
        at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)
        at com.thoughtworks.go.dbsync.DbSync.lambda$export$2(DbSync.java:86)
        at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:97)
        at com.thoughtworks.go.dbsync.DbSync.export(DbSync.java:80)
        at com.thoughtworks.go.dbsync.cli.Main.main(Main.java:46)
Caused by: java.lang.NullPointerException: Cannot invoke "org.h2.index.Index.getRowCountApproximation()" because "this.scanIndex" is null
        at org.h2.pagestore.db.PageStoreTable.getRowCountApproximation(PageStoreTable.java:510)
        at org.h2.pagestore.db.PageDataIndex.getCost(PageDataIndex.java:284)
        at org.h2.table.Table.getBestPlanItem(Table.java:761)
        at org.h2.table.TableFilter.getBestPlanItem(TableFilter.java:251)
        at org.h2.command.dml.Update.prepare(Update.java:284)
        at org.h2.command.CommandList.executeRemaining(CommandList.java:46)
        at org.h2.command.CommandList.update(CommandList.java:67)
        at org.h2.command.CommandList.executeRemaining(CommandList.java:59)
        at org.h2.command.CommandList.update(CommandList.java:67)
        at org.h2.command.Command.executeUpdate(Command.java:251)
        ... 8 common frames omitted
java.lang.RuntimeException: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NullPointerException: Cannot invoke ""org.h2.index.Index.getRowCountApproximation()"" because ""this.scanIndex"" is null"; SQL statement:


--------------- Fragment begins: #1903001: 1903001_add_status_and_message_to_server_backup.sql ---------------
INSERT INTO changelog (change_number, delta_set, start_dt, applied_by, description) VALUES (1903001, 'DDL', CURRENT_TIMESTAMP, USER(), '1903001_add_status_and_message_to_server_backup.sql'); [50000-200]
        at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:100)
        at com.thoughtworks.go.dbsync.DbSync.export(DbSync.java:80)
        at com.thoughtworks.go.dbsync.cli.Main.main(Main.java:46)
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NullPointerException: Cannot invoke ""org.h2.index.Index.getRowCountApproximation()"" because ""this.scanIndex"" is null"; SQL statement:


--------------- Fragment begins: #1903001: 1903001_add_status_and_message_to_server_backup.sql ---------------
INSERT INTO changelog (change_number, delta_set, start_dt, applied_by, description) VALUES (1903001, 'DDL', CURRENT_TIMESTAMP, USER(), '1903001_add_status_and_message_to_server_backup.sql'); [50000-200]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:505)
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
        at org.h2.message.DbException.get(DbException.java:194)
        at org.h2.message.DbException.convert(DbException.java:347)
        at org.h2.command.Command.executeUpdate(Command.java:259)
        at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228)
        at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)
        at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)
        at com.thoughtworks.go.dbsync.DbSync.lambda$export$2(DbSync.java:86)
        at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:97)
        ... 2 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.h2.index.Index.getRowCountApproximation()" because "this.scanIndex" is null
        at org.h2.pagestore.db.PageStoreTable.getRowCountApproximation(PageStoreTable.java:510)
        at org.h2.pagestore.db.PageDataIndex.getCost(PageDataIndex.java:284)
        at org.h2.table.Table.getBestPlanItem(Table.java:761)
        at org.h2.table.TableFilter.getBestPlanItem(TableFilter.java:251)
        at org.h2.command.dml.Update.prepare(Update.java:284)
        at org.h2.command.CommandList.executeRemaining(CommandList.java:46)
        at org.h2.command.CommandList.update(CommandList.java:67)
        at org.h2.command.CommandList.executeRemaining(CommandList.java:59)
        at org.h2.command.CommandList.update(CommandList.java:67)
        at org.h2.command.Command.executeUpdate(Command.java:251)



Chad Wilson

unread,
Oct 22, 2024, 9:40:04 PM10/22/24
to go...@googlegroups.com
I'm not sure, but you might want to try upgrading your database to GoCD 20.4.0 the 'normal way' first and then see if you can migrate that upgraded 20.4.0 database.

If that doesn't work your H2DB might have some corruption that needs fixing before migrating (usually done by doing an export to sql and import to a new db file)


--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/845613bb-1405-4a3a-a0cf-dcc72215e543n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages