My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 2021: "Unique index or primary key violation" on cherry-pick
4 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by atur...@stumbleupon.com, Jul 18, 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: 2.6.1

What steps will reproduce the problem?
1. Revert a commit on repo with cherry-pick strategy
2. Attempt to submit reverted commit

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

Expected: Cherry pick was successful
Experienced: Rarely, maybe 1/1000 times, we fail the cherry-pick because of a "unique index or primary key violation".  Once the commit is in the "Submitted, Merge pending" state, you can't do anything with it until you restart gerrit.




Please provide any additional information below.
We never experienced this issue in 2.5.x

Exceptions:
[2013-07-18 16:30:58,121] ERROR com.google.gerrit.server.git.ChangeMergeQueue : Merge attempt for stumble,refs/heads/master failed
com.google.gerrit.server.git.MergeException: Cannot merge 742debe9939f822f64ea046eac840462f50ad4ae
at com.google.gerrit.server.git.CherryPick._run(CherryPick.java:124)
at com.google.gerrit.server.git.SubmitStrategy.run(SubmitStrategy.java:99)
at com.google.gerrit.server.git.MergeOp.preMerge(MergeOp.java:382)
at com.google.gerrit.server.git.MergeOp.merge(MergeOp.java:287)
at com.google.gerrit.server.git.ChangeMergeQueue$2.call(ChangeMergeQueue.java:207)
at com.google.gerrit.server.git.ChangeMergeQueue$2.call(ChangeMergeQueue.java:204)
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.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:75)
at com.google.gerrit.server.git.ChangeMergeQueue.mergeImpl(ChangeMergeQueue.java:204)
at com.google.gerrit.server.git.ChangeMergeQueue.access$200(ChangeMergeQueue.java:53)
at com.google.gerrit.server.git.ChangeMergeQueue$MergeEntry.run(ChangeMergeQueue.java:247)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:337)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.google.gwtorm.server.OrmException: insert failure on patch_set_ancestors
at com.google.gwtorm.schema.sql.SqlDialect.convertError(SqlDialect.java:151)
at com.google.gwtorm.schema.sql.DialectH2.convertError(DialectH2.java:45)
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.git.CherryPick.insertAncestors(CherryPick.java:206)
at com.google.gerrit.server.git.CherryPick.writeCherryPickCommit(CherryPick.java:164)
at com.google.gerrit.server.git.CherryPick._run(CherryPick.java:84)
... 20 more
Caused by: org.h2.jdbc.JdbcBatchUpdateException: Unique index or primary key violation: "PRIMARY_KEY_4 ON PUBLIC.PATCH_SET_ANCESTORS(CHANGE_ID, PATCH_SET_ID, POSITION)"; SQL statement:
INSERT INTO patch_set_ancestors(ancestor_revision,change_id,patch_set_id,position)VALUES(?,?,?,?) [23505-168]
at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1121)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
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)
... 23 more
Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PRIMARY_KEY_4 ON PUBLIC.PATCH_SET_ANCESTORS(CHANGE_ID, PATCH_SET_ID, POSITION)"; SQL statement:
INSERT INTO patch_set_ancestors(ancestor_revision,change_id,patch_set_id,position)VALUES(?,?,?,?) [23505-168]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:81)
at org.h2.index.PageBtree.find(PageBtree.java:121)
at org.h2.index.PageBtreeLeaf.addRow(PageBtreeLeaf.java:147)
at org.h2.index.PageBtreeLeaf.addRowTry(PageBtreeLeaf.java:100)
at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:200)
at org.h2.index.PageBtreeNode.addRowTry(PageBtreeNode.java:200)
at org.h2.index.PageBtreeIndex.addRow(PageBtreeIndex.java:105)
at org.h2.index.PageBtreeIndex.add(PageBtreeIndex.java:96)
at org.h2.table.RegularTable.addRow(RegularTable.java:121)
at org.h2.command.dml.Insert.insertRows(Insert.java:124)
at org.h2.command.dml.Insert.update(Insert.java:84)
at org.h2.command.CommandContainer.update(CommandContainer.java:75)
at org.h2.command.Command.executeUpdate(Command.java:230)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:156)
at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1106)
... 29 more
Jul 18, 2013
#1 atur...@stumbleupon.com
Okay, I am able to reproduce this bug on another revert.  You have to use the revert through the gerrit interface.
Once the commit gets stuck in the "Submitted, Merge pending" state, you have to abandon it, otherwise it sits there forever, even after the restart.

-Anoakie
Nov 4, 2013
#2 favore...@gmail.com
I can confirm that we stumble on this almost every day. Is there any update on this issue? It's very very very annoying and there's not much understanding from our side as to what triggers it. 

Every time it happens we're forced to restart gerrit and abandon/restore all hanging changes.

Sign in to add a comment

Powered by Google Project Hosting