Skip to content

Check the maximum operation count in HeartbeatConsistencyCheckPingsAsync - #3342

Merged
mgravell merged 1 commit into
seredis:mainfrom
unsafePtr:fix/heartbeat-opcount-max
Nov 9, 2026
Merged

mgravell merged 1 commit into
seredis:mainfrom
unsafePtr:fix/heartbeat-opcount-max

Conversation

@unsafePtr

Copy link
Copy Markdown
Contributor

HeartbeatConsistencyCheckPingsAsync asserted minExpected <= opCount && opCount >= minExpected, checking the minimum twice and never the maxExpected from the theory data. It now checks opCount <= maxExpected, so the case with consistency checks disabled verifies that no heartbeat operations are sent.

Both theory cases pass on net8.0 and net10.0 against a local Redis 7, three runs in a row.

Checklist

  • I fully and freely contribute this code in accordance with the project license (and am legally able to do so)
  • I take responsibility for this contribution's quality and correctness, including any portions produced with AI assistance (see CONTRIBUTING.md).

@mgravell

mgravell commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks @unsafePtr — nice catch. The typo dates all the way back to #2656, so the upper bound (and the false case's exact-zero) had been silently vacuous for three years; the compound assert testing minExpected twice is exactly the shape that hides this, which is a good argument for Assert.InRange here.

One thing we'll keep an eye on post-merge: since those bounds have never actually gated a run, this effectively arms two new timing assertions (the 100ms heartbeat fires on wall clock, so a Task.Delay(1s) overshoot under CI load can push past 15 pings, and the false case now requires literally zero ops in the window). If they flake we'll derive the ceiling from measured elapsed time rather than loosening the constants — but that's on us, not a blocker for this fix. Merging — thanks again!

@mgravell
mgravell merged commit 079742b into seredis:main Nov 9, 2026
4 checks passed
@unsafePtr

Copy link
Copy Markdown
Contributor Author

@mgravell , that's the beauty of roslyn analyzer. Let me try to scan couple more projects. If you have also something in mind for catching such kind of mistakes, please let me know. I would be happy to improve the analyzer.
https://github.com/unsafePtr/Typo.Analyzers

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.

2 participants