diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-06-05 21:18:21 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-06-05 21:18:47 +0200 |
commit | 60d65bbd222e0b5e4156fd62d0424746a2a883b5 (patch) | |
tree | 661780cdf0c79d03222c7fca6e2611be0d3e0225 /org.eclipse.jgit/src/org/eclipse/jgit/storage | |
parent | 92d1ca80996047b2b232fbee7fcaa7efb82d7634 (diff) | |
parent | 4018709eb99fe6c41145ba03bc2c6229c04b1cd7 (diff) | |
download | jgit-60d65bbd222e0b5e4156fd62d0424746a2a883b5.tar.gz jgit-60d65bbd222e0b5e4156fd62d0424746a2a883b5.zip |
Merge branch 'stable-5.2' into stable-5.3
* stable-5.2:
Prepare 5.1.9-SNAPSHOT builds
JGit v5.1.8.201906050907-r
Test detecting modified packfiles
Enhance fsTick() to use filesystem timer resolution
Add debug trace to measure time needed to open pack index
Extend FileSnapshot for packfiles to also use checksum to detect changes
Wait opening new packfile until it can't be racy anymore
Avoid null PackConfig in GC
Add FileSnapshot test testing recognition of file size changes
Capture reason for result of FileSnapshot#isModified
Skip FileSnapshotTest#testSimulatePackfileReplacement on Windows
Tune max heap size for tests
Fix FileSnapshotTest.testNewFileNoWait() to match its javadoc
ObjectDirectory: fix closing of obsolete packs
Include filekey file attribute when comparing FileSnapshots
Measure file timestamp resolution used in FileSnapshot
Fix FileSnapshot's consideration of file size
Fix API problem filters
Fix API problem filters
Change-Id: Id79a3a19f9a31dff94d10a406c2b6e08a506931a
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/storage')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java index ed3fe2aab9..6722e9bdcd 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java @@ -116,12 +116,30 @@ public class PackConfig { */ public static final int DEFAULT_DELTA_SEARCH_WINDOW_SIZE = 10; + private static final int MB = 1 << 20; + /** * Default big file threshold: {@value} * * @see #setBigFileThreshold(int) */ - public static final int DEFAULT_BIG_FILE_THRESHOLD = 50 * 1024 * 1024; + public static final int DEFAULT_BIG_FILE_THRESHOLD = 50 * MB; + + /** + * Default if we wait before opening a newly written pack to prevent its + * lastModified timestamp could be racy + * + * @since 5.1.8 + */ + public static final boolean DEFAULT_WAIT_PREVENT_RACY_PACK = false; + + /** + * Default if we wait before opening a newly written pack to prevent its + * lastModified timestamp could be racy + * + * @since 5.1.8 + */ + public static final long DEFAULT_MINSIZE_PREVENT_RACY_PACK = 100 * MB; /** * Default delta cache size: {@value} @@ -238,6 +256,10 @@ public class PackConfig { private int bigFileThreshold = DEFAULT_BIG_FILE_THRESHOLD; + private boolean waitPreventRacyPack = DEFAULT_WAIT_PREVENT_RACY_PACK; + + private long minSizePreventRacyPack = DEFAULT_MINSIZE_PREVENT_RACY_PACK; + private int threads; private Executor executor; @@ -314,6 +336,8 @@ public class PackConfig { this.deltaCacheSize = cfg.deltaCacheSize; this.deltaCacheLimit = cfg.deltaCacheLimit; this.bigFileThreshold = cfg.bigFileThreshold; + this.waitPreventRacyPack = cfg.waitPreventRacyPack; + this.minSizePreventRacyPack = cfg.minSizePreventRacyPack; this.threads = cfg.threads; this.executor = cfg.executor; this.indexVersion = cfg.indexVersion; @@ -737,6 +761,76 @@ public class PackConfig { } /** + * Get whether we wait before opening a newly written pack to prevent its + * lastModified timestamp could be racy + * + * @return whether we wait before opening a newly written pack to prevent + * its lastModified timestamp could be racy + * @since 5.1.8 + */ + public boolean isWaitPreventRacyPack() { + return waitPreventRacyPack; + } + + /** + * Get whether we wait before opening a newly written pack to prevent its + * lastModified timestamp could be racy. Returns {@code true} if + * {@code waitToPreventRacyPack = true} and + * {@code packSize > minSizePreventRacyPack}, {@code false} otherwise. + * + * @param packSize + * size of the pack file + * + * @return whether we wait before opening a newly written pack to prevent + * its lastModified timestamp could be racy + * @since 5.1.8 + */ + public boolean doWaitPreventRacyPack(long packSize) { + return isWaitPreventRacyPack() + && packSize > getMinSizePreventRacyPack(); + } + + /** + * Set whether we wait before opening a newly written pack to prevent its + * lastModified timestamp could be racy + * + * @param waitPreventRacyPack + * whether we wait before opening a newly written pack to prevent + * its lastModified timestamp could be racy + * @since 5.1.8 + */ + public void setWaitPreventRacyPack(boolean waitPreventRacyPack) { + this.waitPreventRacyPack = waitPreventRacyPack; + } + + /** + * Get minimum packfile size for which we wait before opening a newly + * written pack to prevent its lastModified timestamp could be racy if + * {@code isWaitToPreventRacyPack} is {@code true}. + * + * @return minimum packfile size, default is 100 MiB + * + * @since 5.1.8 + */ + public long getMinSizePreventRacyPack() { + return minSizePreventRacyPack; + } + + /** + * Set minimum packfile size for which we wait before opening a newly + * written pack to prevent its lastModified timestamp could be racy if + * {@code isWaitToPreventRacyPack} is {@code true}. + * + * @param minSizePreventRacyPack + * minimum packfile size, default is 100 MiB + * + * @since 5.1.8 + */ + public void setMinSizePreventRacyPack(long minSizePreventRacyPack) { + this.minSizePreventRacyPack = minSizePreventRacyPack; + } + + /** * Get the compression level applied to objects in the pack. * * Default setting: {@value java.util.zip.Deflater#DEFAULT_COMPRESSION} @@ -1083,6 +1177,10 @@ public class PackConfig { setBitmapInactiveBranchAgeInDays( rc.getInt("pack", "bitmapinactivebranchageindays", //$NON-NLS-1$ //$NON-NLS-2$ getBitmapInactiveBranchAgeInDays())); + setWaitPreventRacyPack(rc.getBoolean("pack", "waitpreventracypack", //$NON-NLS-1$ //$NON-NLS-2$ + isWaitPreventRacyPack())); + setMinSizePreventRacyPack(rc.getLong("pack", "minsizepreventracypack", //$NON-NLS-1$//$NON-NLS-2$ + getMinSizePreventRacyPack())); } /** {@inheritDoc} */ |