You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2020/01/14 05:09:42 UTC

[kudu] branch master updated: [server] validate RPC vs Raft maximum message size flags

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c0bf8ca  [server] validate RPC vs Raft maximum message size flags
c0bf8ca is described below

commit c0bf8cab5263b2cd2c3b847d2188c0647098e445
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Fri Jan 10 21:02:04 2020 -0800

    [server] validate RPC vs Raft maximum message size flags
    
    Added a group validator to check for the consistency between settings
    of --rpc_max_message_size and --consensus_max_batch_size_bytes flags.
    The validator helps to avoid a non-operable state of a Kudu cluster
    if the mentioned flags are being tweaked in an inconsistent way.
    
    Change-Id: Ied3c2c7ee4f0df48636f5f7ed3adce1e69c28f9d
    Reviewed-on: http://gerrit.cloudera.org:8080/15013
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
---
 src/kudu/consensus/consensus_queue.cc | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/kudu/consensus/consensus_queue.cc b/src/kudu/consensus/consensus_queue.cc
index c655d5f..a8aaa8f 100644
--- a/src/kudu/consensus/consensus_queue.cc
+++ b/src/kudu/consensus/consensus_queue.cc
@@ -46,6 +46,7 @@
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/util/fault_injection.h"
 #include "kudu/util/flag_tags.h"
+#include "kudu/util/flag_validators.h"
 #include "kudu/util/logging.h"
 #include "kudu/util/metrics.h"
 #include "kudu/util/pb_util.h"
@@ -71,9 +72,10 @@ DEFINE_int32(consensus_inject_latency_ms_in_notifications, 0,
 TAG_FLAG(consensus_inject_latency_ms_in_notifications, hidden);
 TAG_FLAG(consensus_inject_latency_ms_in_notifications, unsafe);
 
-DECLARE_int32(consensus_rpc_timeout_ms);
-DECLARE_bool(safe_time_advancement_without_writes);
 DECLARE_bool(raft_prepare_replacement_before_eviction);
+DECLARE_bool(safe_time_advancement_without_writes);
+DECLARE_int32(consensus_rpc_timeout_ms);
+DECLARE_int64(rpc_max_message_size);
 
 using kudu::log::Log;
 using kudu::pb_util::SecureDebugString;
@@ -84,6 +86,22 @@ using std::unordered_map;
 using std::vector;
 using strings::Substitute;
 
+static bool ValidateMaxMessageSizeFlags() {
+  static const int64_t kSizeDelta = 1024;
+  const int64_t raft_max_size = FLAGS_consensus_max_batch_size_bytes;
+  const int64_t rpc_max_size = FLAGS_rpc_max_message_size;
+  if (raft_max_size + kSizeDelta > rpc_max_size) {
+    LOG(ERROR) << strings::Substitute(
+        "--consensus_max_batch_size_bytes is set too high compared with "
+        "--rpc_max_message_size; either increase --rpc_max_message_size "
+        "at least up to $0 or decrease --consensus_max_batch_size_bytes "
+        "down to $1", raft_max_size + kSizeDelta, rpc_max_size - kSizeDelta);
+    return false;
+  }
+  return true;
+}
+GROUP_FLAG_VALIDATOR(max_message_size_flags, ValidateMaxMessageSizeFlags);
+
 namespace kudu {
 namespace consensus {