Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Cannot lock due to index.lock not removed after crash
Cannot lock due to index.lock not removed after crash [message #1823307] Tue, 24 March 2020 16:46 Go to next message
Henning Blohm is currently offline Henning BlohmFriend
Messages: 6
Registered: July 2013
Junior Member
Hi,

this happens on Ubuntu 18.04, Java 8, JGit 5.6.1.

Our application frequently needs to fetch updates from a remote repository to a local repository. This is part of a "self-updating" feature. Anyway, this also happens on nodes that perform background work. Sometimes these nodes fail and unfortunately sometimes they fail while fetching updates.

After that, the fetch fails with

Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Cannot lock /repos/baseRepository/git/.git/index. Ensure that no other process has an open file handle on the lock file /repos/baseRepository/git/.git/index.lock, then you may delete the lock file and retry.
	at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:340)
	at com.zfabrik.impl.gitcr.helper.GitTools.checkOutRef(GitTools.java:110)
	... 10 more
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock /repos/baseRepository/git/.git/index. Ensure that no other process has an open file handle on the lock file /repos/baseRepository/git/.git/index.lock, then you may delete the lock file and retry.
	at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:251)
	at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:322)
	at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:288)
	at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1292)
	at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:270)
	... 11 more


and it always takes a while for us to detect that failure. We would really like to avoid this problem in the first place.

I suppose there is a reason JGit does not use java.nio.channels.FileLock. It would be possible for our application however to make sure there is no concurrent access to the repository.

Is there a way to make sure JGit does not lock or use a safe locking implementation?

Thanks,
Henning
Re: Cannot lock due to index.lock not removed after crash [message #1823323 is a reply to message #1823307] Tue, 24 March 2020 22:21 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1176
Registered: July 2009
Senior Member
JGit implements the same locking protocol native git implements in order to ensure interoperability
between different git processes acting on the same repository concurrently. If there's a stale index lock file
remaining after a crash you need to ensure there's no other git process having an open file handle on the
index lock file then the stale lock file can be deleted.
Re: Cannot lock due to index.lock not removed after crash [message #1823615 is a reply to message #1823323] Mon, 30 March 2020 10:21 Go to previous message
Henning Blohm is currently offline Henning BlohmFriend
Messages: 6
Registered: July 2013
Junior Member
Ok, I guess, as we know what processes access the repo, we will have another locking layer on top and remove any left-over Git lock, if found. Thanks, Henning
Previous Topic:EGit now forcing GSSAPI-WITH-MIC?
Next Topic:Git clone produces a non-wildcard fetch refspec since 2019-12
Goto Forum:
  


Current Time: Wed Jun 16 02:12:34 GMT 2021

Powered by FUDForum. Page generated in 0.01744 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top