Issue 2706: Deleting multiple branches causes LockFailedException
Status:  Released
Owner: ----
Closed:  Feb 2015
Project Member Reported by dougk....@gmail.com, Jun 10, 2014
Affected Version: 2.8.3, 2.9-rc (2.9-rc1-168-g7833b5d-dirty)

What steps will reproduce the problem?
1. Go to a project with MANY branches and a long development tree (a trivial test case didn't seem to work)
2. Select multiple (~10-12) branches to delete
3. Attempt to delete branches

What is the expected output? What do you see instead?
Branches should delete successfully, but instead, an Internal Server Error is given and a LockFailedException is thrown.  Deleting the branches one at a time works normally.

Please provide any additional information below.

org.eclipse.jgit.errors.LockFailedException: Cannot lock repo.git/packed-refs
        at org.eclipse.jgit.internal.storage.file.RefDirectory.delete(RefDirectory
.java:565)
        at org.eclipse.jgit.internal.storage.file.RefDirectoryUpdate.doDelete(RefD
irectoryUpdate.java:144)
        at org.eclipse.jgit.lib.RefUpdate$2.execute(RefUpdate.java:545)
        at org.eclipse.jgit.lib.RefUpdate.updateImpl(RefUpdate.java:624)
        at org.eclipse.jgit.lib.RefUpdate.delete(RefUpdate.java:542)
        at org.eclipse.jgit.lib.RefUpdate.delete(RefUpdate.java:515)
        at com.google.gerrit.server.project.DeleteBranch.apply(DeleteBranch.java:8
0)
        at com.google.gerrit.server.project.DeleteBranch.apply(DeleteBranch.java:3
8)
        at com.google.gerrit.httpd.restapi.RestApiServlet.service(RestApiServlet.j
ava:303)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
        at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:278)
        at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:268)
        at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180)
        at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85)
        at com.google.gwtexpui.server.CacheControlFilter.doFilter(CacheControlFilter.java:70)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gerrit.httpd.RunAsFilter.doFilter(RunAsFilter.java:113)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gerrit.httpd.RequireSslFilter.doFilter(RequireSslFilter.java:68)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gerrit.httpd.AllRequestFilter$FilterProxy$1.doFilter(AllRequestFilter.java:64)
        at com.google.gerrit.httpd.AllRequestFilter$FilterProxy.doFilter(AllRequestFilter.java:57)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.gerrit.httpd.RequestContextFilter.doFilter(RequestContextFilter.java:75)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
        at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:132)
        at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:129)
        at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:206)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:129)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1539)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:524)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:219)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1110)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:453)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1044)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:459)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:280)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229)
        at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
        at java.lang.Thread.run(Thread.java:724)

Sep 29, 2014
#1 jfas...@gmail.com
I can confirm it happens in 2.9 and 2.9.1 .

It happens if I try to delete 2 or more branches.
Dec 4, 2014
Project Member #2 huga...@gmail.com
 Issue 3042  has been merged into this issue.
Dec 4, 2014
Project Member #3 huga...@gmail.com
More details how to reproduce the issue:
-Run gc on the repo
-Delete 2 or more branch

The problem is that when deleting multiple branches, branch deletion is done is parallel and jgit fails to lock the pack-ref file to remove the branch from it since the first deletion that gets executed already locked the file.
Status: Accepted
Feb 5, 2015
Project Member #7 edwin.ke...@gmail.com
(No comment was entered for this change.)
Status: Submitted
Labels: FixedIn-2.11
Apr 16, 2015
Project Member #8 david.pu...@sonymobile.com
(No comment was entered for this change.)
Status: Released