My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 2046: Error during schema upgrade 73 to 74 - 'Duplicate entry' for a primary key in account groups
3 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by schniede...@gmail.com, Aug 5, 2013
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version:

What steps will reproduce the problem?
1. I have an existing gerrit DB (MySQL) with schema version 73 (gerrit 2.5.6).
2. I stopped gerrit, replaced gerrit.war with a link to 2.6.1 gerrit.war, and run "java -jar ./gerrit-2.6.1.war init --batch -d /srv/gerrit".

What is the expected output? What do you see instead?
- I expect schema upgrades from 73 to 74 (and then further).
- Instead, I see this error during the 73->74 upgrade:

Upgrading database schema from version 73 to 74 ...
Exception in thread "main" com.google.gwtorm.server.OrmException: insert failure on account_group_includes_by_uuid
	at com.google.gwtorm.schema.sql.SqlDialect.convertError(SqlDialect.java:151)
	at com.google.gwtorm.jdbc.JdbcAccess.convertError(JdbcAccess.java:448)
....
Caused by: java.sql.BatchUpdateException: Duplicate entry '9-214a46be33d2e356f3a71a53ea9aa4e1d8d2b4c1' for key 'PRIMARY'
	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2054)
	at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
....
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '9-214a46be33d2e356f3a71a53ea9aa4e1d8d2b4c1' for key 'PRIMARY'
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

I see an account group with group uuid "214a46be33d2e356f3a71a53ea9aa4e1d8d2b4c1" (without the leading "9-") in my DB. If I remove that specific group, it will just throw the same error on the next account group uuid.

Please provide any additional information below.
- I see the same error when trying to upgrade to 2.6 first (which is not surprising as it would run through the same schema upgrades)
Aug 5, 2013
#1 schniede...@gmail.com
This is the complete error message:
Upgrading database schema from version 73 to 74 ...
Exception in thread "main" com.google.gwtorm.server.OrmException: insert failure on account_group_includes_by_uuid
	at com.google.gwtorm.schema.sql.SqlDialect.convertError(SqlDialect.java:151)
	at com.google.gwtorm.jdbc.JdbcAccess.convertError(JdbcAccess.java:448)
	at com.google.gwtorm.jdbc.JdbcAccess.insert(JdbcAccess.java:160)
	at com.google.gerrit.server.schema.Schema_74.migrateData(Schema_74.java:111)
	at com.google.gerrit.server.schema.SchemaVersion.upgradeFrom(SchemaVersion.java:100)
	at com.google.gerrit.server.schema.SchemaVersion.check(SchemaVersion.java:77)
	at com.google.gerrit.server.schema.SchemaVersion.upgradeFrom(SchemaVersion.java:91)
	at com.google.gerrit.server.schema.SchemaVersion.check(SchemaVersion.java:77)
	at com.google.gerrit.server.schema.SchemaVersion.upgradeFrom(SchemaVersion.java:91)
	at com.google.gerrit.server.schema.SchemaVersion.check(SchemaVersion.java:77)
	at com.google.gerrit.server.schema.SchemaVersion.upgradeFrom(SchemaVersion.java:91)
	at com.google.gerrit.server.schema.SchemaVersion.check(SchemaVersion.java:77)
	at com.google.gerrit.server.schema.SchemaUpdater.update(SchemaUpdater.java:64)
	at com.google.gerrit.pgm.Init$SiteRun.upgradeSchema(Init.java:175)
	at com.google.gerrit.pgm.Init.run(Init.java:78)
	at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:67)
	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:616)
	at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:168)
	at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:92)
	at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:50)
	at Main.main(Main.java:25)
Caused by: java.sql.BatchUpdateException: Duplicate entry '9-214a46be33d2e356f3a71a53ea9aa4e1d8d2b4c1' for key 'PRIMARY'
	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2054)
	at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
	at com.google.gwtorm.schema.sql.SqlDialect.executeBatch(SqlDialect.java:370)
	at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:438)
	at com.google.gwtorm.jdbc.JdbcAccess.insertAsBatch(JdbcAccess.java:202)
	at com.google.gwtorm.jdbc.JdbcAccess.insert(JdbcAccess.java:155)
	... 21 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '9-214a46be33d2e356f3a71a53ea9aa4e1d8d2b4c1' for key 'PRIMARY'
	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:532)
	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:1040)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2450)
	at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2006)
	... 26 more

Aug 5, 2013
#2 schniede...@gmail.com
Workaround that seems to work for me:
- While at schema 73 (v2.5.6), truncate table account_group_includes
- Then run the schema upgrades

After that, the account group includes are still intact (they migrated to the new account_group_includes_uuid table).
Sign in to add a comment

Powered by Google Project Hosting