Repository navigation
Conversation
…me-epoch master restart The controller keeps the master epoch unchanged when the original master restarts. AutoSwitchHAService.changeToMaster then rewrote the existing epoch entry's start offset to the current max physical offset, while the slave still held the original start offset. The two epoch entries could never match in findConsistentPoint, so the slave kept failing with "Failed to find a consistent point" and never rejoined the sync state set. Keep the original epoch entry when the master epoch already exists locally. A new epoch is still appended at the max physical offset as before. Add a unit test for the same-epoch restart case and an AutoSwitchHA integration test covering slave rejoin and ongoing replication.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #11588 +/- ##
=============================================
+ Coverage 50.04% 50.29% +0.25%
- Complexity 14515 14613 +98
=============================================
Files 1391 1391
Lines 103460 103466 +6
Branches 13558 13556 -2
=============================================
+ Hits 51777 52042 +265
+ Misses 45449 45174 -275
- Partials 6234 6250 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…hHAService Both callers reject masterEpoch < lastEpoch before appending, and the same-epoch case returns early in appendEpochEntry, so the truncation branch for lastEpoch > masterEpoch could never be executed. Remove it.
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.
Fixes #11585
Summary
In controller mode, when the original master restarts and the controller re-elects it with the same
MasterEpoch, the broker rewrote the start offset of the existing epoch entry to its current max physical offset (e.g.1-0->1-5802). The slave still held1-0, andEpochFileCache#findConsistentPointrequires both the epoch number and the start offset to match, so the slave failed withFailed to find a consistent pointforever and never rejoined the SyncStateSet. The master kept accepting writes with an effective replication factor of 1.Root cause
ReplicasInfoManager#electMasterreturns the currentmasterEpochwhen the old master is elected again, andregisterBrokerdoes the same while the master is considered alive.ReplicasManagerstarts withmasterEpoch = 0/masterBrokerId = null, so it takes the fullchangeToMaster(masterEpoch)path, where the recovered epoch entry with the same epoch number gets truncated and re-appended atmaxPhyOffset.findConsistentPointcompares(epoch, startOffset)pairs, so1-5802and1-0never match.Fix
Keep the existing epoch entry when the incoming
masterEpochalready exists locally; a new epoch is still appended atmaxPhyOffsetas before. The epoch start offset is an immutable fact: a restarted master continues the same epoch, so its start offset must not move.changeToMasterandchangeToMasterWhenLastRoleIsMasternow share this logic.Tests
AutoSwitchHAServiceTest(3 cases, runs in CI):changeToMasterWhenLastRoleIsMasterbehaves the same way.AutoSwitchHATest(the class is@Ignored due to HA port flakiness; can be run manually): the master restarts with the same epoch, the existing slave reconnects, is added back to the SyncStateSet and continues replicating.expected:<0> but was:<5802>and the integration test fails withexpected:<0> but was:<1580>; with the fix all related tests pass:mvn -pl store -Dtest='AutoSwitchHAServiceTest,EpochFileCacheTest,AutoSwitchHAStateValidationTest' test(14/14).Notes