CandyShop / gerrit

Automatically exported from code.google.com/p/gerrit
Apache License 2.0
1 stars 0 forks source link

SQLException when updating from 2.9.1 to 2.10 #3368

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by jani.kyt...@gmail.com on 14 May 2015 at 4:37

GoogleCodeExporter commented 9 years ago
This issue can be ignored. There was indeed one duplicated record in 
patch_set_approvals table. After deleting it init was executed properly.

Original comment by jani.kyt...@gmail.com on 14 May 2015 at 7:45

GoogleCodeExporter commented 9 years ago

Original comment by david.pu...@sonymobile.com on 14 May 2015 at 8:26