63

On push of a new branch to a gerrit server we encounter the following error:

de@roma:~/git-hate/www$ git push origin landingpage
Counting objects: 149, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (73/73), done.
Writing objects: 100% (111/111), 2.77 MiB, done.
Total 111 (delta 68), reused 80 (delta 38)
remote: Resolving deltas: 100% (68/68)
error: unpack failed: error Missing tree 30c4809ade0b4b0c81cb7f882450774862b82361
fatal: Unpack error, check server log
To ssh://user@git-server/repository
 ! [remote rejected] landingpage -> landingpage (n/a (unpacker error))
error: failed to push some refs to 'ssh://user@git-server/repository'

We tried to copy the mentioned tree object to the remote git manually without success.

On gerrit side we get a stacktrace:

[2013-05-16 13:43:42,753] ERROR com.google.gerrit.sshd.BaseCommand : Internal server error (user de account 1000000) during git-receive-pack '/repository'
com.google.gerrit.sshd.BaseCommand$Failure: fatal: Unpack error, check server log
        at com.google.gerrit.sshd.commands.Receive.runImpl(Receive.java:157)
        at com.google.gerrit.sshd.AbstractGitCommand.service(AbstractGitCommand.java:106)
        at com.google.gerrit.sshd.AbstractGitCommand.access$000(AbstractGitCommand.java:34)
        at com.google.gerrit.sshd.AbstractGitCommand$1.run(AbstractGitCommand.java:72)
        at com.google.gerrit.sshd.BaseCommand$TaskThunk.run(BaseCommand.java:430)
        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:636)
Caused by: java.io.IOException: Unpack error on project "repository":
  AdvertiseRefsHook: org.eclipse.jgit.transport.AdvertiseRefsHookChain@7047125class org.eclipse.jgit.transport.AdvertiseRefsHookChain

        at com.google.gerrit.sshd.commands.Receive.runImpl(Receive.java:156)
        ... 13 more
Caused by: org.eclipse.jgit.errors.UnpackException: Exception while parsing pack stream
        at org.eclipse.jgit.transport.ReceivePack.service(ReceivePack.java:202)
        at org.eclipse.jgit.transport.ReceivePack.receive(ReceivePack.java:142)
        at com.google.gerrit.sshd.commands.Receive.runImpl(Receive.java:98)
        ... 13 more
Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing tree 30c4809ade0b4b0c81cb7f882450774862b82361
        at org.eclipse.jgit.transport.BaseReceivePack.checkConnectivity(BaseReceivePack.java:996)
        at org.eclipse.jgit.transport.BaseReceivePack.receivePackAndCheckConnectivity(BaseReceivePack.java:756)
        at org.eclipse.jgit.transport.ReceivePack.service(ReceivePack.java:167)
        ... 15 more

Folks: any ideas what to do?

edlerd
  • 2,145
  • 1
  • 16
  • 24

11 Answers11

110

Pushing with --no-thin argument works as a workaround for me:

git push --no-thin omnigerrit HEAD:refs/for/android-4.4
Tassadar
  • 1,861
  • 1
  • 15
  • 12
  • 13
    Well, a new optimization which causes git to send as little data as possible over the network caused this bug to manifest, so my guess is --no-thin just turns these optimizations off. From git push --help: "A thin transfer significantly reduces the amount of sent data when the sender and receiver share many of the same objects in common." (--thin is the default). – Tassadar Dec 01 '14 at 22:19
  • 1
    How can I do a "+2"? this worked for me, and then I noticed I already did "+1" here before... – shapiro yaacov Oct 27 '15 at 08:35
  • 5
    The reason this works is because empty changes (ie: only a changelog chage) do not transfer any data, and some servers are expenting some data to come. So they respond with a "unpack error". – DarkZeros Mar 22 '16 at 11:15
  • 1
    @shapiroyaacov You can click 'Reply' button on Gerrit and use +2. (The answer is a year late) :D – ThePatelGuy Oct 12 '16 at 18:46
14

Are you using git > 1.8.4.2 ?

I found incompatibility between git 1.8.4.3+ and gerrit 2.6, because of https://github.com/git/git/commit/fbd4a7036dfa71ec89e7c441cef1ac9aaa59a315

With this enhancement, if git finds out that the tree sha1 already exists in the server, it wont send it again, but gerrit wants to search the tree sha1 associated with the commit sha1 in the uploaded pack.

It looks like I cannot reproduce it with gerrit 2.8-rc3, not with latest version of scm-manager. I would say this has been resolved in jgit, but cannot find which version yet.

tardyp
  • 1,142
  • 11
  • 9
  • 1
    This is the right answer: downgrade git to resolve gerrit server issue. – akhan Dec 03 '13 at 01:34
  • 4
    And the according Gerrit issues reports are [here](https://code.google.com/p/gerrit/issues/detail?id=1582) and [here](https://code.google.com/p/gerrit/issues/detail?id=2296). – sschuberth Jan 29 '14 at 08:58
  • 3
    This happened to me when trying to push a new patch set to an existing review where the only change was in the commit message. Making a small change in one of the files and pushing that was successful as a work-around for me – onlynone Mar 05 '14 at 21:21
11

my case

I also encounter this problem too, and this take a long time to fix this problem.

First, I notice one error info in gerrit log:

Internal server error (user newptone account 1) during git-receive-pack                           '/neutron.git' 
com.google.gerrit.sshd.BaseCommand$Failure: fatal: Unpack error,   check server log
......
... Missing unknown 613fd2557fba30aff2dbd51c3807cc57561bab08

What is 613fd2557fba30aff2dbd51c3807cc57561bab08 object?

Then I use git review -l to search all opened patchset for this project neutron:

1974  master  Add two interfaces for manipulate forwarding individually

Then I find this patchset in gerrit dashboard by searching, I click the link and it seems error:

613fd2557fba30aff2dbd51c3807cc57561bab08 cannot  found

Aha, that's the reason!

But why this object missing?

The reason is my colleague tell me neutron project will use a new repo to replace the old, I delete the the old repo but didn't close all open patchset in gerrit. The open patchset will disappear in gerrit dashboard, but it still exist in gerrit database.

how to fix it

Login in your reviewdb sql and find this record:

First, make sure this is the one we want to modify:

select * from changes where change_id=1974\G;

Then update this record:

update changes set open='N',status='A' where change_id=1974;
gturri
  • 13,807
  • 9
  • 40
  • 57
NewPtone
  • 3,075
  • 1
  • 17
  • 10
  • Fantastic. In my case I just abandoned all open changes with `update changes set open='N',status='A' where open='Y';`. – indiv Mar 03 '15 at 21:15
8

I just encountered this error as well.

For my scenario, I was attempting to push an amended commit where none of the files had changed since the last time the same commit was pushed. I literally had just amended the commit message for the change, and attempted to push again. No files as part of the commit changed.

My push was rejected with the same error message you posted.

It seemed that Gerrit did not like a push with no changes other than the amended commit message.

I literally made a one character change to a file, added the file, amended the commit again, and pushed, and the push succeeded.

I'm using git == 1.8.4.2

Andy Obusek
  • 12,614
  • 4
  • 41
  • 62
  • +1. The unpack error occurs AFAIK because git is "dumb" and works 99% off the file system changes. If no there are no changes, git will not push anything to the remote server (the same reason you can't push an empty directory either). This makes gerrit barf. – Matt S. Nov 05 '14 at 21:10
  • +1000. Same issue, but while doing a git revert... I have added an additional change to the commit, amended the commit and the push was successful! – King Sumo Aug 05 '15 at 19:55
  • Is Gerrit publish the bug fix according to this issue? – hsiaoairplane Sep 29 '16 at 09:21
8

I had this problem today and tried all the suggestions. Finally the solution was very simple:

  1. Switch to another branch (e.g. develop).
  2. Pull from the remote repository
  3. Switch back to your new branch and push.

With any luck it'll work now.

obrienk
  • 481
  • 5
  • 10
  • 1
    This basically worked for me. I skipped one step: Instead of switching to a different branch, I used the command: `git pull --rebase=preserve`. After that, I could push without a problem. – Briank Aug 11 '17 at 20:24
2

I encountered this issue today and I was not using git > 1.8.4.2. I am on Gerrit 2.7.

After around 5 minutes of frustration, I decided to just switch to the local version of the branch I was trying to push to and I did a pull. After that, my pushes started working again but I do not understand why.

onlywei
  • 1,447
  • 2
  • 11
  • 14
2

I just come with this issue just now,and my case is: Some one git init and push a whole new branch (that is to say,this branch is no relation with any revision in origin git in gerrit) to a git project in gerrit. I try many way but fail. In the end I am inspired by the answer of @obuseme ,follow this and fixed:

git remote add gerrit GERRIT_GIT_PROJECT_URL
git fetch gerrit
And then upload again.
2

Pushing with --no-thin argument

This solution worked for me, sorry @Tassadar, I just w

Duc Dinh
  • 21
  • 3
  • sorry @Tassadar, I just want to upvote your answer but I do not have enough reputation to do that – Duc Dinh Aug 17 '22 at 04:29
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/32502901) – treckstar Aug 23 '22 at 00:21
1

In my case, I simply needed to do a rebase with master HEAD before attempting pushing.

John Jiang
  • 827
  • 1
  • 9
  • 19
0

I worked around this issue by re-cloning the repository, and copying my changes over from the old one.

The other solutions did not work for me, except I did not try obrienks.

I tried with git 2.6.1 as well as with JGit 4.6.1, and I use Gerrit 2.13.1.

Max Hohenegger
  • 1,609
  • 15
  • 19
0

When you get the unpack error, you might want to look for this line as well: remote: error: unable to create temporary file: No space left on device

Deleting a couple of old backup files freed up enough space to get it working again.

Frank Forte
  • 2,031
  • 20
  • 19