Add force resume support for cross-cluster replication#1685
Conversation
c20e107 to
fb17424
Compare
PR Reviewer Guide 🔍(Review updated until commit 82ea354)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 82ea354 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 2bf84b4
Suggestions up to commit 576641a
Suggestions up to commit b7f4ab9
Suggestions up to commit 6da406c
Suggestions up to commit 8e877db
|
a8e76d6 to
5017605
Compare
|
Persistent review updated to latest commit 5017605 |
|
Regarding #1685 (comment) Regarding Race Condition comment:- Incomplete Cleanup Logic Error Null seqNoStats |
5017605 to
a23f7a8
Compare
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 82ea354.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Persistent review updated to latest commit a23f7a8 |
|
#1685 (comment) Replaced .all() with .clear() followed by .translog(true) — this tells the leader to only compute translog-related stats, dramatically reducing the payload sent across the cluster boundary. |
|
Persistent review updated to latest commit fdf3669 |
|
Can you add ITs ? |
e5aa8d4 to
a22e956
Compare
|
Persistent review updated to latest commit a22e956 |
|
Persistent review updated to latest commit fc1a080 |
fc1a080 to
0f53dec
Compare
|
Persistent review updated to latest commit 0f53dec |
Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
- Removed reimplemented block removal/addition (reuses UpdateIndexBlockAction, same as stop action) - Removed reimplemented index deletion (reuses same pattern as IndexReplicationTask.cancelRestore) - Removed reimplemented lease cleanup (reuses existing RemoteClusterRetentionLeaseHelper methods) - Removed ReplicationMetadataManager dependency from coordinator (not needed) - Simplified getLeaderGlobalCheckpoint using firstOrNull (same API as RemoteClusterRepository) - Only genuinely new logic retained: pre-restore lease acquisition at leaderCheckpoint+1 Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
00fafb3 to
d63504b
Compare
|
Persistent review updated to latest commit d63504b |
d63504b to
a1901ff
Compare
|
Persistent review updated to latest commit a1901ff |
a1901ff to
d9fc56e
Compare
|
Persistent review updated to latest commit d9fc56e |
d9fc56e to
28878c9
Compare
|
Persistent review updated to latest commit 28878c9 |
28878c9 to
88aa4ba
Compare
|
Persistent review updated to latest commit 88aa4ba |
88aa4ba to
8e877db
Compare
|
Persistent review updated to latest commit 8e877db |
8e877db to
6da406c
Compare
|
Persistent review updated to latest commit 6da406c |
6da406c to
b7f4ab9
Compare
|
Persistent review updated to latest commit b7f4ab9 |
b7f4ab9 to
576641a
Compare
|
Persistent review updated to latest commit 576641a |
576641a to
2bf84b4
Compare
|
Persistent review updated to latest commit 2bf84b4 |
…ordinator Signed-off-by: Mohit Kumar <mohitamg@amazon.com>
2bf84b4 to
82ea354
Compare
|
Persistent review updated to latest commit 82ea354 |
Test Coverage for Force ResumeUnit Tests —
|
| # | Scenario | What it validates |
|---|---|---|
| 1 | Serialization roundtrip with forceResume=false | Wire format backward compatibility — default false survives serialize/deserialize |
| 2 | Serialization roundtrip with forceResume=true | Wire format carries force_resume=true correctly across nodes |
| 3 | indices() returns index name | Request correctly identifies target index |
| 4 | validate() returns null | No validation errors for valid request |
| 5 | fromXContent with force_resume=true | REST body {"force_resume": true} parsed correctly |
| 6 | fromXContent with force_resume=false | REST body {"force_resume": false} parsed correctly |
| 7 | fromXContent with empty body defaults to false | Empty {} body maintains backward compatibility |
| 8 | toXContent includes force_resume field | API response includes the field |
| 9 | indicesOptions is strict single index | Request targets exactly one index |
Unit Tests — TransportResumeIndexReplicationActionTests.kt
| # | Scenario | What it validates |
|---|---|---|
| 1 | Leases valid + forceResume=true → skips force path | No unnecessary stop+start when leases are healthy |
| 2 | Leases expired + forceResume=false → throws | User gets clear error instead of silent failure |
| 3 | Leases expired + forceResume=true → triggers force path | Core routing logic works correctly |
| 4 | Role preservation with both roles present | Follower/leader roles carried into start request |
| 5 | Role preservation skipped when roles are null | No NPE when roles aren't set |
Integration Tests — ForceResumeReplicationIT.kt
| # | Scenario | What it validates |
|---|---|---|
| 1 | Force resume after retention lease expires | Full flow: start → sync → pause → expire leases (1s period, 30s wait) → normal resume fails → force resume succeeds → reaches SYNCING/BOOTSTRAPPING state |
| 2 | Force resume when retention leases still exist | force_resume=true with valid leases falls through to normal resume path — no unnecessary stop+start |
| 3 | Error message suggests force_resume option | When normal resume fails due to expired leases, error contains "force_resume=true" hint |
| 4 | Data written after force resume is replicated | 5 docs before pause + 5 docs during pause → force resume → all 10 present on follower → 5 more post-resume replicate (15 total) |
| 5 | Force resume on multi-shard index (5 shards) | 20 docs across 5 shards → pause → expire leases → 10 more during pause → force resume → all 30 present → 5 more post-resume replicate (35 total) |
Description
When retention leases expire on the leader cluster (e.g., due to prolonged pause or leader translog rollover), the normal resume API fails because it cannot catch up from where it left off. This PR adds a force_resume option that triggers a snapshot-based bootstrap to recover replication.
Solution
Added force_resume=true parameter to the resume replication API:
Backward Compatibility
The force_resume field defaults to false, so existing clients calling _resume with an empty body or without the field see no behavior change
Wire serialization is additive (new boolean field appended)
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.