Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Deadlock when JGit config is in a different drive
Deadlock when JGit config is in a different drive [message #1824524] Thu, 16 April 2020 20:45 Go to next message
Duarte Meneses is currently offline Duarte MenesesFriend
Messages: 1
Registered: April 2020
Junior Member
v5.6.1.202002131546-r

Description
If a git repository and JGit's configuration file are located in different drives, JGit will fail to save the filesystem's attributes when it runs for the first time.
The problem is that there is a deadlock involving the configuration file's lock and the generation of both filesystem's attributes.

Here is how the deadlock happens:
1) JGit tries to create a FileSnapshot for the repository's index
2) Doesn't have the FS attributes saved for that drive, so generates it
3) Proceeds to save it in the configuration file located in the other drive
4) Next it creates a lock file for the configuration file
5) Tries to create a FileSnapshot for the lock file.
6) Repeates steps 2-4 for the attributes of the other drive, and step 4 fails because the lock file already exists.

Impact
Note that it still manages to save the filesystem attributes for 1 of the drives, so next time it runs it will successfully save the attributes for the other drive. A warning is logged but it shouldn't directly impact applications using the library.

Using 2 drives might sound like a corner case but turns out that CI pipelines with Atlassian and GitLab have this kind of setup in their worker nodes. This is impacting users of sonarqube scanners, which uses JGit.


Reproducer
You'll need 2 drives, let's call them /d1 and /d2.

1) Place a git repository in /d1, let's say /d1/repo.
2) Set the environment variable XDG_CONFIG_HOME=/d2
3) Run the following.

  @Test
  public void reproduce() throws IOException {
    try (Repository repo = new RepositoryBuilder()
      .findGitDir(new File("/d1/repo")
      .setMustExist(true).build()) {
    }
  }


Workaround
Setting
FS.setAsyncFileStoreAttributes(true)
breaks the deadlock loop.
Re: Deadlock when JGit config is in a different drive [message #1827969 is a reply to message #1824524] Wed, 27 May 2020 21:09 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
Hi Duarte - thanks for taking time to add this here. As this is a user forum I am not sure if/when a JGit developer will see this. Can you raise this as a bug in the bug tracker: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=jgit&version=5.6

(PS I came across this thanks to you spotting it on https://community.sonarsource.com/t/error-locking-filebasedconfig-root-config-jgit-config-failed-after-5-retries/21899/13 )
Re: Deadlock when JGit config is in a different drive [message #1831383 is a reply to message #1827969] Tue, 18 August 2020 20:39 Go to previous messageGo to next message
Kaspar von Gunten is currently offline Kaspar von GuntenFriend
Messages: 1
Registered: August 2020
Junior Member
I finally opened a bug in bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=566170.

I was experiencing the same problem when building with maven and git-commit-id-plugin in Docker.
Re: Deadlock when JGit config is in a different drive [message #1831846 is a reply to message #1831383] Mon, 31 August 2020 20:22 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
that's fixed in the nightly build
https://download.eclipse.org/egit/updates-nightly
and will be released with 5.9 and Eclipse 2020-09 in 3 weeks.
Previous Topic:Failed to install egit-5.1 from https://archive.eclipse.org/egit/updates-5.1/
Next Topic:New Project Wizard fails on git clone
Goto Forum:
  


Current Time: Fri Apr 26 21:38:22 GMT 2024

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

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

Back to the top