improve replication/handover check logging and readability#9787
Closed
thestephenstanton wants to merge 0 commit intomainfrom
Closed
improve replication/handover check logging and readability#9787thestephenstanton wants to merge 0 commit intomainfrom
thestephenstanton wants to merge 0 commit intomainfrom
Conversation
Comment on lines
222
to
224
| sort.SliceStable(resp.Shards, func(i, j int) bool { | ||
| return resp.Shards[i].ShardId < resp.Shards[j].ShardId | ||
| }) |
Contributor
There was a problem hiding this comment.
I'm surprised the slices weren't already sorted this way. Is this required?
Contributor
Author
There was a problem hiding this comment.
I can't tell why this was done, it did kinda help out though when debugging because we always started from the lowest shard number and could tell by the log of the first non ready shard how close we were to finishing. And since most logged were low numbers we could assume most of them weren't getting very far.
|
Stephen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
33c6a70 to
a133503
Compare
5 tasks
thestephenstanton
added a commit
that referenced
this pull request
Apr 8, 2026
Continuing from this PR: #9787 ## What changed? Replaced the log dump that happened on the first non ready shard with with a single summary log per invocation that includes total, ready, and not ready shard counts and the slowest shard by task lag and time lag, making it easier to diagnose stalled replication and handover. Refactored `checkReplicationOnce`, `checkHandoverOnce`, and `checkReplicationOnRemoteCluster` to use guard clauses, eliminating nested logic and the logged guard pattern while also renaming some variables; all for improved readability. Also, there is a fix to a subtle bug where if the remote cluster shard progress lookup (map inside the shard loop) doesn't have data and we have already logged previous non ready shards, then we would actually not return an error. ## Why? Log change: The old log only captured one shard's state at a time, making it hard to understand overall progress during a stalled catchup or handover. A single summary with counts and the slowest shards gives you the full picture in one entry. Refactor: The nested if/logged guard pattern made it harder to follow than needed; guarding flattens this out vs having deep nests. Also renamed variables make things more clear. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks If anyone is extremely dependent on the previous log fields.
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.
What changed?
Replaced the log dump that happened on the first non ready shard with with a single summary log per invocation that includes total, ready, and not ready shard counts and the slowest shard by task lag and time lag, making it easier to diagnose stalled replication and handover.
Refactored
checkReplicationOnce,checkHandoverOnce, andcheckReplicationOnRemoteClusterto use guard clauses, eliminating nested logic and the logged guard pattern while also renaming some variables; all for improved readability.Also, there is a fix to a subtle bug where if the remote cluster shard progress lookup (map inside the shard loop) doesn't have data and we have already logged previous non ready shards, then we would actually not return an error.
Why?
Log change: The old log only captured one shard's state at a time, making it hard to understand overall progress during a stalled catchup or handover. A single summary with counts and the slowest shards gives you the full picture in one entry.
Refactor: The nested if/logged guard pattern made it harder to follow than needed; guarding flattens this out vs having deep nests. Also renamed variables make things more clear.
How did you test it?
Potential risks
If anyone is extremely dependent on the previous log fields.