Repository navigation
IoUring: preserve readPending when rescheduling cancelled reads (#17087) - #17090
Merged
Merged
Conversation
Motivation: Fix a read stall reported in #17049. With autoRead disabled, an explicit read can be lost when a cancelled RECV completion races with an active multishot POLL_ADD. ```text T0 A multishot POLL_ADD(POLLIN) is active. T1 Netty submits a normal RECV. T2 clearRead() cancels the RECV. -> readPending = false T3 user calls channel.read() before the cancel CQE arrives. -> readPending = true -> doBeginReadNow() skips submitting RECV because POLL_ADD is still active T4 the cancelled RECV completes with -ECANCELED. -> pending is captured as true -> completion handling clears readPending = false T5 current behavior: -> doBeginReadNow() is called, but readPending is already false -> later POLLIN only sets socketHasMoreData -> no RECV is submitted, so the response stalls ``` One-shot POLL_ADD usually avoids this because its POLLIN completion clears the poll state first. Multishot POLL_ADD remains scheduled, so the later cancelled RECV completion can clear the only readPending signal. This race depends on CQE ordering, so it is hard to cover with a stable unit test. Modification: Restore readPending before rescheduling a read when a cancelled read completion observed a pending read. This also covers the equivalent one-shot POLLIN interleaving. Result: Fixes #17049.
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.
Motivation:
Fix a read stall reported in #17049. With autoRead disabled, an explicit
read can be lost when a cancelled RECV completion races with an active
multishot POLL_ADD.
One-shot POLL_ADD usually avoids this because its POLLIN completion
clears the poll state first. Multishot POLL_ADD remains scheduled, so
the later cancelled RECV completion can clear the only readPending
signal.
This race depends on CQE ordering, so it is hard to cover with a stable
unit test.
Modification:
Restore readPending before rescheduling a read when a cancelled read
completion observed a pending read. This also covers the equivalent
one-shot POLLIN interleaving.
Result:
Fixes #17049.