Issue 2698: Cannot push changes for review
Status:  Invalid
Owner: ----
Closed:  Jun 2014
Reported by jani.kyt...@gmail.com, Jun 3, 2014
************************************************************
***** 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: 2.8.5

What steps will reproduce the problem?
1. Create commit
2. Try to push it to Gerrit (refs/for/master)
3.

What is the expected output? What do you see instead?

Commit it pushed to Gerrit to review.
Instead there comes database error:  
! [remote rejected] HEAD -> refs/for/master (database error)


Please provide any additional information below.

Gerrit is running under tomcat with Oracle database. Previously mysql was used and this error started to happen when we tried to change from mysql to oracle. Below is gerrit log:

[2014-06-03 14:08:05,096] ERROR com.google.gerrit.server.git.ReceiveCommits : Cannot query database to locate prior changes
com.google.gwtorm.server.OrmException: sequence failure on SELECT change_id.nextval FROM dual
        at com.google.gwtorm.schema.sql.SqlDialect.convertError(SqlDialect.java:152)
        at com.google.gwtorm.schema.sql.SqlDialect.nextLong(SqlDialect.java:178)
        at com.google.gwtorm.jdbc.JdbcSchema.nextLong(JdbcSchema.java:205)
        at com.google.gerrit.reviewdb.server.ReviewDb_Schema_GwtOrm$$23.nextChangeId(Unknown Source)
        at com.google.gerrit.server.git.ReceiveCommits$CreateRequest.<init>(ReceiveCommits.java:1456)
        at com.google.gerrit.server.git.ReceiveCommits.selectNewChanges(ReceiveCommits.java:1383)
        at com.google.gerrit.server.git.ReceiveCommits.processCommands(ReceiveCommits.java:520)
        at com.google.gerrit.server.git.AsyncReceiveCommits$Worker.run(AsyncReceiveCommits.java:90)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:222)
        at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:201)
        at com.google.gerrit.server.util.ThreadLocalRequestScopePropagator$1.call(ThreadLocalRequestScopePropagator.java:55)
        at com.google.gerrit.server.util.RequestScopePropagator$1.call(RequestScopePropagator.java:98)
        at com.google.gerrit.server.util.RequestScopePropagator$2.run(RequestScopePropagator.java:131)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:364)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist

        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.executeForDescribe(T4CStatement.java:876)
        at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1175)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1296)
        at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1498)
        at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
        at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
Jun 3, 2014
Project Member #1 David.Os...@gmail.com
Something went wrong with database set up or with your database migration from MySQL.
Sequences seem to be missing. If you are setting gerrit test site from the scratch with new
Oracle database with:

  java -jar gerrit.war init -d $gerrit_site

And then list the sequences in sqlplus with the following command:

  SQL> select SEQUENCE_NAME from user_sequences;

Can you see the correct created sequences?

If yes, just re-create the sequences in your database.

Status: AwaitingInformation
Jun 4, 2014
#2 jani.kyt...@gmail.com
Actually there were sequences but they were with wrong name. Root cause was that I copied tables from mysql to oracle database before I ran gerrit init. Since there were already table named change_id, gerrit created sequence with different name. That caused all sorts of problems including the one mentioned in this issue.

I have to remember in future to run gerrit init before migrating data from old database. So, this issue can be closed since there wasn't actually anything wrong with Gerrit :)
Jun 4, 2014
Project Member #3 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Invalid