You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by eo...@apache.org on 2022/07/29 12:11:27 UTC
[bookkeeper] branch master updated: [conf] minorCompactionInterval should be greater than gcWaitTime (#2116)
This is an automated email from the ASF dual-hosted git repository.
eolivelli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 6520a45724 [conf] minorCompactionInterval should be greater than gcWaitTime (#2116)
6520a45724 is described below
commit 6520a45724abcf8f4fe4566bc58b67f8aea659a0
Author: Penghui Li <pe...@apache.org>
AuthorDate: Fri Jul 29 20:11:21 2022 +0800
[conf] minorCompactionInterval should be greater than gcWaitTime (#2116)
---
.../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 e66cb41db1..2c4fc08edc 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 31177b011e..e34d10570a 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")
@@ -3131,6 +3132,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 9890674ca4..b02634b03f 100755
--- a/conf/bk_server.conf
+++ b/conf/bk_server.conf
@@ -542,6 +542,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.
@@ -567,6 +568,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.