-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#20124] docdb: leaderless tablet endpoint fixes
Summary: The leaderless tablet endpoint can incorrectly report a tablet which just had leader changed as leaderless tablet because: The new leader's lease does not get updated right after the leader change, instead, it's updated by the next heartbeat from the new leader. And if the new leader originally has a very old leader lease because it was the leader long time ago, we can get this tablet incorrectly reported as leaderless. In this diff, the leaderless tablet detection logic is modified to rely on checking the last time the tablet has a valid leader (peer role is LEADER and has a valid lease), so a per-tablet `TabletInfo::last_time_with_valid_leader_` is introduced to track it. This timestamp will be set to MonoTime::Now when: # initialization of the TabletInfo # when handling ts metrics heartbeat and find the leader of the tablet reported: ``` its status as HAS_LEASE the ht lease is greater than the last reported value (to avoid stale heartbeats) the ht lease is not expired for more than `FLAGS_maximum_tablet_leader_lease_expired_secs` seconds ``` At detection, if the tablet doesn't have a valid leader for more than `FLAGS_maximum_tablet_without_valid_leader_secs` seconds, the tablet is treated as leaderless. With this approach, if the tablet has 3 followers (between leader step-down and re-election), leaderless tablet endpoint can also avoid reporting such tablets as leaderless right after step-down happens, instead, will be detected only when no valid leader lease is reported after `FLAGS_maximum_tablet_without_valid_leader_secs` seconds after leader change. (MasterPathHandlersLeaderlessITest.TestAllFollowers is added to simulate this scenario). Jira: DB-9064 Test Plan: MasterPathHandlersLeaderlessITest.* Reviewers: asrivastava, zdrudi Reviewed By: asrivastava, zdrudi Subscribers: bogdan, ybase, esheng Differential Revision: https://phorge.dev.yugabyte.com/D31078
- Loading branch information
Showing
6 changed files
with
226 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.