This is an automated email from the ASF dual-hosted git repository.
hanm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 1f12116 ZOOKEEPER-3491: Specify commitLogCount value using a system
property
1f12116 is described below
commit 1f1211653589c98e259d043affc00c90a4c54eb7
Author: Vladimir Ivić <[email protected]>
AuthorDate: Mon Sep 9 15:27:26 2019 -0700
ZOOKEEPER-3491: Specify commitLogCount value using a system property
Currently the commit log count value is set to 500. This can cause busy
servers to snapshot transactions too often.
Override default commitLogCount=500 through the system property
zookeeper.commitLogCount.
Author: Vladimir Ivić <[email protected]>
Author: Vladimir Ivic <[email protected]>
Author: Brian Nixon <[email protected]>
Reviewers: Michael Han <[email protected]>, Enrico Olivelli
<[email protected]>
Closes #1034 from vladimirivic/ZOOKEEPER-3491-commitLogCount-system-property
---
.../src/main/resources/markdown/zookeeperAdmin.md | 7 ++++++
.../org/apache/zookeeper/server/ZKDatabase.java | 25 ++++++++++++++++++++--
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
index 5113eaa..7c37a53 100644
--- a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
+++ b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
@@ -626,6 +626,13 @@ property, when available, is noted below.
reaches a runtime generated random value in the \[snapCount/2+1, snapCount]
range.The default snapCount is 100,000.
+* *commitLogCount* * :
+ (Java system property: **zookeeper.commitLogCount**)
+ Zookeeper maintains an in-memory list of last committed requests for fast
synchronization with
+ followers when the followers are not too behind. This improves sync
performance in case when your
+ snapshots are large (>100,000).
+ The default commitLogCount value is 500.
+
* *snapSizeLimitInKb* :
(Java system property: **zookeeper.snapSizeLimitInKb**)
ZooKeeper records its transactions using snapshots and
diff --git
a/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java
index c04f8b2..5d292a9 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/ZKDatabase.java
@@ -85,7 +85,9 @@ public class ZKDatabase {
public static final double DEFAULT_SNAPSHOT_SIZE_FACTOR = 0.33;
private double snapshotSizeFactor;
- public static final int commitLogCount = 500;
+ public static final String COMMIT_LOG_COUNT = "zookeeper.commitLogCount";
+ public static final int DEFAULT_COMMIT_LOG_COUNT = 500;
+ public int commitLogCount;
protected static int commitLogBuffer = 700;
protected Queue<Proposal> committedLog = new ArrayDeque<>();
protected ReentrantReadWriteLock logLock = new ReentrantReadWriteLock();
@@ -108,7 +110,9 @@ public class ZKDatabase {
this.snapLog = snapLog;
try {
- snapshotSizeFactor =
Double.parseDouble(System.getProperty(SNAPSHOT_SIZE_FACTOR,
Double.toString(DEFAULT_SNAPSHOT_SIZE_FACTOR)));
+ snapshotSizeFactor = Double.parseDouble(
+ System.getProperty(SNAPSHOT_SIZE_FACTOR,
+ Double.toString(DEFAULT_SNAPSHOT_SIZE_FACTOR)));
if (snapshotSizeFactor > 1) {
snapshotSizeFactor = DEFAULT_SNAPSHOT_SIZE_FACTOR;
LOG.warn("The configured {} is invalid, going to use the
default {}",
@@ -120,6 +124,23 @@ public class ZKDatabase {
snapshotSizeFactor = DEFAULT_SNAPSHOT_SIZE_FACTOR;
}
LOG.info("{} = {}", SNAPSHOT_SIZE_FACTOR, snapshotSizeFactor);
+
+ try {
+ commitLogCount = Integer.parseInt(
+ System.getProperty(COMMIT_LOG_COUNT,
+ Integer.toString(DEFAULT_COMMIT_LOG_COUNT)));
+ if (commitLogCount < DEFAULT_COMMIT_LOG_COUNT) {
+ commitLogCount = DEFAULT_COMMIT_LOG_COUNT;
+ LOG.warn("The configured commitLogCount {} is less than the
recommended {}"
+ + ", going to use the recommended one",
+ COMMIT_LOG_COUNT, DEFAULT_COMMIT_LOG_COUNT);
+ }
+ } catch (NumberFormatException e) {
+ LOG.error("Error parsing {} - use default value {}",
+ COMMIT_LOG_COUNT, DEFAULT_COMMIT_LOG_COUNT);
+ commitLogCount = DEFAULT_COMMIT_LOG_COUNT;
+ }
+ LOG.info("{}={}", COMMIT_LOG_COUNT, commitLogCount);
}
/**