Skip to content

Conversation

@becomeStar
Copy link
Contributor

@becomeStar becomeStar commented Dec 4, 2025

What this PR does

This PR fixes a race condition in OkHttpClientTransport where MAX_CONCURRENT_STREAMS sent by the server could be incorrectly overwritten by the client's default initialization.

The fix simply reorders the initialization to happen before starting the reader thread, ensuring that any updates from the server are preserved.

Note on Testing

I attempted to add a deterministic reproduction test, but reliably simulating this specific race condition proved difficult without intrusive changes.
I request reviewers to primarily verify the logical correctness of the reordering. I am open to collaborating with the team to develop a suitable test case if required.

Future Work

This PR covers Step 1 (Fixing the race condition) of the plan discussed in #11985.
I plan to follow up with Step 2 (Adding assertions to verify no pending streams exist) in a separate PR.

Part of #11985

@kannanjgithub kannanjgithub added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Dec 5, 2025
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Dec 5, 2025
@kannanjgithub kannanjgithub merged commit 8d49dc1 into grpc:master Dec 5, 2025
15 of 17 checks passed
@becomeStar becomeStar deleted the okhttp/fix-max-concurrent-streams-race branch December 12, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants