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

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit e554db14d25d9a927ccfec56433f20aeca574bde
Author: Andrew Wong <[email protected]>
AuthorDate: Wed Aug 25 20:51:44 2021 -0700

    [tablet_bootstrap] add a comment explaining WAL recovery dirs
    
    It may not be straightforward upon a quick pass through the
    bootstrapping code why we have a recovery directory for our WALs. I
    found myself reading through method comments to remind myself why we
    have them. This patch adds a high-level comment explaining why and how
    we use them.
    
    Change-Id: I7866c618f346d6e609df435c4adf2ff94108228a
    Reviewed-on: http://gerrit.cloudera.org:8080/17810
    Tested-by: Andrew Wong <[email protected]>
    Reviewed-by: Alexey Serbin <[email protected]>
---
 src/kudu/tablet/tablet_bootstrap.cc | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/kudu/tablet/tablet_bootstrap.cc 
b/src/kudu/tablet/tablet_bootstrap.cc
index 4d52e80..790fd53 100644
--- a/src/kudu/tablet/tablet_bootstrap.cc
+++ b/src/kudu/tablet/tablet_bootstrap.cc
@@ -211,9 +211,20 @@ class FlushedStoresSnapshot {
 // is handled by the 'TabletCopy' classes, which copy blocks and metadata 
locally
 // before invoking this local bootstrap functionality to start the tablet.
 //
-// TODO Because the table that is being rebuilt is never flushed/compacted, 
consensus
-// is only set on the tablet after bootstrap, when we get to 
flushes/compactions though
-// we need to set it before replay or we won't be able to re-rebuild.
+// When rebuilding an existing WAL, we first move the WAL segments into a
+// separate "recovery" directory to serve as the original copy. New WAL entries
+// with new commit messages are added to a new WAL in the original WAL
+// directory. Entire segments may be skipped (e.g. if the mem-stores were
+// flushed prior to shutting down), so the resulting WAL may be shorter than
+// the original. Once the bootstrap is complete, the recovery directory is
+// deleted, leaving only the new WAL. Since recovery directories contain the
+// original WALs, following a crash during bootstrapping, subsequent bootstraps
+// should attempt to replay segments out of the recovery directory.
+//
+// TODO(dralves): Because the table that is being rebuilt is never
+// flushed/compacted, consensus is only set on the tablet after bootstrap, when
+// we get to flushes/compactions though we need to set it before replay or we
+// won't be able to re-rebuild.
 class TabletBootstrap {
  public:
   TabletBootstrap(scoped_refptr<TabletMetadata> tablet_meta,

Reply via email to