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 2018/11/28 20:24:00 UTC

[bookkeeper] branch branch-4.8 updated: [LEDGER STORAGE] DbLedgerStorage should do periodical flush

This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch branch-4.8
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/branch-4.8 by this push:
     new cf30cf2  [LEDGER STORAGE] DbLedgerStorage should do periodical flush
cf30cf2 is described below

commit cf30cf27de531b8f4b5f12bdb365167c1c5b7b4c
Author: Sijie Guo <gu...@gmail.com>
AuthorDate: Wed Nov 28 12:07:29 2018 -0800

    [LEDGER STORAGE] DbLedgerStorage should do periodical flush
    
    Descriptions of the changes in this PR:
    
    *Motivation*
    
    DbLedgerStorage doesn't drive checkpoint itself. so currently DbLedgerStorage flush only
    happens either when write-cache is full or entry log file rotated. The correctness is still
    maintained. However the behavior is different from original yahoo behavior.
    
    *Changes*
    
    Revert the behavior back to original periodical flush
    
    Reviewers: Matteo Merli <mm...@apache.org>, Jia Zhai <None>
    
    This closes #1843 from sijie/dbledgerstorage_sync
    
    (cherry picked from commit d7fffac47f013a6902f9b61e8f8ffcb3ed29abff)
    Signed-off-by: Sijie Guo <si...@apache.org>
---
 .../java/org/apache/bookkeeper/bookie/Bookie.java     | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
index c565a98..25c2fc3 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
@@ -71,6 +71,7 @@ import org.apache.bookkeeper.bookie.CheckpointSource.Checkpoint;
 import org.apache.bookkeeper.bookie.Journal.JournalScanner;
 import org.apache.bookkeeper.bookie.LedgerDirsManager.LedgerDirsListener;
 import org.apache.bookkeeper.bookie.LedgerDirsManager.NoWritableLedgerDirException;
+import org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage;
 import org.apache.bookkeeper.common.util.Watcher;
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.discover.RegistrationManager;
@@ -707,14 +708,22 @@ public class Bookie extends BookieCriticalThread {
         LOG.info("Using ledger storage: {}", ledgerStorageClass);
         ledgerStorage = LedgerStorageFactory.createLedgerStorage(ledgerStorageClass);
 
+        boolean isDbLedgerStorage = ledgerStorage instanceof DbLedgerStorage;
+
         /*
          * with this change https://github.com/apache/bookkeeper/pull/677,
-         * LedgerStorage drives the checkpoint logic. But with multiple entry
-         * logs, checkpoint logic based on a entry log is not possible, hence it
-         * needs to be timebased recurring thing and it is driven by SyncThread.
-         * SyncThread.start does that and it is started in Bookie.start method.
+         * LedgerStorage drives the checkpoint logic.
+         *
+         * <p>There are two exceptions:
+         *
+         * 1) with multiple entry logs, checkpoint logic based on a entry log is
+         *    not possible, hence it needs to be timebased recurring thing and
+         *    it is driven by SyncThread. SyncThread.start does that and it is
+         *    started in Bookie.start method.
+         *
+         * 2) DbLedgerStorage
          */
-        if (entryLogPerLedgerEnabled) {
+        if (entryLogPerLedgerEnabled || isDbLedgerStorage) {
             syncThread = new SyncThread(conf, getLedgerDirsListener(), ledgerStorage, checkpointSource) {
                 @Override
                 public void startCheckpoint(Checkpoint checkpoint) {