You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2025/01/30 07:46:01 UTC
(jackrabbit-oak) branch OAK-11439 created (now 685c894c67)
This is an automated email from the ASF dual-hosted git repository.
daim pushed a change to branch OAK-11439
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at 685c894c67 OAK-11439 : set remaining full gc modes
This branch includes the following new commits:
new 685c894c67 OAK-11439 : set remaining full gc modes
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-11439 : set remaining full gc modes
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch OAK-11439
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 685c894c67c48cee03fd5d05cebf87af94aeeda9
Author: Rishabh Kumar <di...@adobe.com>
AuthorDate: Thu Jan 30 13:15:48 2025 +0530
OAK-11439 : set remaining full gc modes
---
.../oak/plugins/document/FullGCMode.java | 105 +++++++++++++++++++++
.../plugins/document/VersionGarbageCollector.java | 68 +------------
.../oak/plugins/document/BranchCommitGCTest.java | 1 -
.../oak/plugins/document/FullGCHelper.java | 1 -
.../oak/plugins/document/VersionGCTest.java | 54 ++++++++++-
.../document/VersionGarbageCollectorIT.java | 1 -
6 files changed, 159 insertions(+), 71 deletions(-)
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FullGCMode.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FullGCMode.java
new file mode 100644
index 0000000000..03ba9cd48b
--- /dev/null
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/FullGCMode.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.document;
+
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * During hardening of FullGC one can choose level type of garbage should be cleaned up.
+ * Ultimately the goal is to clean up all possible garbage. After hardening these modes
+ * might no longer be supported.
+ */
+enum FullGCMode {
+ /**
+ * no full GC is done at all
+ */
+ NONE,
+ /**
+ * GC only empty properties
+ */
+ EMPTYPROPS,
+ /**
+ * GC only orphaned nodes with gaps in ancestor docs
+ */
+ GAP_ORPHANS,
+ /**
+ * GC orphaned nodes with gaps in ancestor docs, plus empty properties
+ */
+ GAP_ORPHANS_EMPTYPROPS,
+ /**
+ * GC any kind of orphaned nodes, plus empty properties
+ */
+ ALL_ORPHANS_EMPTYPROPS,
+ /**
+ * GC any kind of orphaned nodes, empty properties plus keep 1 (== keep
+ * traversed) revision, applied to user properties only
+ */
+ ORPHANS_EMPTYPROPS_KEEP_ONE_USER_PROPS,
+ /**
+ * GC any kind of orphaned nodes, empty properties plus keep 1 (== keep
+ * traversed) revision, applied to all properties
+ */
+ ORPHANS_EMPTYPROPS_KEEP_ONE_ALL_PROPS,
+ /**
+ * GC any kind of orphaned nodes, empty properties plus cleanup unmerged BCs
+ */
+ ORPHANS_EMPTYPROPS_UNMERGED_BC,
+ /**
+ * GC any kind of orphaned nodes, empty properties plus cleanup revisions, also
+ * between checkpoints
+ */
+ ORPHANS_EMPTYPROPS_BETWEEN_CHECKPOINTS_NO_UNMERGED_BC,
+ /**
+ * GC any kind of orphaned nodes, empty properties, cleanup revisions, also
+ * between checkpoints, plus cleanup unmerged BCs
+ */
+ ORPHANS_EMPTYPROPS_BETWEEN_CHECKPOINTS_WITH_UNMERGED_BC;
+
+ private static final Logger log = getLogger(FullGCMode.class);
+
+ public static FullGCMode getMode(final int mode) {
+
+ switch (mode) {
+ case 1:
+ return EMPTYPROPS;
+ case 2:
+ return GAP_ORPHANS;
+ case 3:
+ return GAP_ORPHANS_EMPTYPROPS;
+ case 4:
+ return ALL_ORPHANS_EMPTYPROPS;
+ case 5:
+ return ORPHANS_EMPTYPROPS_KEEP_ONE_USER_PROPS;
+ case 6:
+ return ORPHANS_EMPTYPROPS_KEEP_ONE_ALL_PROPS;
+ case 7:
+ return ORPHANS_EMPTYPROPS_UNMERGED_BC;
+ case 8:
+ return ORPHANS_EMPTYPROPS_BETWEEN_CHECKPOINTS_NO_UNMERGED_BC;
+ case 9:
+ return ORPHANS_EMPTYPROPS_BETWEEN_CHECKPOINTS_WITH_UNMERGED_BC;
+ default:
+ log.warn("Unsupported full GC mode configuration value: {}. Resetting to NONE", mode);
+ return NONE;
+ }
+ }
+
+}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
index 18c544a495..27c75e8337 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollector.java
@@ -93,10 +93,10 @@ import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.REVISIONS;
import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.COMMIT_ROOT_ONLY;
import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.DEFAULT_LEAF;
import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.DEFAULT_NO_BRANCH;
-import static org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.FullGCMode.EMPTYPROPS;
-import static org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.FullGCMode.GAP_ORPHANS;
-import static org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.FullGCMode.GAP_ORPHANS_EMPTYPROPS;
-import static org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.FullGCMode.NONE;
+import static org.apache.jackrabbit.oak.plugins.document.FullGCMode.EMPTYPROPS;
+import static org.apache.jackrabbit.oak.plugins.document.FullGCMode.GAP_ORPHANS;
+import static org.apache.jackrabbit.oak.plugins.document.FullGCMode.GAP_ORPHANS_EMPTYPROPS;
+import static org.apache.jackrabbit.oak.plugins.document.FullGCMode.NONE;
import static org.apache.jackrabbit.oak.plugins.document.util.Utils.getIdFromPath;
import static org.apache.jackrabbit.oak.plugins.document.util.Utils.timestampToString;
import static org.apache.jackrabbit.oak.stats.StatisticsProvider.NOOP;
@@ -157,48 +157,6 @@ public class VersionGarbageCollector {
*/
static final String SETTINGS_COLLECTION_FULL_GC_DRY_RUN_DOCUMENT_ID_PROP = "fullGCDryRunId";
- /**
- * During hardening of FullGC one can choose level type of garbage should be cleaned up.
- * Ultimately the goal is to clean up all possible garbage. After hardening these modes
- * might no longer be supported.
- */
- enum FullGCMode {
- /** no full GC is done at all */
- NONE,
- /** GC only empty properties */
- EMPTYPROPS,
- /** GC only orphaned nodes with gaps in ancestor docs */
- GAP_ORPHANS,
- /** GC orphaned nodes with gaps in ancestor docs, plus empty properties */
- GAP_ORPHANS_EMPTYPROPS,
- /** GC any kind of orphaned nodes, plus empty properties */
- ALL_ORPHANS_EMPTYPROPS,
- /**
- * GC any kind of orphaned nodes, empty properties plus keep 1 (== keep
- * traversed) revision, applied to user properties only
- */
- ORPHANS_EMPTYPROPS_KEEP_ONE_USER_PROPS,
- /**
- * GC any kind of orphaned nodes, empty properties plus keep 1 (== keep
- * traversed) revision, applied to all properties
- */
- ORPHANS_EMPTYPROPS_KEEP_ONE_ALL_PROPS,
- /**
- * GC any kind of orphaned nodes, empty properties plus cleanup unmerged BCs
- */
- ORPHANS_EMPTYPROPS_UNMERGED_BC,
- /**
- * GC any kind of orphaned nodes, empty properties plus cleanup revisions, also
- * between checkpoints
- */
- ORPHANS_EMPTYPROPS_BETWEEN_CHECKPOINTS_NO_UNMERGED_BC,
- /**
- * GC any kind of orphaned nodes, empty properties, cleanup revisions, also
- * between checkpoints, plus cleanup unmerged BCs
- */
- ORPHANS_EMPTYPROPS_BETWEEN_CHECKPOINTS_WITH_UNMERGED_BC
- }
-
private static FullGCMode fullGcMode = GAP_ORPHANS_EMPTYPROPS;
static FullGCMode getFullGcMode() {
@@ -212,23 +170,7 @@ public class VersionGarbageCollector {
* @param fullGcMode configuration value for full GC mode
*/
static void setFullGcMode(int fullGcMode) {
- switch (fullGcMode) {
- case 0:
- VersionGarbageCollector.fullGcMode = NONE;
- break;
- case 1:
- VersionGarbageCollector.fullGcMode = EMPTYPROPS;
- break;
- case 2:
- VersionGarbageCollector.fullGcMode = GAP_ORPHANS;
- break;
- case 3:
- VersionGarbageCollector.fullGcMode = GAP_ORPHANS_EMPTYPROPS;
- break;
- default:
- log.warn("Unsupported full GC mode configuration value: {}. Resetting to NONE", fullGcMode);
- VersionGarbageCollector.fullGcMode = NONE;
- }
+ VersionGarbageCollector.fullGcMode = FullGCMode.getMode(fullGcMode);
}
private final DocumentNodeStore nodeStore;
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchCommitGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchCommitGCTest.java
index fc8921048e..95789f3eed 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchCommitGCTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchCommitGCTest.java
@@ -51,7 +51,6 @@ import java.util.SortedMap;
import java.util.function.Consumer;
import org.apache.jackrabbit.oak.plugins.document.DocumentMK.Builder;
-import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.FullGCMode;
import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollectorIT.GCCounts;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FullGCHelper.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FullGCHelper.java
index f75f180fe4..dc625d4320 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FullGCHelper.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/FullGCHelper.java
@@ -18,7 +18,6 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
-import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.FullGCMode;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java
index edb4bfd692..35fa216570 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGCTest.java
@@ -561,7 +561,7 @@ public class VersionGCTest {
@Test
public void testVersionGCLoadGCModeConfigurationNotApplicable() {
- int fullGcModeNotAllowedValue = 5;
+ int fullGcModeNotAllowedValue = 15;
int fullGcModeGapOrphans = 2;
// set fullGcMode to allowed value that is different than NONE
@@ -573,7 +573,7 @@ public class VersionGCTest {
fullGcModeNotAllowedValue, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
assertEquals("Starting VersionGarbageCollector with not applicable / not allowed value" +
- "will set fullGcMode to default NONE", VersionGarbageCollector.FullGCMode.NONE, VersionGarbageCollector.getFullGcMode());
+ "will set fullGcMode to default NONE", FullGCMode.NONE, VersionGarbageCollector.getFullGcMode());
}
@Test
@@ -583,7 +583,7 @@ public class VersionGCTest {
ns, new VersionGCSupport(store), true, false, false,
fullGcModeNone, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
- assertEquals(VersionGarbageCollector.FullGCMode.NONE, VersionGarbageCollector.getFullGcMode());
+ assertEquals(FullGCMode.NONE, VersionGarbageCollector.getFullGcMode());
}
@Test
@@ -593,7 +593,7 @@ public class VersionGCTest {
ns, new VersionGCSupport(store), true, false, false,
fullGcModeGapOrphans, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
- assertEquals(VersionGarbageCollector.FullGCMode.GAP_ORPHANS, VersionGarbageCollector.getFullGcMode());
+ assertEquals(FullGCMode.GAP_ORPHANS, VersionGarbageCollector.getFullGcMode());
}
@Test
@@ -603,11 +603,55 @@ public class VersionGCTest {
ns, new VersionGCSupport(store), true, false, false,
fullGcModeGapOrphansEmptyProperties, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
- assertEquals(VersionGarbageCollector.FullGCMode.GAP_ORPHANS_EMPTYPROPS, VersionGarbageCollector.getFullGcMode());
+ assertEquals(FullGCMode.GAP_ORPHANS_EMPTYPROPS, VersionGarbageCollector.getFullGcMode());
}
// OAK-10896 END
+ // OAK-11439
+
+ @Test
+ public void testVersionGCLoadGCModeConfigurationAllOrphansEmptyProps() {
+ int fullGcModeAllOrphansEmptyProperties = 4;
+ VersionGarbageCollector gc = new VersionGarbageCollector(
+ ns, new VersionGCSupport(store), true, false, false,
+ fullGcModeAllOrphansEmptyProperties, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
+
+ assertEquals(FullGCMode.ALL_ORPHANS_EMPTYPROPS, VersionGarbageCollector.getFullGcMode());
+ }
+
+ @Test
+ public void testVersionGCLoadGCModeConfigurationAllOrphansEmptyPropsKeepOneUserProps() {
+ int fullGcModeAllOrphansEmptyPropertiesKeepOneUserProps = 5;
+ VersionGarbageCollector gc = new VersionGarbageCollector(
+ ns, new VersionGCSupport(store), true, false, false,
+ fullGcModeAllOrphansEmptyPropertiesKeepOneUserProps, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
+
+ assertEquals(FullGCMode.ORPHANS_EMPTYPROPS_KEEP_ONE_USER_PROPS, VersionGarbageCollector.getFullGcMode());
+ }
+
+ @Test
+ public void testVersionGCLoadGCModeConfigurationAllOrphansEmptyPropsKeepOneAllProps() {
+ int fullGcModeAllOrphansEmptyPropertiesKeepOneAllProps = 6;
+ VersionGarbageCollector gc = new VersionGarbageCollector(
+ ns, new VersionGCSupport(store), true, false, false,
+ fullGcModeAllOrphansEmptyPropertiesKeepOneAllProps, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
+
+ assertEquals(FullGCMode.ORPHANS_EMPTYPROPS_KEEP_ONE_ALL_PROPS, VersionGarbageCollector.getFullGcMode());
+ }
+
+ @Test
+ public void testVersionGCLoadGCModeConfigurationAllOrphansEmptyPropsUnmergedBC() {
+ int fullGcModeAllOrphansEmptyPropertiesUnmergedBC = 7;
+ VersionGarbageCollector gc = new VersionGarbageCollector(
+ ns, new VersionGCSupport(store), true, false, false,
+ fullGcModeAllOrphansEmptyPropertiesUnmergedBC, 0, DEFAULT_FGC_BATCH_SIZE, DEFAULT_FGC_PROGRESS_SIZE);
+
+ assertEquals(FullGCMode.ORPHANS_EMPTYPROPS_UNMERGED_BC, VersionGarbageCollector.getFullGcMode());
+ }
+
+ // OAK-11439 END
+
private Future<VersionGCStats> gc() {
// run gc in a separate thread
return execService.submit(new Callable<VersionGCStats>() {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
index 08aaea9cac..2988d50949 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/VersionGarbageCollectorIT.java
@@ -113,7 +113,6 @@ import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.collections.ListUtils;
import org.apache.jackrabbit.oak.plugins.document.DocumentStoreFixture.RDBFixture;
import org.apache.jackrabbit.oak.plugins.document.FailingDocumentStore.FailedUpdateOpListener;
-import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.FullGCMode;
import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats;
import org.apache.jackrabbit.oak.plugins.document.bundlor.BundlingConfigInitializer;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoTestUtils;