JiangSOBD opened a new pull request, #11619:
URL: https://github.com/apache/rocketmq/pull/11619
### Which Issue(s) This PR Fixes
- Fixes #11603
### Brief Description
In controller mode, an AutoSwitch HA slave may calculate a consistent point
that is lower than its local `confirmOffset` when reconnecting to a
data-regressed master.
Previously, `AutoSwitchHAClient#doTruncate` passed that offset directly to
`truncateFiles`, which could silently remove already confirmed messages and
lower the slave's local `confirmOffset`.
This PR adds a fail-closed safety check before truncation:
- Read the slave's current local `confirmOffset`.
- Reject the operation when `truncateOffset < confirmOffset`.
- Return before calling `truncateFiles`, changing the HA state, or reporting
the
truncated offset.
- Log the proposed truncate offset, confirm offset, and both master and slave
epoch entries for diagnosis.
- Continue to allow truncation when `truncateOffset == confirmOffset`.
This prevents acknowledged data from being silently discarded. The change is
limited to the store-side safety guard and does not modify the controller
election policy.
### How Did You Test This Change?
Added `AutoSwitchHAClientTest` with coverage for:
- Rejecting a truncate offset below `confirmOffset`.
- Verifying that `truncateFiles` is not called after rejection.
- Verifying that the client remains in the `READY` state.
- Allowing a truncate offset exactly equal to `confirmOffset`.
- Verifying that the valid boundary case enters the `TRANSFER` state.
Also ran the complete `common`, `remoting`, and `store` Maven test reactor:
- 900 tests executed.
- 0 failures.
- 0 errors.
- 12 existing skipped tests.
- Checkstyle and SpotBugs 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]