[Backport 2.19] Fix segment replication failure during rolling restart#20498
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
During rolling restarts, replica shards may have received newer checkpoints from the primary before the restart, but after restart, the primary may have rolled back to an older state. The strict checkpoint validation added in opensearch-project#18944 to fix race conditions during primary relocation incorrectly rejects this legitimate scenario, causing shards to fail allocation after 5 retries. This fix distinguishes between two scenarios: 1. Normal replication - strict checkpoint validation applies to prevent accepting stale data during primary relocation (maintains opensearch-project#18944 fix) 2. Recovery (shard INITIALIZING or RELOCATING) - accepts the primary's current state even if it appears older than the replica's last known checkpoint, as this is expected during recovery from restart Added unit tests to verify: - Stale checkpoint is rejected during normal replication - Stale checkpoint is accepted during shard recovery Note: In 2.19, the logic is in SegmentReplicationTarget.java instead of AbstractSegmentReplicationTarget.java (which was introduced in later versions). Signed-off-by: Cuong Ha <cuong.ha@optimizely.com> Fixes opensearch-project#19234
Signed-off-by: Cuong Ha <cuong.ha@optimizely.com>
Signed-off-by: Cuong Ha <cuong.ha@optimizely.com>
Signed-off-by: Cuong Ha <cuong.ha@optimizely.com>
bd60de1 to
36e440d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 2.19 #20498 +/- ##
============================================
- Coverage 71.99% 71.98% -0.02%
- Complexity 65993 66022 +29
============================================
Files 5342 5342
Lines 307364 307363 -1
Branches 44857 44857
============================================
- Hits 221298 221251 -47
- Misses 67624 67668 +44
- Partials 18442 18444 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Andrew Ross <andrross@amazon.com>
|
Hello @andrross , is this PR part of OpenSearch 2.19.5? 2.19.5 release notes did not mention it. Was the issue fixed? |
|
@louzadod This is included in OpenSearch version 2.19.5. You can check it here https://github.com/opensearch-project/OpenSearch/blob/2.19/release-notes/opensearch.release-notes-2.19.5.md |
|
Thank you @cuonghm2809 for the quick answer. Last night our cluster nodes were updated and OS cluster returned automatically to the GREEN state thanks to v2.19.5. |
Description
Backport of the fix #20422 for segment replication failure during rolling restart to 2.19 branch.
Related Issues
Resolves #19234
Root Cause
During rolling restarts, replica shards may have received newer checkpoints from the primary before the restart, but after restart, the primary may have rolled back to an older state. The strict checkpoint validation added in #18944 to fix race conditions during primary relocation incorrectly rejects this legitimate scenario, causing shards to fail allocation after 5 retries.
Error Message
Solution
This fix distinguishes between two scenarios:
Implementation Notes
SegmentReplicationTarget.javainstead ofAbstractSegmentReplicationTarget.java(which was introduced in later versions)