Repository navigation
v4: a sync unsubscribe doesn't wait behind an in-flight subscribe - #3421
Merged
Merged
Conversation
An UNSUBSCRIBE queued behind a subscribe that hasn't been acknowledged cannot reply first, so a synchronous caller waiting for it blocked for the whole sync timeout and then returned or threw RedisTimeoutException, depending on which timer ran out first. main doesn't wait here; nor does v4 now. The unsubscribe is still sent as an ordinary command, so a declined or timed-out one is still retried; async callers still await it. The test's sync timeout is now far above the async one, so the old behaviour fails every time rather than only on a slow runner.
17 of 49 tasks
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.
A synchronous
Unsubscribethat races an in-flight subscribe queues itsUNSUBSCRIBEbehind that subscribe on the same connection. On v4 it then waited for the reply. That reply can't arrive before the subscribe's, so the caller blocked for the whole sync timeout, and then:RedisTimeoutException, if the command's timeout won.Which of the two happened came down to timing, and that race is what flaked
SyncUnsubscribeDuringInFlightSubscribeThatTimesOutStillUnsubscribeson Windows CI. main doesn't wait in this case: it queues the unsubscribe and returns, soUnsubscribeAlldoesn't stall behind it either.v4 now does the same. The change is limited to a sync caller and an unsubscribe queued behind an in-flight subscribe. That unsubscribe is still sent as an ordinary command, never fire-and-forget, so a declined or timed-out one is still retried. Async callers still await it, as on main.
The test
The test's comment said the unsubscribe was fire-and-forget, which wasn't true on v4. It now matches the behaviour. I also raised the test's sync timeout to 10s, against a 500ms async timeout. That makes the old behaviour fail every time with the same error CI saw (4/4, twice), not just on a slow runner. With the fix it passed 10 runs out of 10.
Checks
Full suite on net10.0 in both configurations, with no failures:
SanityChecks also passes, and
srcbuilds clean on every TFM.