You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2018/03/03 06:23:11 UTC

[1/2] kudu git commit: Optionally advance safe time with non-write operations

Repository: kudu
Updated Branches:
  refs/heads/branch-1.6.x 1042e4164 -> e8c68e6c0


Optionally advance safe time with non-write operations

We currently have a problem with safe time advancement when
there are no write messages in the WAL. Because of KUDU-2233,
NO_OP and CHANGE_CONFIG messages are not guaranteed to have
monotonic timestamps, which forced us to ignore them in the
past. This can cause compactions to execute with a timestamp
that is in the beginning of time, causing corruption or crashes.

This patch enables us to advance safe time for all messages
if a flag a set.

Once KUDU-2233 is solved we can flip the flag or remove it
altogether.

Change-Id: I99de2284ba1626581c6e0770c823fd1ba714c1d7
Reviewed-on: http://gerrit.cloudera.org:8080/9396
Tested-by: David Ribeiro Alves <da...@gmail.com>
Reviewed-by: Todd Lipcon <to...@apache.org>
(cherry picked from commit 611627f2c2e1137f50373954090fa9f7a76badef)
Reviewed-on: http://gerrit.cloudera.org:8080/9481
Reviewed-by: David Ribeiro Alves <da...@gmail.com>
Tested-by: Alexey Serbin <as...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/b9aa69c0
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/b9aa69c0
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/b9aa69c0

Branch: refs/heads/branch-1.6.x
Commit: b9aa69c0d0f4fc6f4778e71bab5290cfbf34dded
Parents: 1042e41
Author: David Alves <dr...@apache.org>
Authored: Mon Jan 8 12:50:00 2018 -0800
Committer: Alexey Serbin <as...@cloudera.com>
Committed: Sat Mar 3 06:20:56 2018 +0000

----------------------------------------------------------------------
 src/kudu/tablet/tablet_bootstrap.cc | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/b9aa69c0/src/kudu/tablet/tablet_bootstrap.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_bootstrap.cc b/src/kudu/tablet/tablet_bootstrap.cc
index 371a6f0..2d17344 100644
--- a/src/kudu/tablet/tablet_bootstrap.cc
+++ b/src/kudu/tablet/tablet_bootstrap.cc
@@ -88,6 +88,10 @@
 #include "kudu/util/pb_util.h"
 #include "kudu/util/stopwatch.h"
 
+DEFINE_bool(advance_safe_time_with_non_write_ops, false,
+            "Whether to advance safe time with committed non-write ops like NO_OP "
+            "or CONFIG_CHANGE. This is not totally safe until KUDU-2233 is fixed.");
+TAG_FLAG(advance_safe_time_with_non_write_ops, experimental);
 
 DECLARE_int32(group_commit_queue_size_bytes);
 
@@ -1079,11 +1083,11 @@ Status TabletBootstrap::HandleEntryPair(LogEntryPB* replicate_entry, LogEntryPB*
 
 #undef RETURN_NOT_OK_REPLAY
 
-  // Non-tablet operations should not advance the safe time, because they are
-  // not started serially and so may have timestamps that are out of order.
-  if (op_type == NO_OP || op_type == CHANGE_CONFIG_OP) {
-    return Status::OK();
-  }
+   // Non-tablet operations should not advance the safe time until KUDU-2233 is fixed.
+   if (!FLAGS_advance_safe_time_with_non_write_ops &&
+       (op_type == NO_OP || op_type == CHANGE_CONFIG_OP)) {
+     return Status::OK();
+   }
 
   // Handle safe time advancement:
   //
@@ -1092,8 +1096,10 @@ Status TabletBootstrap::HandleEntryPair(LogEntryPB* replicate_entry, LogEntryPB*
   // safe timestamp to this operation's timestamp.
   //
   // If the hybrid clock is disabled, all transactions will fall into this category.
+  DCHECK(replicate->has_timestamp());
   Timestamp safe_time;
-  if (replicate->write_request().external_consistency_mode() != COMMIT_WAIT) {
+  if (!replicate->write_request().has_external_consistency_mode() ||
+      replicate->write_request().external_consistency_mode() != COMMIT_WAIT) {
     safe_time = Timestamp(replicate->timestamp());
   // ... else we set the safe timestamp to be the transaction's timestamp minus the maximum clock
   // error. This opens the door for problems if the flags changed across reboots, but this is


[2/2] kudu git commit: Don't perform compactions when clean time has not been advanced

Posted by al...@apache.org.
Don't perform compactions when clean time has not been advanced

Due to KUDU-2233 we might not advance safe time, and thus clean
time, at bootstrap causing possible corruption or crashes.

This patch adds a check to make sure that clean time has been
advanced at all before performing a compaction.

This is temporary fix until we have a more strict check like the
one proposed in https://gerrit.cloudera.org/#/c/8887/.

Change-Id: Ia74abdf7d806efc4239dc9cff4a5da28621d331a
Reviewed-on: http://gerrit.cloudera.org:8080/9436
Reviewed-by: Todd Lipcon <to...@apache.org>
Tested-by: David Ribeiro Alves <da...@gmail.com>
(cherry picked from commit 00815045fc3295c12023fd7ae7ad220645a10c3a)
Reviewed-on: http://gerrit.cloudera.org:8080/9482
Tested-by: Kudu Jenkins
Reviewed-by: David Ribeiro Alves <da...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/e8c68e6c
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/e8c68e6c
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/e8c68e6c

Branch: refs/heads/branch-1.6.x
Commit: e8c68e6c070f5bab2fd5c51cb5d0362ea43b515c
Parents: b9aa69c
Author: David Alves <dr...@apache.org>
Authored: Thu Feb 22 09:38:29 2018 -0800
Committer: Alexey Serbin <as...@cloudera.com>
Committed: Sat Mar 3 06:21:03 2018 +0000

----------------------------------------------------------------------
 src/kudu/tablet/tablet.cc | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/e8c68e6c/src/kudu/tablet/tablet.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index 4f3231f..29596b2 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -1672,6 +1672,13 @@ Status Tablet::Compact(CompactFlags flags) {
 
 void Tablet::UpdateCompactionStats(MaintenanceOpStats* stats) {
 
+  if (mvcc_.GetCleanTimestamp() == Timestamp::kInitialTimestamp) {
+    KLOG_EVERY_N_SECS(WARNING, 30) << LogPrefix() <<  "Can't schedule compaction. Clean time has "
+                                   << "not been advanced past its initial value.";
+    stats->set_runnable(false);
+    return;
+  }
+
   // TODO: use workload statistics here to find out how "hot" the tablet has
   // been in the last 5 minutes, and somehow scale the compaction quality
   // based on that, so we favor hot tablets.