Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 442154

Summary: JGit Repository instances not closed properly at various places
Product: [ECD] Orion Reporter: Michael Ochmann <michael.ochmann>
Component: GitAssignee: Bogdan Gheorghe <gheorghe>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: pwebster
Version: unspecified   
Target Milestone: 7.0   
Hardware: All   
OS: All   
Whiteboard:

Description Michael Ochmann CLA 2014-08-20 07:14:31 EDT
Sometimes the deletion of a project with a git repository fails with an IOException indicating that one of the pack files of the repository is still locked. 

There is no special sequence of UI interactions that triggers this problem reproducibly, but we quite frequently received reports from users about error messages like 

    "Could not delete /mnt/..../projectriver00/.git/objects/pack"

when they tried to delete projects after several fetch/pull/push commands on the corresponding git repositories.

Locked pack files usually happen in JGit if Repository#close() is not called properly on Repository instance.

Looking into the Orion implementation several jobs like CloneJob, FetchJob, PullJob, PushJob, some handlers (GitCloneHandlerV1, GitConfigHandlerV1, GitRemoteHandlerV1) and GitFileDecorator do not close Repository instances at all, or not inside of a try-finally block, so that these instances can be leaked if a command fails with an exception.

I'll provide my patches on Gerrit. With these patches the issue did not occur again on any of our Orion instances. So I'm quite confident that I found all relevant places.
Comment 1 Michael Ochmann CLA 2014-08-20 07:17:09 EDT
https://git.eclipse.org/r/#/c/31959/
"Bug 442154 - Proper closing of Repository instances"

https://git.eclipse.org/r/#/c/31960/
"Bug 442154 - Clone should not hold Repository instances"
Comment 2 John Arthorne CLA 2014-08-28 14:18:08 EDT
Thanks Michael, another good find! Bogdan can you please review.
Comment 3 Bogdan Gheorghe CLA 2014-08-28 16:30:45 EDT
The second set has been reviewed and is ready to go. The first set needs to be rebased as there are some merge conflicts.
Comment 4 Michael Ochmann CLA 2014-08-29 03:14:15 EDT
Rebased and resolved the conflicts.