解决Gerrit的git unpack error问题

发布于 2020-05-06  56 次阅读


问题描述:

由于neutron项目要换成全新的内部代码,原先仓库里的代码要全部废弃掉,于是简单地创建了一个空项目使用git push –force将其置空。

发现提交patch的时候,会发现如下报错:

remote: Resolving deltas: 100% (2/2)

error: unpack failed: error Missing unknown 613fd2557fba30aff2dbd51c3807cc57561bab08

fatal: Unpack error, check server log

To ssh://newptone@review.ustack.com:29418/neutron.git

! [remote rejected] HEAD -> refs/publish/datong (n/a (unpacker error))

error: failed to push some refs to ‘ssh://newptone@review.ustack.com:29418/neutron.git’

解决方法:

查看了gerrit的日志:

[2014-01-07 03:57:15,400] ERROR com.google.gerrit.sshd.BaseCommand : 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
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:
1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:
615)
at java.lang.Thread.run(Thread.java:
701)
Caused by: java.io.IOException: Unpack error on project
neutron:
AdvertiseRefsHook: org.eclipse.jgit.transport.AdvertiseRefsHookChain@77348c71class 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 unknown 613fd2557fba30aff2dbd51c3807cc57561bab08
at org.eclipse.jgit.storage.file.WindowCursor.open(WindowCursor.java:
125)
at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:
228)
at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:
812)
at org.eclipse.jgit.transport.BaseReceivePack.checkConnectivity(BaseReceivePack.java:
956)
at org.eclipse.jgit.transport.BaseReceivePack.receivePackAndCheckConnectivity(BaseReceivePack.java:
756)
at org.eclipse.jgit.transport.ReceivePack.service(ReceivePack.java:
167)
15 more

那么就定义到613fd2557fba30aff2dbd51c3807cc57561bab08这串哈希值,为什么会丢失这个object ?

执行命令git review -l,发现gerrit上有一个还没有关闭的patch:

1974 master Add two interfaces for manipulate forwarding individually

我打开Gerrit web界面,点击这个patchset,跳出一段错误说明:613fd2557fba30aff2dbd51c3807cc57561bab08 cannot  found.

原因就是在删除原先的旧有neutron代码时,忘记把gerrit上相关的neutron提交做关闭处理,而输入git review命令时,gerrit会先做一个rebase操作,再做提交,然而neutron仓库发生变化后,存在数据库中的1974号patch_set找不到对应的object了,所以在执行:git push gerrit HEAD:refs/publish/datong 操作时发生了前面的问题。

解决办法就是到reviewdb数据库里,先从patch_sets表中找出change_id是1974的记录,确定无误后,我们从changes表中找出对应的记录:

  mysql> select * from changes where change_id=1974G; *************************** 1. row *************************** change_key: I6596720099473969b19675f8fbb97a2db29b5532
created_on:
2014-01-06 12:20:07         last_updated_on: 2014-01-07 03:02:09 sort_key: 002a4736000007b6
owner_account_id:
25 dest_project_name: neutron
dest_branch_name: refs
/heads/master
open: Y
status: n
nbr_patch_sets:
1 current_patch_set_id: 1 subject: Add two          interfaces for manipulate forwarding individually
topic: portforwarding
-api
last_sha1_merge_tested: NULL
mergeable: N
row_version:
2 change_id: 1974 1 row in set (0.00 sec)

我们要做的是将其关闭,并把状态置为Abandon。(注意备份数据库)

mysql> update changes set open=N,status=A where change_id=1974;
Query OK,
1 row affected (0.05 sec)
Rows matched:
1 Changed: 1 Warnings: 0

问题解决.


一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。