Skip to content

Commit 432021b

Browse files
authored
OAK-11737: Fix some properties not being properly passed to FullGC revisions command (#2307)
* OAK-11737: Properly set embeddedVerification value on FullGC revisions command. * OAK-11737: Improved RevisionsCommand test cases. Output actual applied settings. Fix include/exclude paths.
1 parent 869a2f9 commit 432021b

File tree

5 files changed

+70
-21
lines changed

5 files changed

+70
-21
lines changed

oak-run-commons/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ public static void garbageReport(DocumentNodeStore dns) {
7272

7373
public static VersionGarbageCollector createVersionGC(final DocumentNodeStore nodeStore, final VersionGCSupport gcSupport,
7474
boolean isFullGCDryRun, final DocumentNodeStoreBuilder<?> builder) {
75-
return new VersionGarbageCollector(nodeStore, gcSupport, isFullGCEnabled(builder), isFullGCDryRun,
75+
VersionGarbageCollector gc = new VersionGarbageCollector(nodeStore, gcSupport, isFullGCEnabled(builder), isFullGCDryRun,
7676
isEmbeddedVerificationEnabled(builder), builder.getFullGCMode(), builder.getFullGCDelayFactor(),
7777
builder.getFullGCBatchSize(), builder.getFullGCProgressSize(), builder.getFullGcMaxAgeMillis(),
7878
builder.getFullGCGeneration());
79+
gc.setFullGCPaths(builder.getFullGCIncludePaths(), builder.getFullGCExcludePaths());
80+
return gc;
7981
}
8082

8183
public static DocumentNodeState readNode(DocumentNodeStore documentNodeStore, Path path, RevisionVector rootRevision) {

oak-run/src/main/java/org/apache/jackrabbit/oak/run/RevisionsCommand.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -411,29 +411,27 @@ private VersionGarbageCollector bootstrapVGC(RevisionsOptions options, Closer cl
411411
version);
412412
System.exit(1);
413413
}
414-
if (options.isEmbeddedVerificationEnabled()) {
415-
builder.setEmbeddedVerificationEnabled(true);
416-
}
414+
builder.setEmbeddedVerificationEnabled(options.isEmbeddedVerificationEnabled());
417415
// set it read-only before the DocumentNodeStore is created
418416
// this prevents the DocumentNodeStore from writing a new
419417
// clusterId to the clusterNodes and nodes collections
420418
builder.setReadOnlyMode();
421419
useMemoryBlobStore(builder);
422420
// create a version GC that operates on a read-only DocumentNodeStore
423421
// and a GC support with a writable DocumentStore
424-
System.out.println("DryRun is enabled : " + options.isDryRun());
425-
System.out.println("EmbeddedVerification is enabled : " + options.isEmbeddedVerificationEnabled());
422+
VersionGarbageCollector gc = createVersionGC(builder.build(), gcSupport, options.isDryRun(), builder);
423+
System.out.println("DryRun is enabled : " + gc.isFullGCDryRun());
424+
System.out.println("EmbeddedVerification is enabled : " + gc.isEmbeddedVerificationEnabled());
426425
System.out.println("ResetFullGC is enabled : " + options.isResetFullGC());
427426
System.out.println("Compaction is enabled : " + options.doCompaction());
428-
System.out.println("IncludePaths are : " + Arrays.toString(options.getIncludePaths()));
429-
System.out.println("ExcludePaths are : " + Arrays.toString(options.getExcludePaths()));
430-
System.out.println("FullGcMode is : " + options.getFullGcMode());
431-
System.out.println("FullGcDelayFactory is : " + options.getFullGcDelayFactor());
432-
System.out.println("FullGcBatchSize is : " + options.getFullGcBatchSize());
433-
System.out.println("FullGcProgressSize is : " + options.getFullGcProgressSize());
427+
System.out.println("IncludePaths are : " + gc.getFullGCIncludePaths());
428+
System.out.println("ExcludePaths are : " + gc.getFullGCExcludePaths());
429+
System.out.println("FullGcMode is : " + VersionGarbageCollector.getFullGcMode());
430+
System.out.println("FullGcDelayFactor is : " + gc.getFullGcDelayFactor());
431+
System.out.println("FullGcBatchSize is : " + gc.getFullGcBatchSize());
432+
System.out.println("FullGcProgressSize is : " + gc.getFullGcProgressSize());
434433
System.out.println("FullGcMaxAgeInSecs is : " + options.getFullGcMaxAge());
435-
System.out.println("FullGcMaxAgeMillis is : " + builder.getFullGcMaxAgeMillis());
436-
VersionGarbageCollector gc = createVersionGC(builder.build(), gcSupport, options.isDryRun(), builder);
434+
System.out.println("FullGcMaxAgeMillis is : " + gc.getFullGcMaxAgeInMillis());
437435

438436
VersionGCOptions gcOptions = gc.getOptions();
439437
gcOptions = gcOptions.withDelayFactor(options.getDelay());
@@ -654,6 +652,7 @@ private void collectDocument(RevisionsOptions options, Closer closer, String pat
654652
DocumentStore documentStore = builder.getDocumentStore();
655653
builder.setReadOnlyMode();
656654
useMemoryBlobStore(builder);
655+
builder.setEmbeddedVerificationEnabled(options.isEmbeddedVerificationEnabled());
657656
DocumentNodeStore documentNodeStore = builder.build();
658657

659658
VersionGarbageCollector gc = bootstrapVGC(options, closer, true);

oak-run/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionsCommandTest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ public void fullGC() {
195195
assertTrue(output.contains("ResetFullGC is enabled : false\n"));
196196
assertTrue(output.contains("Compaction is enabled : false\n"));
197197
assertTrue(output.contains("starting gc collect\n"));
198-
assertTrue(output.contains("IncludePaths are : [/]\n"));
198+
assertTrue(output.contains("IncludePaths are : []\n"));
199199
assertTrue(output.contains("ExcludePaths are : []\n"));
200-
assertTrue(output.contains("FullGcMode is : 0\n"));
201-
assertTrue(output.contains("FullGcDelayFactory is : 2.0\n"));
200+
assertTrue(output.contains("FullGcMode is : NONE\n"));
201+
assertTrue(output.contains("FullGcDelayFactor is : 2.0\n"));
202202
assertTrue(output.contains("FullGcBatchSize is : 1000\n"));
203203
assertTrue(output.contains("FullGcProgressSize is : 10000\n"));
204204
assertTrue(output.contains("FullGcMaxAgeInSecs is : 86400\n"));
@@ -220,7 +220,7 @@ public void fullGCWithDelayFactor() {
220220
ns.dispose();
221221

222222
String output = captureSystemOut(new RevisionsCmd("fullGC", "--fullGcDelayFactor", "2.5", "--entireRepo"));
223-
assertTrue(output.contains("FullGcDelayFactory is : 2.5\n"));
223+
assertTrue(output.contains("FullGcDelayFactor is : 2.5\n"));
224224
assertTrue(output.contains("starting gc collect"));
225225
}
226226

@@ -251,7 +251,19 @@ public void fullGCWithMode() {
251251
assertTrue(output.contains("ResetFullGC is enabled : false"));
252252
assertTrue(output.contains("Compaction is enabled : false"));
253253
assertTrue(output.contains("starting gc collect"));
254-
assertTrue(output.contains("FullGcMode is : 3"));
254+
assertTrue(output.contains("FullGcMode is : GAP_ORPHANS_EMPTYPROPS"));
255+
}
256+
257+
@Test
258+
public void fullGCWithModeAllOrphans() {
259+
ns.dispose();
260+
261+
String output = captureSystemOut(new RevisionsCmd("fullGC", "--entireRepo", "--fullGcMode", "4"));
262+
assertTrue(output.contains("DryRun is enabled : true"));
263+
assertTrue(output.contains("ResetFullGC is enabled : false"));
264+
assertTrue(output.contains("Compaction is enabled : false"));
265+
assertTrue(output.contains("starting gc collect"));
266+
assertTrue(output.contains("FullGcMode is : ALL_ORPHANS_EMPTYPROPS"));
255267
}
256268

257269
@Test

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FullGCMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Ultimately the goal is to clean up all possible garbage. After hardening these modes
2828
* might no longer be supported.
2929
*/
30-
enum FullGCMode {
30+
public enum FullGCMode {
3131
/**
3232
* no full GC is done at all
3333
*/

oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,45 @@ public class VersionGarbageCollector {
172172
private static FullGCMode fullGcMode = GAP_ORPHANS_EMPTYPROPS;
173173
private final long fullGcGen;
174174

175-
static FullGCMode getFullGcMode() {
175+
public static FullGCMode getFullGcMode() {
176176
return fullGcMode;
177177
}
178+
179+
public boolean isFullGCEnabled() {
180+
return fullGCEnabled;
181+
}
182+
183+
public boolean isFullGCDryRun() {
184+
return isFullGCDryRun;
185+
}
186+
187+
public boolean isEmbeddedVerificationEnabled() {
188+
return embeddedVerification;
189+
}
190+
191+
public double getFullGcDelayFactor() {
192+
return fullGCDelayFactor;
193+
}
194+
195+
public long getFullGcMaxAgeInMillis() {
196+
return fullGcMaxAgeInMillis;
197+
}
198+
199+
public int getFullGcBatchSize() {
200+
return fullGCBatchSize;
201+
}
202+
203+
public int getFullGcProgressSize() {
204+
return fullGCProgressSize;
205+
}
206+
207+
public Set<String> getFullGCIncludePaths() {
208+
return fullGCIncludePaths;
209+
}
210+
211+
public Set<String> getFullGCExcludePaths() {
212+
return fullGCExcludePaths;
213+
}
178214

179215
/**
180216
* Set the full GC mode to be used according to the provided configuration value.

0 commit comments

Comments
 (0)