aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/storage
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-06-05 15:43:29 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-06-05 20:58:16 +0200
commit4018709eb99fe6c41145ba03bc2c6229c04b1cd7 (patch)
tree2639bf3c54bff4021bcbe8d8ad351f4e76d53823 /org.eclipse.jgit/src/org/eclipse/jgit/storage
parentf5957e433c6309b936b5d891531189e25cc74e4c (diff)
parent57ccca75e610550536bb6f6b5a61d5d23a0f4fc6 (diff)
downloadjgit-4018709eb99fe6c41145ba03bc2c6229c04b1cd7.tar.gz
jgit-4018709eb99fe6c41145ba03bc2c6229c04b1cd7.zip
Merge branch 'stable-5.1' into stable-5.2
* stable-5.1: 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 Change-Id: I3ac77bfa03f7436de12ab86e1bba29afee5ccd01 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/storage')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConfig.java100
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 256e41d22b..6bd32dd873 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} */