From 06cfebd066c9d62c9cb5258343fa566f788c1fec Mon Sep 17 00:00:00 2001 From: Nasser Grainawi Date: Tue, 2 May 2023 16:30:44 -0600 Subject: [PATCH] Fix inProcessPackedRefsLock not shared with copies of the instance The in process lock is intended to manage contention on locking the packed-refs file within a single process without acquiring the file system lock. Not sharing it across RefDirectory instances of the same repository undermines that intent and results in more contention at the file system level. Change-Id: I68f11856aa0b4b1524f43554d7391a322a0a6897 Signed-off-by: Nasser Grainawi --- .../org/eclipse/jgit/internal/storage/file/RefDirectory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index 0416a648e..f0676d9be 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java @@ -155,7 +155,7 @@ public class RefDirectory extends RefDatabase { * {@code RepositoryCache} is used, this lock instance will be used by all * threads. */ - final ReentrantLock inProcessPackedRefsLock = new ReentrantLock(true); + final ReentrantLock inProcessPackedRefsLock; /** * Number of modifications made to this database. @@ -190,6 +190,7 @@ public class RefDirectory extends RefDatabase { packedRefs.set(refDb.packedRefs.get()); trustFolderStat = refDb.trustFolderStat; trustPackedRefsStat = refDb.trustPackedRefsStat; + inProcessPackedRefsLock = refDb.inProcessPackedRefsLock; } RefDirectory(FileRepository db) { @@ -210,6 +211,7 @@ public class RefDirectory extends RefDatabase { .getEnum(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_TRUST_PACKED_REFS_STAT, TrustPackedRefsStat.UNSET); + inProcessPackedRefsLock = new ReentrantLock(true); } Repository getRepository() {