Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reentrant subscribe in StreamingNettyByteBody #11051

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Conversation

yawkat
Copy link
Member

@yawkat yawkat commented Aug 6, 2024

If a subscriber to a split streaming body writes a response when reading data from the body, this can ultimately lead to another split of the same body being closed. Closing the body in turn is a subscribe operation, which must not happen during a read in a reentrant fashion. This would lead to a failure in the assertion that guards against such reentrant operations (assert !working;), and various downstream issues like buffer leaks. In particular, MaxRequestSizeSpec was affected by this bug occasionally.

This patch replaces the use of EventLoopFlow with more suitable code. In particular, EventLoopFlow does not support reentrant or concurrent calls, it only ensures serialization. The new logic supports reentrant or concurrent calls and still ensures serialization where it matters.

The new test does not work yet due to netty/netty#13730 . This PR is a draft until that patch is released.

If a subscriber to a split streaming body writes a response when reading data from the body, this can ultimately lead to another split of the same body being closed. Closing the body in turn is a subscribe operation, which must not happen during a read in a reentrant fashion. This would lead to a failure in the assertion that guards against such reentrant operations (`assert !working;`), and various downstream issues like buffer leaks. In particular, `MaxRequestSizeSpec` was affected by this bug occasionally.

This patch replaces the use of EventLoopFlow with more suitable code. In particular, EventLoopFlow does not support reentrant or concurrent calls, it only ensures serialization. The new logic supports reentrant or concurrent calls and still ensures serialization where it matters.

The new test does not work yet due to netty/netty#13730 . This PR is a draft until that patch is released.
@yawkat yawkat added the type: bug Something isn't working label Aug 6, 2024
@graemerocher
Copy link
Contributor

@yawkat now that the netty upgrade is done can this proceed?

@yawkat
Copy link
Member Author

yawkat commented Sep 9, 2024

Sure I'll update

Copy link

sonarcloud bot commented Sep 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
64.3% Coverage on New Code (required ≥ 70%)

See analysis details on SonarCloud

@yawkat yawkat marked this pull request as ready for review September 9, 2024 12:46
@graemerocher graemerocher merged commit 7b60047 into 4.6.x Sep 9, 2024
20 of 21 checks passed
@graemerocher graemerocher deleted the reentrant-close branch September 9, 2024 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants