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

[kudu] 03/03: [compaction] support turn on/off FLAGS_enable_maintenance_manager at runtime

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 80009d6af30f3b19bb547efc92d6558a30d49db3
Author: shenxingwuying <sh...@gmail.com>
AuthorDate: Wed Jan 4 15:52:06 2023 +0800

    [compaction] support turn on/off FLAGS_enable_maintenance_manager at runtime
    
    Now the gflags FLAGS_enable_maintenance_manager can be on/off, it should set
    before start. So if we want to change it, we must restart tservers. But
    restarting a tablet server can sometimes be quite time consuming due to
    various factors.
    
    This patch adds ability to change FLAGS_enable_maintenance_manager at runtime,
    that can help in avoiding slow restart operations caused due to external factors.
    
    Change-Id: I7f7029b22a4c8ce58094501e71a6c22271d4f0b2
    Reviewed-on: http://gerrit.cloudera.org:8080/19398
    Tested-by: Kudu Jenkins
    Reviewed-by: Yingchun Lai <la...@apache.org>
---
 src/kudu/util/maintenance_manager.cc | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/kudu/util/maintenance_manager.cc b/src/kudu/util/maintenance_manager.cc
index 9529d1582..ec245adb8 100644
--- a/src/kudu/util/maintenance_manager.cc
+++ b/src/kudu/util/maintenance_manager.cc
@@ -44,6 +44,7 @@
 #include "kudu/util/logging.h"
 #include "kudu/util/maintenance_manager.pb.h"
 #include "kudu/util/metrics.h"
+#include "kudu/util/monotime.h"
 #include "kudu/util/process_memory.h"
 #include "kudu/util/random_util.h"
 #include "kudu/util/scoped_cleanup.h"
@@ -79,6 +80,7 @@ DEFINE_bool(enable_maintenance_manager, true,
             "Enable the maintenance manager, which runs flush, compaction, "
             "and garbage collection operations on tablets.");
 TAG_FLAG(enable_maintenance_manager, unsafe);
+TAG_FLAG(enable_maintenance_manager, runtime);
 
 DEFINE_int64(log_target_replay_size_mb, 1024,
              "The target maximum size of logs to be replayed at startup. If a tablet "
@@ -302,15 +304,23 @@ bool MaintenanceManager::disabled_for_tests() const {
 }
 
 void MaintenanceManager::RunSchedulerThread() {
-  if (!FLAGS_enable_maintenance_manager) {
-    LOG(INFO) << "Maintenance manager is disabled. Stopping thread.";
-    return;
-  }
-
   // Set to true if the scheduler runs and finds that there is no work to do.
   bool prev_iter_found_no_work = false;
 
   while (true) {
+    if (!FLAGS_enable_maintenance_manager) {
+      {
+        std::unique_lock<Mutex> guard(lock_);
+        if (shutdown_) {
+          VLOG_AND_TRACE_WITH_PREFIX("maintenance", 1) << "Shutting down maintenance manager.";
+          return;
+        }
+      }
+      KLOG_EVERY_N_SECS(INFO, 1200)
+          << "Maintenance manager is disabled (check --enable_maintenance_manager).";
+      SleepFor(polling_interval_);
+      continue;
+    }
     MaintenanceOp* op = nullptr;
     string op_note;
     {