Fix gossip client timeout: TimeSpan .Milliseconds vs .TotalMilliseconds#1972
Merged
Conversation
tiagonapoli
force-pushed
the
tiagonapoli/fix-gossip-client-timeout
branch
3 times, most recently
from
July 23, 2026 05:38
2c72b0a to
eb1cec2
Compare
tiagonapoli
marked this pull request as ready for review
July 23, 2026 05:41
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a TimeSpan component-vs-total misuse that caused the cluster gossip client operation timeout to be computed as 0 for whole-second values (disabling GarnetClient’s timeout checker). Also cleans up related same-pattern issues and adds regression coverage.
Changes:
- Add
GarnetServerNode.GetClientTimeoutMilliseconds(int)and use it when constructing the gossipGarnetClient. - Replace
LoggingFrequency’sTimeSpan.FromSeconds(5).Secondswith the equivalent literal5. - Strengthen AOF recovery TTL assertions to use
TotalMillisecondsand add a new regression test fixture for timeout computation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/standalone/Garnet.test.scripting/RespAofTests.cs | Fix TTL assertions to use total duration rather than component milliseconds. |
| test/cluster/Garnet.test.cluster/GarnetServerNodeTimeoutTests.cs | Add regression tests for gossip client timeout computation. |
| libs/server/Servers/GarnetServerOptions.cs | Simplify LoggingFrequency initialization to a literal seconds value. |
| libs/cluster/Server/Gossip/GarnetServerNode.cs | Fix gossip client timeout computation by using total milliseconds via a helper. |
GarnetServerNode computed the gossip GarnetClient's per-operation timeout as `TimeSpan.FromSeconds(opts.ClusterTimeout).Milliseconds`, which returns the sub-second component (0-999), not the total. For any whole-second ClusterTimeout (default 60s) this yields 0, silently disabling the client's TimeoutChecker so gossip operations never time out. - GarnetServerNode: use TotalMilliseconds via a testable GetClientTimeoutMilliseconds helper. - Add GarnetServerNodeTimeoutTests (7 cases) covering the regression. - GarnetServerOptions: LoggingFrequency used TimeSpan.FromSeconds(5).Seconds (correct only because 5<60); simplify to the int-seconds literal. - RespAofTests: TTL assertions used .Milliseconds (component, always <8500), a silent no-op; use .TotalMilliseconds with the correct 10s ceiling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: de1c4e90-5293-4056-8783-1779a318e774
tiagonapoli
force-pushed
the
tiagonapoli/fix-gossip-client-timeout
branch
from
July 23, 2026 05:49
eb1cec2 to
037b8e9
Compare
kevin-montrose
approved these changes
Jul 23, 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.
Summary
Fixes a
TimeSpancomponent-vs-total misuse that silently disables the gossip client's operation timeout, plus related occurrences of the same defect pattern.Bug 1 (behavioral) — gossip client timeout never fires
GarnetServerNodebuilt the gossipGarnetClientwith:TimeSpan.Millisecondsreturns the sub-second component (0–999), not the total duration. For any whole-secondClusterTimeout(the type isintseconds, default 60), this evaluates to 0, which disablesGarnetClient'sTimeoutChecker. Result: gossip operations effectively never time out on the per-operation client timeout.Fix: compute the value with
TotalMilliseconds, extracted into a testable helper:Same-pattern cleanups
GarnetServerOptions.LoggingFrequencywasTimeSpan.FromSeconds(5).Seconds— correct only because5 < 60, but a latent trap. Simplified to the plain int-seconds literal5(value unchanged).RespAofTests(RMW + Upsert recover tests) assertedrecoveredValueTtl.Value.Milliseconds < 8500. Since the milliseconds component is always 0–999, this assertion was a silent no-op. Corrected toTotalMillisecondswith the real ceiling of10_000(Key2 is set with a 10s expiry), so it now actually validates0 < ttl ≤ 10s.Tests
GarnetServerNodeTimeoutTests(7 cases) directly coversGetClientTimeoutMilliseconds, including the regression case60 → 60000(returns0under the old code).RespAofTestscontinue to pass with the strengthened assertions.Scope
Isolated fix branch off
main— contains only these four files. No functional changes beyond the timeout correctness fix and the same-pattern cleanups.