Skip to content

improve replication/handover check logging and readability#9787

Closed
thestephenstanton wants to merge 0 commit intomainfrom
sstanton/cleaner-more-detailed-catchup-funcs
Closed

improve replication/handover check logging and readability#9787
thestephenstanton wants to merge 0 commit intomainfrom
sstanton/cleaner-more-detailed-catchup-funcs

Conversation

@thestephenstanton
Copy link
Copy Markdown
Contributor

@thestephenstanton thestephenstanton commented Apr 2, 2026

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
  • 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.

@thestephenstanton thestephenstanton marked this pull request as ready for review April 3, 2026 19:29
@thestephenstanton thestephenstanton requested a review from a team as a code owner April 3, 2026 19:29
@temporal-nick temporal-nick requested a review from yux0 April 6, 2026 19:37
Comment on lines 222 to 224
sort.SliceStable(resp.Shards, func(i, j int) bool {
return resp.Shards[i].ShardId < resp.Shards[j].ShardId
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised the slices weren't already sorted this way. Is this required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 7, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ thestephenstanton
❌ Stephen


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.

@thestephenstanton thestephenstanton force-pushed the sstanton/cleaner-more-detailed-catchup-funcs branch from 33c6a70 to a133503 Compare April 7, 2026 18:28
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants