CandyShop / gerrit

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

Submodule conflict blocks subsequent commits from being merged when "automatically resolve conflicts" option enabled #1552

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Affected Version: 2.4.2, 2.6, (most likely all)

What steps will reproduce the problem?
1. Enable "automatically resolve conflicts" in the project ("Merge if 
necessary" selected)
2. Add a submodule to the repository (not Gerrit submodule linking)
3. Push for review two commits that have the same parent and that update the 
submodule pointer in conflict with each other.  
4. Submit these commits. 

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

I expect to see the commits merged, but instead the commit that was submitted 
last gets stuck in "Submitted, merge pending" and it also blocks all later 
commits to the project from being merged, they all get stuck in "Submitted, 
merge pending". The later commits can be unstuck by abandoning the commit that 
has the submodule conflict and was the first one to get stuck. 

Stack trace from error_log is at the end. 

The problem seems to be that JGit expects to find an object called 
e0daeee9f0... in the repository, but that SHA1 is a reference to a commit in 
the submodule, so JGit throws a MissingObjectException. 

ls-tree of the repository shows that e0daeee9f0 points to a submodule:
$ git ls-tree HEAD
100644 blob f088d03c27da4d623b75423b3852a76bce701aed    .gitmodules
160000 commit e0daeee9f05b3e4e99b1c1e5c21b4d6b6c46886a  a
100644 blob 3ed19a2b57fc179846f0d95191757a461f9f27e3    file

I can work around this if I catch the MissingObjectException in the 
server.git.MergeOp.mergeOneCommit method and treat it as a path conflict. This 
will mask any MissingObjectException when there actually are objects missing, 
though. I'll try to take a look at JGit next and see if something can be done 
there to fix this. 

ERROR com.google.gerrit.server.git.ChangeMergeQueue : Merge attempt for 
super,refs/heads/master failed
com.google.gerrit.server.git.MergeException: Cannot merge 
c6547c4b2c8510fc474f042070fd997bc3f49cd9
    at com.google.gerrit.server.git.MergeOp.mergeOneCommit(MergeOp.java:548)
    at com.google.gerrit.server.git.MergeOp.mergeTopics(MergeOp.java:526)
    at com.google.gerrit.server.git.MergeOp.preMerge(MergeOp.java:317)
    at com.google.gerrit.server.git.MergeOp.merge(MergeOp.java:281)
    at com.google.gerrit.server.git.ChangeMergeQueue$2.call(ChangeMergeQueue.java:209)
    at com.google.gerrit.server.git.ChangeMergeQueue$2.call(ChangeMergeQueue.java:206)
    at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:196)
    at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:174)
    at com.google.gerrit.server.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:73)
    at com.google.gerrit.server.git.ChangeMergeQueue.mergeImpl(ChangeMergeQueue.java:206)
    at com.google.gerrit.server.git.ChangeMergeQueue.access$200(ChangeMergeQueue.java:51)
    at com.google.gerrit.server.git.ChangeMergeQueue$MergeEntry.run(ChangeMergeQueue.java:248)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:165)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:266)
    at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:337)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing blob 
e0daeee9f05b3e4e99b1c1e5c21b4d6b6c46886a
    at org.eclipse.jgit.storage.file.WindowCursor.open(WindowCursor.java:126)
    at org.eclipse.jgit.lib.ObjectDatabase.open(ObjectDatabase.java:176)
    at org.eclipse.jgit.lib.Repository.open(Repository.java:273)
    at org.eclipse.jgit.merge.ResolveMerger.getRawText(ResolveMerger.java:714)
    at org.eclipse.jgit.merge.ResolveMerger.contentMerge(ResolveMerger.java:540)
    at org.eclipse.jgit.merge.ResolveMerger.processEntry(ResolveMerger.java:488)
    at org.eclipse.jgit.merge.ResolveMerger.mergeImpl(ResolveMerger.java:192)
    at org.eclipse.jgit.merge.Merger.merge(Merger.java:175)
    at org.eclipse.jgit.merge.ThreeWayMerger.merge(ThreeWayMerger.java:108)
    at com.google.gerrit.server.git.MergeOp.mergeOneCommit(MergeOp.java:534)
    ... 20 more

Original issue reported on code.google.com by tommi.siivola@eficode.com on 7 Sep 2012 at 10:58

GoogleCodeExporter commented 9 years ago
This should be fixed in JGit with commit 
0e56f347528fb333a344aaec126ea391ff18e43b. 
Bug report in JGit: https://bugs.eclipse.org/bugs/show_bug.cgi?id=389238

Issue in Gerrit will be resolved when the JGit version is updated to include 
the above-mentioned commit. 

Original comment by tommi.siivola@eficode.com on 17 Sep 2012 at 8:42

GoogleCodeExporter commented 9 years ago
Same problem just occurred for us. Deactivating the "Automatically resolve 
conflicts" option for that project temporarily helped.

Original comment by stef...@steffen-gebert.de on 22 Sep 2012 at 9:37