Issue 2296: git push 1 object fail with gerrit 2.6
Status:  Duplicate
Merged:  issue 1582
Owner: ----
Closed:  Sep 2014
Reported by tar...@gmail.com, Dec 2, 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:
gerrit 2.6.1
git 1.8.4.3 and later

What steps will reproduce the problem?
touch file
git add file
git commit -a -m "1st commit"
git push  # push succeed
git commit --amend -m "2st commit tree not changed"
git push

Counting objects: 1, done.
Writing objects: 100% (1/1), 297 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
error: unpack failed: error Missing tree 0ee94615f7feedb1987b2ed7aaddc3fddefc5038
fatal: Unpack error, check server log


After using git bisect on cgit project, I find that this problems first appear with
https://github.com/git/git/commit/fbd4a7036dfa71ec89e7c441cef1ac9aaa59a315

when tree was not modified, cgit only send a pack with the commit object, and not the tree sha1 (hence "Writing objects: 100% (1/1)")


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

gerrit should accept the pack

Please provide any additional information below.

I cannot reproduce the issue with gerrit 2.8-rc3.
Maybe it would be a good idea to include the fix in a gerrit 2.6.2


Dec 2, 2013
#1 tar...@gmail.com
Some additional investigation:

I can in fact reproduce the problem on gerrit 2.8-rc3!

after a default  "quick-install", change the access config for all project to block read for anonymous users:

diff --git a/project.config b/project.config
index af9af4a..0e369a1 100644 (file)
--- a/project.config
+++ b/project.config
@@ -12,6 +12,7 @@
 [access "refs/*"]
        read = group Administrators
+       read = block group Anonymous Users
 [access "refs/for/refs/*"]
        push = group Registered Users

(I also needed to add force push rights to admins)

Then:
git commit --amend -m "`fortune`" &&  git push origin -f test:test
[test 950a3f5] You will be audited by the Internal Revenue Service.
 1 file changed, 3 insertions(+)
Counting objects: 1, done.
Writing objects: 100% (1/1), 228 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
error: unpack failed: error Missing tree 28b81814c1c28b3bcb6a9c02c02895baa7df4328
fatal: Unpack error, check server log
To ssh://test@localhost:29418/test
 ! [remote rejected] test -> test (n/a (unpacker error))
error: failed to push some refs to 'ssh://test@localhost:29418/test'


server log is:

[2013-12-02 17:35:48,181] INFO  com.google.gerrit.pgm.Daemon : Gerrit Code Review 2.8-rc3 ready
[2013-12-02 17:38:27,863] ERROR com.google.gerrit.sshd.BaseCommand : Internal server error (user test account 1000000) during git-receive-pack '/test'
com.google.gerrit.sshd.BaseCommand$Failure: fatal: Unpack error, check server log
	at com.google.gerrit.sshd.commands.Receive.runImpl(Receive.java:162)
	at com.google.gerrit.sshd.AbstractGitCommand.service(AbstractGitCommand.java:101)
	at com.google.gerrit.sshd.AbstractGitCommand.access$000(AbstractGitCommand.java:32)
	at com.google.gerrit.sshd.AbstractGitCommand$1.run(AbstractGitCommand.java:70)
	at com.google.gerrit.sshd.BaseCommand$TaskThunk.run(BaseCommand.java:442)
	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:344)
	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: java.io.IOException: Unpack error on project "test":
  AdvertiseRefsHook: org.eclipse.jgit.transport.AdvertiseRefsHookChain@2f46ccacclass org.eclipse.jgit.transport.AdvertiseRefsHookChain

	at com.google.gerrit.sshd.commands.Receive.runImpl(Receive.java:161)
	... 13 more
Caused by: org.eclipse.jgit.errors.UnpackException: Exception while parsing pack stream
	at org.eclipse.jgit.transport.ReceivePack.service(ReceivePack.java:239)
	at org.eclipse.jgit.transport.ReceivePack.receive(ReceivePack.java:160)
	at com.google.gerrit.sshd.commands.Receive.runImpl(Receive.java:101)
	... 13 more
Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing tree 28b81814c1c28b3bcb6a9c02c02895baa7df4328
	at org.eclipse.jgit.transport.BaseReceivePack.checkConnectivity(BaseReceivePack.java:1008)
	at org.eclipse.jgit.transport.BaseReceivePack.receivePackAndCheckConnectivity(BaseReceivePack.java:768)
	at org.eclipse.jgit.transport.ReceivePack.service(ReceivePack.java:191)
	... 15 more
                                                                                  
Dec 2, 2013
#2 tar...@gmail.com
After digging more in the code, I found out that setting this options make the push possible again

[receive]
      checkReferencedObjectsAreReachable = false

I've not verified my assertion, but I assume putting anonymous read rights has the same effect of disabling refid checks.

the jgit code at:
https://github.com/eclipse/jgit/blame/master/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java#L1005

looks suspicious to me, as my rule of thumb would guess the check should be done on baseObjects or providedObjects


Jan 8, 2014
#4 zxi...@gmail.com
I'm seeing this bug in Gerrit 2.8 as well. In my case I was pushing to refs/for/master. The first push succeeds but if you push again a 2nd time only changing the commit message and nothing else it fails with the error.

error: unpack failed: error Missing tree f928a72391851726460e776d3923c9b43203e593
fatal: Unpack error, check server log

Jan 8, 2014
#5 Lars.Vo...@gmail.com
Eclipse considers this as blocking bug, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=418633
Jan 27, 2014
#6 croeder....@gmail.com
I think the bug severity should be increased, as it makes Gerrit unusable with current versions of cgit. Maybe the documentation should also be updated to warn about this issue, e.g. intoducing a 'Known Bugs' section.
Jan 29, 2014
#7 sschuberth
Looks like this is a duplicate of  issue 1582 .
Mar 1, 2014
Project Member #8 zaro0508
I was NOT able to reproduce this problem on my installation of Gerrit.  Here is my setup..

OSX Mavericks
Gerrit 2.8-34-gaf315ef
Git 1.8.5.1
I used ssh protocol.
pushed to origin HEAD:refs/for/master multiple times while only changing the commit message.

Mar 2, 2014
#9 sschuberth
@zaro0508: As mentioned in  issue 1582 , the bug only surfaces if the Git client is able to apply the optimization described in https://github.com/git/git/commit/fbd4a7036dfa71ec89e7c441cef1ac9aaa59a315.
Apr 23, 2014
#10 onlyn...@gmail.com
I commented in  issue 1582 , but thought I'd try here as well. Is there a work around for this from the client's perspective? Maybe some way to tell git to not do this optimization?
May 8, 2014
#11 kyle.florence@gmail.com
+1 just confirmed this problem in OSX Maverics + Gerrit 2.5.6, broken on Git versions 1.8.4.3/1.8.5.2/1.9.2 and confirmed working on 1.8.4.2.
Jun 10, 2014
#12 mpe...@gmail.com
Duplicate of  issue 1582  ? See comment #12 there for a workaround.
Jul 1, 2014
#13 samu.vou...@gmail.com
By my experience, the workaround (receive.checkReferencedObjectsAreReachable) fixes this problem. I think this really should be fixed, as this seems to happen for each non-admin user with recent (past two years or so...?) Git).
Sep 5, 2014
Project Member #14 jrn@google.com
(No comment was entered for this change.)
Status: Duplicate
Mergedinto: 1582