You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2019/08/26 18:15:20 UTC
[bookkeeper] branch master updated: Journal should respect to
`flushWhenQueueEmpty` setting
This is an automated email from the ASF dual-hosted git repository.
sijie 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 f1df81f Journal should respect to `flushWhenQueueEmpty` setting
f1df81f is described below
commit f1df81f6590e048b93ec21776f931a28f0468a45
Author: Sijie Guo <gu...@gmail.com>
AuthorDate: Mon Aug 26 11:15:15 2019 -0700
Journal should respect to `flushWhenQueueEmpty` setting
Descriptions of the changes in this PR:
*Motivation*
Currently journal doesn't respect to `flushWhenQueueEmpty` setting.
Even `flushWhenQueueEmpty` is set to false, we can still see flushes
triggered due to queue empty.
Reviewers: Enrico Olivelli <eo...@gmail.com>, Jia Zhai <zh...@apache.org>
This closes #2147 from sijie/fix_flush_when_empty
---
.../src/main/java/org/apache/bookkeeper/bookie/Journal.java | 9 ++++++---
stream/distributedlog/core/src/test/resources/bk_server.conf | 1 -
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
index 54da3bb..4af728a 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
@@ -983,8 +983,9 @@ public class Journal extends BookieCriticalThread implements CheckpointSource {
if (maxGroupWaitInNanos > 0 && !groupWhenTimeout && (MathUtils
.elapsedNanos(toFlush.get(0).enqueueTime) > maxGroupWaitInNanos)) {
groupWhenTimeout = true;
- } else if (maxGroupWaitInNanos > 0 && groupWhenTimeout && qe != null
- && MathUtils.elapsedNanos(qe.enqueueTime) < maxGroupWaitInNanos) {
+ } else if (maxGroupWaitInNanos > 0 && groupWhenTimeout
+ && (qe == null // no entry to group
+ || MathUtils.elapsedNanos(qe.enqueueTime) < maxGroupWaitInNanos)) {
// when group timeout, it would be better to look forward, as there might be lots of
// entries already timeout
// due to a previous slow write (writing to filesystem which impacted by force write).
@@ -998,13 +999,15 @@ public class Journal extends BookieCriticalThread implements CheckpointSource {
&& ((bufferedEntriesThreshold > 0 && toFlush.size() > bufferedEntriesThreshold)
|| (bc.position() > lastFlushPosition + bufferedWritesThreshold))) {
// 2. If we have buffered more than the buffWriteThreshold or bufferedEntriesThreshold
+ groupWhenTimeout = false;
shouldFlush = true;
journalStats.getFlushMaxOutstandingBytesCounter().inc();
- } else if (qe == null) {
+ } else if (qe == null && flushWhenQueueEmpty) {
// We should get here only if we flushWhenQueueEmpty is true else we would wait
// for timeout that would put is past the maxWait threshold
// 3. If the queue is empty i.e. no benefit of grouping. This happens when we have one
// publish at a time - common case in tests.
+ groupWhenTimeout = false;
shouldFlush = true;
journalStats.getFlushEmptyQueueCounter().inc();
}
diff --git a/stream/distributedlog/core/src/test/resources/bk_server.conf b/stream/distributedlog/core/src/test/resources/bk_server.conf
index 0a746d6..0d3cd56 100644
--- a/stream/distributedlog/core/src/test/resources/bk_server.conf
+++ b/stream/distributedlog/core/src/test/resources/bk_server.conf
@@ -119,7 +119,6 @@ readOnlyModeEnabled=true
# Bookie Journal Settings
writeBufferSizeBytes=524288
-journalFlushWhenQueueEmpty=false
journalRemoveFromPageCache=true
journalAdaptiveGroupWrites=true
journalMaxGroupWaitMSec=2