Set IsReplicating on APPENDLOG init handshake to prevent idle resync loop#1828
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts replication-session semantics so IsReplicating is set for the replication stream starting with the APPENDLOG init handshake, preventing unnecessary resyncs when the stream is idle.
Changes:
- Updated
IClusterSession.IsReplicatingXML doc to reflect “active replication stream” semantics (incl. handshake). - Moved APPENDLOG “initialization message” handling into the replica-path and sets
IsReplicating = truebefore the init handshake returns OK.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libs/server/Cluster/IClusterSession.cs | Clarifies IsReplicating contract to include init handshake as part of active replication stream. |
| libs/cluster/Session/RespClusterReplicationCommands.cs | Marks sessions as replicating earlier and handles init handshake in the replica branch to avoid spurious resyncs. |
vazois
approved these changes
May 26, 2026
badrishc
approved these changes
May 27, 2026
…loop After a TCP disruption on an idle cluster, the replica's EnsureReplication would trigger repeated resyncs because IsReplicating was only set when a data APPENDLOG arrived, not on the init handshake (-1,-1,-1). On an idle stream no data APPENDLOG follows, so the flag stayed false and EnsureReplication fired every ClusterReplicationReestablishmentTimeout. Move IsReplicating = true to the top of NetworkClusterAppendLog so it is set on every APPENDLOG message including the init handshake. The flag is cleared implicitly when the session is disposed on connection drop. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Validate that the node is a replica of the expected primary before initializing the ReplicaReplayDriver or setting IsReplicating. There is no point in performing initialization work if the role/primary checks would throw immediately after. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1cb8c92 to
2cb87ea
Compare
badrishc
approved these changes
May 27, 2026
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.
After a TCP disruption on an idle cluster, the replica's EnsureReplication
would trigger repeated resyncs because IsReplicating was only set when a
data APPENDLOG arrived, not on the init handshake (-1,-1,-1). On an idle
stream no data APPENDLOG follows, so the flag stayed false and
EnsureReplication fired every ClusterReplicationReestablishmentTimeout.
Move IsReplicating = true to the top of NetworkClusterAppendLog so it is
set on every APPENDLOG message including the init handshake. The flag is
cleared implicitly when the session is disposed on connection drop.