Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validator for leader lease to be larger than heartbeat interval #25747

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/yb/consensus/raft_consensus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "yb/util/debug/trace_event.h"
#include "yb/util/enums.h"
#include "yb/util/flags.h"
#include "yb/util/flag_validators.h"
#include "yb/util/format.h"
#include "yb/util/logging.h"
#include "yb/util/memory/memory.h"
Expand Down Expand Up @@ -196,6 +197,17 @@ DEFINE_UNKNOWN_int32(leader_lease_duration_ms, yb::consensus::kDefaultLeaderLeas
"leader (i.e. serve up-to-date read requests or acknowledge write requests) until a "
"lease of this duration has definitely expired on the old leader's side.");


DEFINE_validator(leader_lease_duration_ms,
FLAG_DELAYED_COND_VALIDATOR(
FLAGS_raft_heartbeat_interval_ms <= _value,
"Must be greater than raft_heartbeat_interval_ms"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Must be greater than raft_heartbeat_interval_ms"));
yb::Format("Must be greater than or equal to raft_heartbeat_interval_ms: $0", FLAGS_raft_heartbeat_interval_ms)));


DEFINE_validator(raft_heartbeat_interval_ms,
FLAG_DELAYED_COND_VALIDATOR(
_value <= FLAGS_leader_lease_duration_ms,
"Must be less than leader_lease_duration_ms"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Must be less than leader_lease_duration_ms"));
yb::Format("Must be less than or equal to leader_lease_duration_ms: $0", FLAGS_leader_lease_duration_ms)));


DEFINE_UNKNOWN_int32(ht_lease_duration_ms, 2000,
"Hybrid time leader lease duration. A leader keeps establishing a new lease or "
"extending the existing one with every UpdateConsensus. A new server is not allowed "
Expand Down