You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by yo...@apache.org on 2022/08/01 13:44:47 UTC
[bookkeeper] 01/17: [conf] minorCompactionInterval should be greater than gcWaitTime (#2116)
This is an automated email from the ASF dual-hosted git repository.
yong pushed a commit to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
commit 12c332519124040eeea08be38b700d906a400361
Author: Penghui Li <pe...@apache.org>
AuthorDate: Fri Jul 29 20:11:21 2022 +0800
[conf] minorCompactionInterval should be greater than gcWaitTime (#2116)
(cherry picked from commit 6520a45724abcf8f4fe4566bc58b67f8aea659a0)
---
.../bookkeeper/bookie/GarbageCollectorThread.java | 4 ++--
.../bookkeeper/conf/ServerConfiguration.java | 7 +++++++
.../bookkeeper/conf/TestServerConfiguration.java | 22 +++++++++++++++++++++-
conf/bk_server.conf | 2 ++
4 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
index 87a947731a..b98cd2a8f0 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/GarbageCollectorThread.java
@@ -224,7 +224,7 @@ public class GarbageCollectorThread extends SafeRunnable {
throw new IOException("Invalid minor compaction threshold "
+ minorCompactionThreshold);
}
- if (minorCompactionInterval <= gcWaitTime) {
+ if (minorCompactionInterval < gcWaitTime) {
throw new IOException("Too short minor compaction interval : "
+ minorCompactionInterval);
}
@@ -245,7 +245,7 @@ public class GarbageCollectorThread extends SafeRunnable {
throw new IOException("Invalid major compaction threshold "
+ majorCompactionThreshold);
}
- if (majorCompactionInterval <= gcWaitTime) {
+ if (majorCompactionInterval < gcWaitTime) {
throw new IOException("Too short major compaction interval : "
+ majorCompactionInterval);
}
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
index 9ce055610d..09a1c76cc5 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
@@ -54,6 +54,7 @@ import org.apache.commons.lang3.StringUtils;
*/
public class ServerConfiguration extends AbstractConfiguration<ServerConfiguration> {
+ private static final int SECOND = 1000;
// Ledger Storage Settings
private static final ConfigKeyGroup GROUP_LEDGER_STORAGE = ConfigKeyGroup.builder("ledgerstorage")
@@ -3090,6 +3091,12 @@ public class ServerConfiguration extends AbstractConfiguration<ServerConfigurati
throw new ConfigurationException("For persisiting explicitLac, journalFormatVersionToWrite should be >= 6"
+ "and FileInfoFormatVersionToWrite should be >= 1");
}
+ if (getMinorCompactionInterval() * SECOND < getGcWaitTime()) {
+ throw new ConfigurationException("minorCompactionInterval should be >= gcWaitTime.");
+ }
+ if (getMajorCompactionInterval() * SECOND < getGcWaitTime()) {
+ throw new ConfigurationException("majorCompactionInterval should be >= gcWaitTime.");
+ }
}
/**
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/conf/TestServerConfiguration.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/conf/TestServerConfiguration.java
index 16901117bb..04ac87818f 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/conf/TestServerConfiguration.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/conf/TestServerConfiguration.java
@@ -155,7 +155,7 @@ public class TestServerConfiguration {
}
@Test
- public void testCompactionSettings() {
+ public void testCompactionSettings() throws ConfigurationException {
ServerConfiguration conf = new ServerConfiguration();
long major, minor;
@@ -199,6 +199,26 @@ public class TestServerConfiguration {
Assert.assertEquals(900, minor);
Assert.assertEquals(21700, major);
+ conf.setMinorCompactionInterval(500);
+ try {
+ conf.validate();
+ fail();
+ } catch (ConfigurationException ignore) {
+ }
+
+ conf.setMinorCompactionInterval(600);
+ conf.validate();
+
+ conf.setMajorCompactionInterval(550);
+ try {
+ conf.validate();
+ fail();
+ } catch (ConfigurationException ignore) {
+ }
+
+ conf.setMajorCompactionInterval(600);
+ conf.validate();
+
// Default Values
double majorThreshold, minorThreshold;
majorThreshold = conf.getMajorCompactionThreshold();
diff --git a/conf/bk_server.conf b/conf/bk_server.conf
index cf76c2a4aa..4aeec71264 100755
--- a/conf/bk_server.conf
+++ b/conf/bk_server.conf
@@ -535,6 +535,7 @@ ledgerDirectories=/tmp/bk-data
# Interval to run minor compaction, in seconds
# If it is set to less than zero, the minor compaction is disabled.
+# Note: should be greater than gcWaitTime.
# minorCompactionInterval=3600
# Maximum milliseconds to run minor Compaction. Defaults to -1 run indefinitely.
@@ -560,6 +561,7 @@ ledgerDirectories=/tmp/bk-data
# Interval to run major compaction, in seconds
# If it is set to less than zero, the major compaction is disabled.
+# Note: should be greater than gcWaitTime.
# majorCompactionInterval=86400
# Maximum milliseconds to run major Compaction. Defaults to -1 run indefinitely.