You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by wd...@apache.org on 2018/10/09 17:07:02 UTC

[4/4] kudu git commit: KUDU-2324 Add gflags to disable individual maintenance ops

KUDU-2324 Add gflags to disable individual maintenance ops

This patch adds one flag per maintenance op that allows the user to
individually disable each of the seven types of maintenance op. This
results in six new flags:

-enable_flush_deltamemstores
-enable_flush_memrowset
-enable_log_gc
-enable_major_delta_compaction
-enable_minor_delta_compaction
-enable_rowset_compaction

These flags do not stop the ops from being registered; instead, they
keep them from being runnable. This allows the flags to be changed at
runtime.

There was already a flag -enable_undo_delta_block_gc controlling whether
undo delta block gc was enabled; however, it prevented the
maintenance op from even being registered. The implementation of the
flag has been changed to match the others. The effect is the same,
except now the flag can be changed at runtime.

Change-Id: If4823c067883897718cc225ef85a0aaf67f1df38
Reviewed-on: http://gerrit.cloudera.org:8080/11609
Tested-by: Kudu Jenkins
Reviewed-by: Attila Bukor <ab...@apache.org>


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

Branch: refs/heads/master
Commit: 9ec8d28dbed301c3d0bd3d9daab183d802f6a58d
Parents: 0c91532
Author: Will Berkeley <wd...@gmail.org>
Authored: Sun Oct 7 11:07:21 2018 -0700
Committer: Will Berkeley <wd...@gmail.com>
Committed: Tue Oct 9 16:44:10 2018 +0000

----------------------------------------------------------------------
 src/kudu/tablet/tablet.cc                | 15 ++-----
 src/kudu/tablet/tablet_mm_ops.cc         | 59 +++++++++++++++++++++++++++
 src/kudu/tablet/tablet_replica_mm_ops.cc | 44 ++++++++++++++++++++
 3 files changed, 106 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/9ec8d28d/src/kudu/tablet/tablet.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index ac18d41..05a024f 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -157,13 +157,6 @@ DEFINE_int32(max_encoded_key_size_bytes, 16 * 1024,
              "result in an error.");
 TAG_FLAG(max_encoded_key_size_bytes, unsafe);
 
-DEFINE_bool(enable_undo_delta_block_gc, true,
-    "Whether to enable undo delta block garbage collection. "
-    "This only affects the undo delta block deletion background task, and "
-    "doesn't control whether compactions delete ancient history. "
-    "To change what is considered ancient history use --tablet_history_max_age_sec");
-TAG_FLAG(enable_undo_delta_block_gc, evolving);
-
 METRIC_DEFINE_entity(tablet);
 METRIC_DEFINE_gauge_size(tablet, memrowset_size, "MemRowSet Memory Usage",
                          kudu::MetricUnit::kBytes,
@@ -1422,11 +1415,9 @@ void Tablet::RegisterMaintenanceOps(MaintenanceManager* maint_mgr) {
   maint_mgr->RegisterOp(major_delta_compact_op.get());
   maintenance_ops.push_back(major_delta_compact_op.release());
 
-  if (FLAGS_enable_undo_delta_block_gc) {
-    gscoped_ptr<MaintenanceOp> undo_delta_block_gc_op(new UndoDeltaBlockGCOp(this));
-    maint_mgr->RegisterOp(undo_delta_block_gc_op.get());
-    maintenance_ops.push_back(undo_delta_block_gc_op.release());
-  }
+  gscoped_ptr<MaintenanceOp> undo_delta_block_gc_op(new UndoDeltaBlockGCOp(this));
+  maint_mgr->RegisterOp(undo_delta_block_gc_op.get());
+  maintenance_ops.push_back(undo_delta_block_gc_op.release());
 
   std::lock_guard<simple_spinlock> l(state_lock_);
   maintenance_ops_.swap(maintenance_ops);

http://git-wip-us.apache.org/repos/asf/kudu/blob/9ec8d28d/src/kudu/tablet/tablet_mm_ops.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_mm_ops.cc b/src/kudu/tablet/tablet_mm_ops.cc
index 3af1042..c71bc6e 100644
--- a/src/kudu/tablet/tablet_mm_ops.cc
+++ b/src/kudu/tablet/tablet_mm_ops.cc
@@ -18,6 +18,7 @@
 #include "kudu/tablet/tablet_mm_ops.h"
 
 #include <mutex>
+#include <ostream>
 #include <utility>
 
 #include <gflags/gflags.h>
@@ -41,6 +42,36 @@ DEFINE_int32(undo_delta_block_gc_init_budget_millis, 1000,
 TAG_FLAG(undo_delta_block_gc_init_budget_millis, evolving);
 TAG_FLAG(undo_delta_block_gc_init_budget_millis, advanced);
 
+DEFINE_bool(enable_major_delta_compaction, true,
+    "Whether to enable major delta compaction. Disabling major delta "
+    "compaction may worsen performance and increase disk space usage for "
+    "workloads involving updates and deletes.");
+TAG_FLAG(enable_major_delta_compaction, runtime);
+TAG_FLAG(enable_major_delta_compaction, unsafe);
+
+DEFINE_bool(enable_minor_delta_compaction, true,
+    "Whether to enable minor delta compaction. Disabling minor delta "
+    "compaction may worsen performance and increase disk space usage for "
+    "workloads involving updates and deletes.");
+TAG_FLAG(enable_minor_delta_compaction, runtime);
+TAG_FLAG(enable_minor_delta_compaction, unsafe);
+
+DEFINE_bool(enable_rowset_compaction, true,
+    "Whether to enable rowset compaction. Disabling rowset compaction "
+    "may worsen performance and increase disk space usage.");
+TAG_FLAG(enable_rowset_compaction, runtime);
+TAG_FLAG(enable_rowset_compaction, unsafe);
+
+DEFINE_bool(enable_undo_delta_block_gc, true,
+    "Whether to enable undo delta block garbage collection. Disabling undo "
+    "delta block garbage collection may worsen performance and increase disk "
+    "space usage for workloads involving updates and deletes. This only "
+    "affects the undo delta block deletion background task, and doesn't "
+    "control whether compactions delete ancient history. To change what is "
+    "considered ancient history use --tablet_history_max_age_sec");
+TAG_FLAG(enable_undo_delta_block_gc, runtime);
+TAG_FLAG(enable_undo_delta_block_gc, unsafe);
+
 using std::string;
 using strings::Substitute;
 
@@ -68,6 +99,13 @@ CompactRowSetsOp::CompactRowSetsOp(Tablet* tablet)
 }
 
 void CompactRowSetsOp::UpdateStats(MaintenanceOpStats* stats) {
+  if (PREDICT_FALSE(!FLAGS_enable_rowset_compaction)) {
+    KLOG_EVERY_N_SECS(WARNING, 300)
+        << "Rowset compaction is disabled (check --enable_rowset_compaction)";
+    stats->set_runnable(false);
+    return;
+  }
+
   std::lock_guard<simple_spinlock> l(lock_);
 
   // Any operation that changes the on-disk row layout invalidates the
@@ -132,6 +170,13 @@ MinorDeltaCompactionOp::MinorDeltaCompactionOp(Tablet* tablet)
 }
 
 void MinorDeltaCompactionOp::UpdateStats(MaintenanceOpStats* stats) {
+  if (PREDICT_FALSE(!FLAGS_enable_minor_delta_compaction)) {
+    KLOG_EVERY_N_SECS(WARNING, 300)
+        << "Minor delta compaction is disabled (check --enable_minor_delta_compaction)";
+    stats->set_runnable(false);
+    return;
+  }
+
   std::lock_guard<simple_spinlock> l(lock_);
 
   // Any operation that changes the number of REDO files invalidates the
@@ -204,6 +249,13 @@ MajorDeltaCompactionOp::MajorDeltaCompactionOp(Tablet* tablet)
 }
 
 void MajorDeltaCompactionOp::UpdateStats(MaintenanceOpStats* stats) {
+  if (PREDICT_FALSE(!FLAGS_enable_major_delta_compaction)) {
+    KLOG_EVERY_N_SECS(WARNING, 300)
+        << "Major delta compaction is disabled (check --enable_major_delta_compaction)";
+    stats->set_runnable(false);
+    return;
+  }
+
   std::lock_guard<simple_spinlock> l(lock_);
 
   // Any operation that changes the size of the on-disk data invalidates the
@@ -275,6 +327,13 @@ UndoDeltaBlockGCOp::UndoDeltaBlockGCOp(Tablet* tablet)
 }
 
 void UndoDeltaBlockGCOp::UpdateStats(MaintenanceOpStats* stats) {
+  if (PREDICT_FALSE(!FLAGS_enable_undo_delta_block_gc)) {
+    KLOG_EVERY_N_SECS(WARNING, 300)
+        << "Undo delta block GC is disabled (check --enable_undo_delta_block_gc)";
+    stats->set_runnable(false);
+    return;
+  }
+
   int64_t max_estimated_retained_bytes = 0;
   WARN_NOT_OK(tablet_->EstimateBytesInPotentiallyAncientUndoDeltas(&max_estimated_retained_bytes),
               "Unable to count bytes in potentially ancient undo deltas");

http://git-wip-us.apache.org/repos/asf/kudu/blob/9ec8d28d/src/kudu/tablet/tablet_replica_mm_ops.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_replica_mm_ops.cc b/src/kudu/tablet/tablet_replica_mm_ops.cc
index b3761a4..b16fae3 100644
--- a/src/kudu/tablet/tablet_replica_mm_ops.cc
+++ b/src/kudu/tablet/tablet_replica_mm_ops.cc
@@ -29,11 +29,34 @@
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/tablet/tablet_metrics.h"
 #include "kudu/util/flag_tags.h"
+#include "kudu/util/logging.h"
 #include "kudu/util/maintenance_manager.h"
 #include "kudu/util/metrics.h"
 #include "kudu/util/scoped_cleanup.h"
 #include "kudu/util/status.h"
 
+DEFINE_bool(enable_flush_memrowset, true,
+    "Whether to enable memrowset flush. Disabling memrowset flush prevents "
+    "the tablet server from flushing writes to diskrowsets, resulting in "
+    "increasing memory and WAL disk space usage.");
+TAG_FLAG(enable_flush_memrowset, runtime);
+TAG_FLAG(enable_flush_memrowset, unsafe);
+
+DEFINE_bool(enable_flush_deltamemstores, true,
+    "Whether to enable deltamemstore flush. Disabling deltamemstore flush "
+    "prevents the tablet server from flushing updates to deltafiles, resulting "
+    "in increasing memory and WAL disk space usage for workloads involving "
+    "updates and deletes.");
+TAG_FLAG(enable_flush_deltamemstores, runtime);
+TAG_FLAG(enable_flush_deltamemstores, unsafe);
+
+DEFINE_bool(enable_log_gc, true,
+    "Whether to enable write-ahead log garbage collection. Disabling WAL "
+    "garbage collection will cause the tablet server to stop reclaiming space "
+    "from the WAL, leading to increasing WAL disk space usage.");
+TAG_FLAG(enable_log_gc, runtime);
+TAG_FLAG(enable_log_gc, unsafe);
+
 DEFINE_int32(flush_threshold_mb, 1024,
              "Size at which MemRowSet flushes are triggered. "
              "A MRS can still flush below this threshold if it if hasn't flushed in a while, "
@@ -100,6 +123,13 @@ void FlushOpPerfImprovementPolicy::SetPerfImprovementForFlush(MaintenanceOpStats
 //
 
 void FlushMRSOp::UpdateStats(MaintenanceOpStats* stats) {
+  if (PREDICT_FALSE(!FLAGS_enable_flush_memrowset)) {
+    KLOG_EVERY_N_SECS(WARNING, 300)
+        << "Memrowset flush is disabled (check --enable_flush_memrowset)";
+    stats->set_runnable(false);
+    return;
+  }
+
   std::lock_guard<simple_spinlock> l(lock_);
 
   map<int64_t, int64_t> replay_size_map;
@@ -166,6 +196,13 @@ scoped_refptr<AtomicGauge<uint32_t> > FlushMRSOp::RunningGauge() const {
 //
 
 void FlushDeltaMemStoresOp::UpdateStats(MaintenanceOpStats* stats) {
+  if (PREDICT_FALSE(!FLAGS_enable_flush_deltamemstores)) {
+    KLOG_EVERY_N_SECS(WARNING, 300)
+        << "Deltamemstore flush is disabled (check --enable_flush_deltamemstores)";
+    stats->set_runnable(false);
+    return;
+  }
+
   std::lock_guard<simple_spinlock> l(lock_);
   int64_t dms_size;
   int64_t retention_size;
@@ -230,6 +267,13 @@ LogGCOp::LogGCOp(TabletReplica* tablet_replica)
       sem_(1) {}
 
 void LogGCOp::UpdateStats(MaintenanceOpStats* stats) {
+  if (PREDICT_FALSE(!FLAGS_enable_log_gc)) {
+    KLOG_EVERY_N_SECS(WARNING, 300)
+        << "Log GC is disabled (check --enable_log_gc)";
+    stats->set_runnable(false);
+    return;
+  }
+
   int64_t retention_size;
 
   if (!tablet_replica_->GetGCableDataSize(&retention_size).ok()) {