Repository navigation
Stabilize two racy tests: keyspace notification counting, and the drain-cap MOVING test - #3393
Merged
Merged
Conversation
…in-cap MOVING test PubSubKeyNotificationTests counted an event in the total before counting its key. Multi-node notifications arrive on several reader threads, so the last event could complete the run while another, already in the total, had not yet counted its key: the per-key check came up one short (expected 51, actual 50). Count the key first. MovingWaitsForSlowCommandsThatFitInsideTheDrainCap needs exactly one 3s command in flight, but SetLatency slowed every command, and the in-process server answers one at a time: a background INFO ahead of the PING pushed the PING's reply to ~6s, past the 5s drain cap, so the recycle failed it. Add a SetLatency overload that holds a single command, and slow only the PING.
mgravell
added a commit
that referenced
this pull request
Dec 3, 2026
* Docs: why WithRetry has no retrying batch, and what to use instead (#3388) A batch's one guarantee is an uninterrupted run, which a retry would break: a batch cannot be replayed as a unit (some of it may have applied), and re-issuing just the failed element would reorder it. Document that, and the alternatives: pipelined commands on the retrying database for independent work (each retried by its own category), a retrying transaction for all-or-nothing, and a plain batch where the uninterrupted run is what matters. Closes #3370. (cherry picked from commit 5e2e8e4) * Stabilize two racy tests: keyspace notification counting, and the drain-cap MOVING test (#3393) PubSubKeyNotificationTests counted an event in the total before counting its key. Multi-node notifications arrive on several reader threads, so the last event could complete the run while another, already in the total, had not yet counted its key: the per-key check came up one short (expected 51, actual 50). Count the key first. MovingWaitsForSlowCommandsThatFitInsideTheDrainCap needs exactly one 3s command in flight, but SetLatency slowed every command, and the in-process server answers one at a time: a background INFO ahead of the PING pushed the PING's reply to ~6s, past the 5s drain cap, so the recycle failed it. Add a SetLatency overload that holds a single command, and slow only the PING. (cherry picked from commit f5bf0c3) * Resp3DowngradeTests: keep publishing until the restored subscription receives (#3396) The test published once, straight after the interactive connection came back as RESP2. The subscription is restored separately (with a dedicated connection, on a connection of its own), and a message published before that SUBSCRIBE lands is not delivered, so on a slow runner the test waited 10s for a message that was never coming. It now publishes every 250ms until one arrives, still within 10s, so a subscription that is never restored still fails it. (cherry picked from commit e56835e) * Port main's small 3.5.0 fixes and test hardening to v4 - #3374 (+#3376): v4 already had the inverted-check fix; its regression test comes over (as #3374 shipped it - #3376's TryAdoptEndpoint rename belongs with #3353) - #3361: v4 already disposes socketless tunnel streams; its regression test comes over - #3386: the toy server's CLUSTER SLOTS snapshot fix; the other two windows are in code v4 replaced (QuitAllServers, PhysicalBridge creation; v4 executors connect lazily) - #3395: already the v4 behaviour (GetConnectionId does not dial) - #3394: not applicable; the test it fixes went with the old core
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.
Two intermittent failures on
main, both races in the tests rather than library bugs.PubSubKeyNotificationTestsCluster.KeyNotification_CanObserveSimple_ViaQueueSeen on Ubuntu at
a4cea63a: "Expected: 51, Actual: 50" for one key.OnNotificationincremented the total count before the per-key count, and the run completes when the total reaches 512. A multi-node (keyspace-pattern) subscription receives notifications on several reader threads at once, one per primary. The 512th event could therefore complete the run while another event was already counted in the total but hadn't yet counted its key. The per-key check then came up exactly one short.This wasn't duplicate delivery: a duplicate would also leave one key short, but it would complete the run early with an event still in flight, and the counting order explains the failure on its own. The fix counts the key first and then the total, so every event's per-key increment happens before its total increment. It applies to every test in the class, since they all go through
OnNotification.MaintenanceNotificationTests.MovingWaitsForSlowCommandsThatFitInsideTheDrainCapSeen on Windows/net481 at
5e2e8e49:MaintenanceHandoff ... origin: RecycleConnectionat 5.4s.The test relies on exactly one 3s command being in flight, because the in-process server answers one request at a time. But
SetLatencyslowed every command. In the failing run, the captured server log shows a backgroundINFOheld for 3s ahead of thePING. That pushed thePING's reply to about 6s, past the 5s drain cap, so the recycle correctly failed it.The fix adds an
InProcessTestServer.SetLatency(TimeSpan, RedisCommand onlyFor)overload that holds a single command. This test now slows only thePING; the existing all-commands overload is unchanged for every other caller.To confirm the diagnosis, I temporarily issued an
INFOjust before thePING. With the old all-commands latency, that reproduces the CI failure exactly (MaintenanceHandoffat 5.4s). With thePING-only latency, it passes.Testing
MaintenanceNotificationTests(37),MaintenanceRelaxationTests(17) andMultiMessageWriteTimeTests, theSetLatencyusers, pass on net10.0 and net481.