Issue 3368: SQLException when updating from 2.9.1 to 2.10
Status:  Invalid
Owner: ----
Closed:  May 2015
Reported by jani.kyt...@gmail.com, May 13, 2015
Affected Version: 2.10

What steps will reproduce the problem?
1. Update Gerrit version from 2.9.1 to 2.10
2. Run init program java -jar gerrit.war init -d site_path
3. After adding all needed settings there comes note: Wrong Primary Key Column Order Detected. After answering yes to Fix primary key column order -question init program tries to fix primary keys but it fails. 


What is the expected output? What do you see instead?
Fixing primary keys works. Now it fails with following log:

*** Wrong Primary Key Column Order Detected
***

The following tables are affected:
patch_set_approvals, patch_sets, schema_version, starred_changes, submodule_subscriptions, system_config
Fix primary keys column order  [Y/n]?
fixing primary keys...
  table: patch_set_approvals ... WARN: primary key for table patch_set_approvals didn't exist ... Exception in thread "main" com.google.gwtorm.server.OrmException: Cannot apply SQL
ALTER TABLE patch_set_approvals ADD PRIMARY KEY(change_id,patch_set_id,account_id,category_id)
        at com.google.gwtorm.jdbc.JdbcExecutor.execute(JdbcExecutor.java:44)
        at com.google.gerrit.pgm.init.UpdatePrimaryKeys.recreatePK(UpdatePrimaryKeys.java:177)
        at com.google.gerrit.pgm.init.UpdatePrimaryKeys.postRun(UpdatePrimaryKeys.java:86)
        at com.google.gerrit.pgm.init.SitePathInitializer.postRun(SitePathInitializer.java:118)
        at com.google.gerrit.pgm.BaseInit.run(BaseInit.java:116)
        at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:64)
        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:166)
        at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:93)
        at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:50)
        at Main.main(Main.java:25)
Caused by: java.sql.SQLException: ORA-02437: cannot validate (GERRIT.SYS_C0022058) - primary key violated

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1036)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
        at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1916)
        at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1878)
        at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
        at com.google.gwtorm.jdbc.JdbcExecutor.execute(JdbcExecutor.java:42)
        ... 13 more


Please provide any additional information below.

Gerrit starts correctly despite this error and seems to work also otherwise well.

May 14, 2015
#1 jani.kyt...@gmail.com
This issue can be ignored. There was indeed one duplicated record in patch_set_approvals table. After deleting it init was executed properly.
May 14, 2015
Project Member #2 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Invalid