feat(split-brain): Introduce lease mechanism for Kvrocks master#3397
Open
redwood9 wants to merge 5 commits intoapache:unstablefrom
Open
feat(split-brain): Introduce lease mechanism for Kvrocks master#3397redwood9 wants to merge 5 commits intoapache:unstablefrom
redwood9 wants to merge 5 commits intoapache:unstablefrom
Conversation
Introduce a master lease mechanism that allows a master node to detect
when it may have lost cluster ownership and optionally block writes to
prevent split-brain data corruption.
- Add `master_lease_mode` config option: disabled / log-only / block-write
- Add lease atomics (`lease_deadline_`, `lease_owner_`) to `Storage`
- Add `UpdateLease()` and `ResetLease()` methods on `Storage`
- Check lease expiry in `Storage::Write()` and `writeToDB()` to cover
both direct writes and `CommitTxn()` paths
- Add `CLUSTERX HEARTBEAT <election_version> <ttl_ms>` command for
controller-driven lease renewal
- Reset master lease automatically on role transition to slave
- Add C++ unit tests (`tests/cppunit/lease_test.cc`)
- Add Go integration tests (`tests/gocase/integration/cluster/lease_test.go`)
Introduce a master lease mechanism that allows a master node to detect
when it may have lost cluster ownership and optionally block writes to
prevent split-brain data corruption.
- Add `master_lease_mode` config option: disabled / log-only / block-write
- Add lease atomics (`lease_deadline_`, `lease_owner_`) to `Storage`
- Add `UpdateLease()` and `ResetLease()` methods on `Storage`
- Check lease expiry in `Storage::Write()` and `writeToDB()` to cover
both direct writes and `CommitTxn()` paths
- Add `CLUSTERX HEARTBEAT <election_version> <ttl_ms>` command for
controller-driven lease renewal
- Reset master lease automatically on role transition to slave
- Add C++ unit tests (`tests/cppunit/lease_test.cc`)
- Add Go integration tests (`tests/gocase/integration/cluster/lease_test.go`)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on the ideas I proposed in issue #3380
#3380
this is the first step of the solution:
introducing a lease mechanism for the Kvrocks master node.
This mechanism ensures that the maximum split-brain window is bounded by the lease TTL. It also comes with flexible configuration options:
To minimize invasion into the existing codebase structure, the implementation follows these strategies:
I will also submit the corresponding HEARTBEAT implementation in the controller at the same time / in parallel.