Issue 2382: Database error at schema 70 during data migration of gerrit site
Status:  Released
Owner: ----
Closed:  Jan 2014
Project Member Reported by zaro0508, Jan 6, 2014
I get a MySQLSyntaxErrorException when attempting to upgrade a gerrit site.  I don't get the error on creation of a new site, just on upgrade.

Affected Version: master (1bcb2ca18056ae64d701d984b0de63ad03dc90ee)

What steps will reproduce the problem?
I got the error when attempting to upgrade from version 2.4.  I'm using mysql 5.5
1. get or build the gerrit.war
2. run init script to upgrade an existing gerrit site (i.e.  java -jar gerrit.war init -d gerrit_site --batch) 

What is the expected output? What do you see instead?
I expect upgrade to work without any errors.

I get the following..

Downloading http://repo2.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar ... OK
Checksum mysql-connector-java-5.1.21.jar OK
Upgrading schema to 65 ...
Upgrading schema to 66 ...
Upgrading schema to 67 ...
Upgrading schema to 68 ...
Upgrading schema to 69 ...
Upgrading schema to 70 ...
Upgrading schema to 71 ...
Upgrading schema to 72 ...
Upgrading schema to 73 ...
Upgrading schema to 74 ...
Upgrading schema to 75 ...
Upgrading schema to 76 ...
Upgrading schema to 77 ...
Upgrading schema to 78 ...
Upgrading schema to 79 ...
Upgrading schema to 80 ...
Upgrading schema to 81 ...
Upgrading schema to 82 ...
Upgrading schema to 83 ...
Upgrading schema to 84 ...
Upgrading schema to 85 ...
Upgrading schema to 86 ...
Upgrading schema to 87 ...
Upgrading schema to 88 ...
Upgrading schema to 89 ...
Upgrading schema to 90 ...
Upgrading schema to 91 ...
Migrating data to schema 65 ...
Moved contributor agreements to project.config
Migrating data to schema 66 ...
Migrating data to schema 67 ...
Update ownerGroupId to ownerGroupUUID
Migrating data to schema 68 ...
Migrating data to schema 69 ...
Migrating data to schema 70 ...
Exception in thread "main" com.google.gwtorm.server.OrmException: Cannot upgrade schema
	at com.google.gerrit.server.schema.SchemaUpdater.update(SchemaUpdater.java:66)
	at com.google.gerrit.pgm.BaseInit$SiteRun.upgradeSchema(BaseInit.java:214)
	at com.google.gerrit.pgm.BaseInit.run(BaseInit.java:91)
	at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:169)
	at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:96)
	at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:53)
	at Main.main(Main.java:25)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'tracking_key' in 'field list'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
	at com.mysql.jdbc.Util.getInstance(Util.java:386)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2819)
	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1842)
	at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1764)
	at com.google.gerrit.server.schema.Schema_70.migrateData(Schema_70.java:38)
	at com.google.gerrit.server.schema.SchemaVersion.migrateData(SchemaVersion.java:143)
	at com.google.gerrit.server.schema.SchemaVersion.upgradeFrom(SchemaVersion.java:88)
	at com.google.gerrit.server.schema.SchemaVersion.check(SchemaVersion.java:79)
	at com.google.gerrit.server.schema.SchemaUpdater.update(SchemaUpdater.java:64)
	... 11 more

Jan 9, 2014
Project Member #1 david.pu...@sonymobile.com
Do you also get the same error if you run without --batch?

I can't test it with --batch because I'm behind a proxy and the mysql connector download fails.  If I run it interactively and manually download the mysql connector, the upgrade works fine.

mysql Server version: 5.5.34-0ubuntu0.12.04.1 (Ubuntu)


Status: AwaitingInformation
Jan 9, 2014
Project Member #2 david.pu...@sonymobile.com
Ah, wait.  I tested with the 2.8 official release war file.

Now I tested it with a war file built from the latest master, and was able to reproduce it.

Status: Accepted
Jan 9, 2014
Project Member #3 david.pu...@sonymobile.com
(No comment was entered for this change.)
Labels: Blocking-2.9
Jan 9, 2014
Project Member #4 david.pu...@sonymobile.com
https://gerrit-review.googlesource.com/#/c/53610/
Status: ChangeUnderReview
Jan 11, 2014
Project Member #5 David.Os...@gmail.com
The problem occurs only on upcoming 2.9 release. 9f4de526dd3fec0400f6df53628956a4bf0d9033 was applied after 2.8 was cut off. The 2.8 release doesn't suffer from this bug.
Summary: Database error at schema 70 during data migration of gerrit site (was: MySQLSyntaxErrorException at schema 70 during an upgrade of gerrit site)
Jan 13, 2014
Project Member #6 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Submitted
Labels: -Blocking-2.9 FixedIn-2.9
Jul 18, 2014
Project Member #7 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Released