eclipse-jgit / jgit

JGit, the Java implementation of git
https://www.eclipse.org/jgit/
Other
92 stars 31 forks source link

Encountering LockFailedException: Cannot lock #57

Open aravinds502 opened 1 month ago

aravinds502 commented 1 month ago

Version

6.8.0

Operating System

Linux/Unix

Bug description

While running the load tests with multiple users create and and updating the GIT repo's, we encounter the following error

Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:244) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at com.rapidminer.git.jgit.AbstractJGitRepository.add(AbstractJGitRepository.java:267) ~[adapter-2.0.2-20240430.jar!/:2.0.2-20240430]
    ... 141 common frames omitted
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock /rapidminer-workspace-service/c8007e1a-685a-404f-ac48-9b4837748ae4/465c4b19-53e2-46ae-ab11-6588cd86e173/.git/index. Ensure that no other process has an open file handle on the lock file /rapidminer-workspace-service/c8007e1a-685a-404f-ac48-9b4837748ae4/465c4b19-53e2-46ae-ab11-6588cd86e173/.git/index.lock, then you may delete the lock file and retry.
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:222) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:293) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:259) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1294) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:129) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    ... 142 common frames omitted

Though we ensure the locking while performing the WRITE operation to repository, we end up with above errors. Is there a way(API) to check whether the repository is already locked by another process, and to wait till it completes.

Please let me know your suggestions.

Thanks

Actual behavior

Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:244) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at com.rapidminer.git.jgit.AbstractJGitRepository.add(AbstractJGitRepository.java:267) ~[adapter-2.0.2-20240430.jar!/:2.0.2-20240430]
    ... 141 common frames omitted
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock /rapidminer-workspace-service/c8007e1a-685a-404f-ac48-9b4837748ae4/465c4b19-53e2-46ae-ab11-6588cd86e173/.git/index. Ensure that no other process has an open file handle on the lock file /rapidminer-workspace-service/c8007e1a-685a-404f-ac48-9b4837748ae4/465c4b19-53e2-46ae-ab11-6588cd86e173/.git/index.lock, then you may delete the lock file and retry.
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:222) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:293) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:259) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1294) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:129) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    ... 142 common frames omitted

Expected behavior

No errors and READ/WRITES should be successful

Relevant log output

Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:244) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at com.rapidminer.git.jgit.AbstractJGitRepository.add(AbstractJGitRepository.java:267) ~[adapter-2.0.2-20240430.jar!/:2.0.2-20240430]
    ... 141 common frames omitted
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock /rapidminer-workspace-service/c8007e1a-685a-404f-ac48-9b4837748ae4/465c4b19-53e2-46ae-ab11-6588cd86e173/.git/index. Ensure that no other process has an open file handle on the lock file /rapidminer-workspace-service/c8007e1a-685a-404f-ac48-9b4837748ae4/465c4b19-53e2-46ae-ab11-6588cd86e173/.git/index.lock, then you may delete the lock file and retry.
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:222) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:293) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:259) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1294) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:129) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar!/:6.8.0.202311291450-r]
    ... 142 common frames omitted

Other information

No response