leizhiyuan opened a new pull request, #11660:
URL: https://github.com/apache/rocketmq/pull/11660

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11656
   - Part of #11659
   
   ### Brief Description
   
   `handleCleanBrokerDataEvent` removed the cleaned brokerIds from the replica 
table and the syncStateSet but left `masterBrokerId` untouched, so cleaning the 
current master left the broker-set with a master that is no longer a replica, 
and an unchanged master epoch.
   
   When the cleaned ids contain the current master, the master is now cleared 
through `SyncStateInfo#updateMasterInfo(null)`, which also increases 
`masterEpoch`. This is the same transition as an election that finds no new 
master, so:
   
   - `masterBrokerId == null || masterBrokerId ∈ syncStateSet ⊆ brokerIdTable` 
holds again after a clean;
   - the removed broker is fenced by the larger epoch;
   - the remaining in-sync replicas can be elected through the normal paths.
   
   Note: this changes how a `CleanBrokerDataEvent` is applied, so during a 
rolling upgrade of a controller group, replicas on old and new versions apply 
such an entry differently. This is the same constraint as any other state 
machine fix.
   
   ### How Did You Test This Change?
   
   - New `ReplicasInfoManagerTest#testCleanMasterBrokerIdShouldClearMaster`: 
cleans the master id, asserts that the master is cleared, `masterEpoch` 
increases by one, and that an in-sync replica can be elected afterwards. It 
fails on `develop` (`expected null, but was:<1>`) and passes with this change.
   - `mvn -pl controller test` (JDK 8): 90 tests, 0 failures, checkstyle passed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [PR] [ISSUE #11656] fix(control... leizhiyuan (via GitHub) via commits

Reply via email to