summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2016-03-29 16:41:07 +0200
committerChristian Halstrick <christian.halstrick@sap.com>2016-03-31 16:11:02 +0200
commit74743bc547946bf5730b5caa45645804b2226d35 (patch)
tree937a50e3962fa240b6a03475693837dea95a3daa /org.eclipse.jgit.test
parent10135580d0842972c61daa3aa52493ea4c7d4485 (diff)
downloadjgit-74743bc547946bf5730b5caa45645804b2226d35.tar.gz
jgit-74743bc547946bf5730b5caa45645804b2226d35.zip
Add config parameter gc.prunePackExpire for packfile expiration
JGit's Garbage Collector is repacking relevant objects into new packfiles and is afterwards deleting the now obsolete packfiles. But to prevent problems caused by race conditions JGit was not deleting packfiles when they are too young. The same mechanism as for loose objects and the config parameter gc.pruneExpire was used. But JGit was reusing the parameter gc.pruneExpire also for packfiles which may cause a lot of filesystem consumption if gc.pruneExpire was set to the default of 2 weeks. Only two weeks after packfile creation gc was allowed to delete this packfile. This change introduces a new config paramter gc.prunePackExpire with a default of "1.hour". This parameter is used when packfiles are deleted. Only packfiles older than the specified time can be deleted. For loose objects the behaviour is not changed and only the old parameter gc.pruneExpire is relevant. Change-Id: I6209efb05678b15153bd22479dc13486907a44f8
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java13
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java9
2 files changed, 18 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java
index f549fb5cdf..41a1a5d3f5 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java
@@ -213,9 +213,20 @@ public class GcBasicPackingTest extends GcTestCase {
assertEquals(9, stats.numberOfPackedObjects);
assertEquals(2, stats.numberOfPackFiles);
+ // repack again but now without a grace period for loose objects. Since
+ // we don't have loose objects anymore this shouldn't change anything
+ gc.setExpireAgeMillis(0);
+ gc.gc();
+ stats = gc.getStatistics();
+ assertEquals(0, stats.numberOfLooseObjects);
+ // if objects exist in multiple packFiles then they are counted multiple
+ // times
+ assertEquals(9, stats.numberOfPackedObjects);
+ assertEquals(2, stats.numberOfPackFiles);
+
// repack again but now without a grace period for packfiles. We should
// end up with one packfile
- gc.setExpireAgeMillis(0);
+ gc.setPackExpireAgeMillis(0);
gc.gc();
stats = gc.getStatistics();
assertEquals(0, stats.numberOfLooseObjects);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java
index 5fda070867..49e1f6f3da 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/pack/GcCommitSelectionTest.java
@@ -95,7 +95,8 @@ public class GcCommitSelectionTest extends GcTestCase {
}
currentCommits = nextCommitCount;
- gc.setExpireAgeMillis(0); // immediately delete old packs
+ gc.setPackExpireAgeMillis(0); // immediately delete old packs
+ gc.setExpireAgeMillis(0);
gc.gc();
assertEquals(currentCommits * 3, // commit/tree/object
gc.getStatistics().numberOfPackedObjects);
@@ -158,7 +159,8 @@ public class GcCommitSelectionTest extends GcTestCase {
}
currentCommits = nextCommitCount;
- gc.setExpireAgeMillis(0); // immediately delete old packs
+ gc.setPackExpireAgeMillis(0); // immediately delete old packs
+ gc.setExpireAgeMillis(0);
gc.gc();
assertEquals(currentCommits + " commits: ", expectedBitmapCount,
gc.getStatistics().numberOfBitmaps);
@@ -198,7 +200,8 @@ public class GcCommitSelectionTest extends GcTestCase {
final int commitsForShallowBranches = 100;
// Excessive branch history pruning, one old branch.
- gc.setExpireAgeMillis(0); // immediately delete old packs
+ gc.setPackExpireAgeMillis(0); // immediately delete old packs
+ gc.setExpireAgeMillis(0);
gc.gc();
assertEquals(
commitsForSparseBranch + commitsForFullBranch