Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] JGIT left files open after git.close [Windows 10]

On Thu, Jan 28, 2021 at 3:58 PM Andreas Mueller <am@xxxxxxxxxxxxx> wrote:
Hi,

I’m using JGit to clone a remote repository. I’m doing a git.close() [also tried git.getRepository().close()] after cloning. 

Then I want to delete the parent directory of the .git repository directory but it fails because JGit still holds a lock on a single file:

.git/objects/pack/pack-<someid>.pack

How can I force JGit to release this lock? I was assuming that close means really close and not holding any locks.

This is only a problem on Windows 10 because of their quite restrictive file lock handling. No problem on Unixes.

Class Repository does refcounting, if you debug the problem watch its field useCnt.

This behavior might be caused by RepositoryCache (if you use that) which keeps holding a reference
to a cached repository after the repository's refcount has dropped to 0 for a configurable period defined via
option core.repositoryCacheExpireAfter and core.repositoryCacheCleanupDelay.
The expiration default is 1 hour. This was intorduced to avoid trashing the JGit buffer cache (class WindowCache)
which keeps cached pack data until the repository is removed from the RepositoryCache.
Such trashing was observed in jgit based servers (here Gerrit) after former refcounting issues were all fixed.
This  trashing caused unnecessarily high IO.

Configuration:
  • core.repositoryCacheExpireAfter: cache entries are evicted if the cache entry wasn't accessed longer than this time in milliseconds
  • core.repositoryCacheCleanupDelay: defines the interval in milliseconds for running a background task evicting expired cache entries.
    If set to -1 the delay is set to min(repositoryCacheExpireAfter, 10 minutes).
    If set to 0 the time based eviction is switched off and no background task is started.
    If time based eviction is switched off the JVM can still evict cache entries if heap memory is running low.



Thanks,
Andreas

— 
Andreas Müller
CTO, Edge Broker GmbH
edgebroker.io





_______________________________________________
jgit-dev mailing list
jgit-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jgit-dev

Back to the top