Skip to content

Fix HTTP/2 window accounting and parser test socket leaks - #3749

Open
chenBright wants to merge 2 commits into
apache:masterfrom
chenBright:fix-h2-window
Open

chenBright wants to merge 2 commits into
apache:masterfrom
chenBright:fix-h2-window

Conversation

@chenBright

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A (follow-up to #3382)

Problem Summary:

Oversized HTTP/2 DATA frames are rejected before their flow-control credit is recorded. Stream cleanup cannot recover that credit, gradually reducing the connection window and potentially stalling other streams.

The memcache and Couchbase regression tests also retain the extra Socket creation reference, preventing the sockets from being recycled.

What is changed and the side effects?

Changed:

  • Record the full DATA payload, including padding, before body parsing so stream cleanup returns the offending frame's connection credit.
  • Release the Socket creation references in both parser tests and verify that the sockets are recycled.

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

@chenBright
chenBright requested a lite review from Copilot November 16, 2026 09:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Fixes an HTTP/2 flow-control window leak when rejecting oversized DATA frames (including padding), and plugs socket lifetime leaks in memcache/Couchbase parser regression tests.

Changes:

  • Account for the full HTTP/2 DATA payload (including padding) before body parsing so cleanup restores connection credit on oversized bodies.
  • Release extra Socket creation references in memcache/Couchbase parser tests and assert sockets are recycled.
  • Add an HTTP/2 regression test covering split vs. unsplit and padded vs. unpadded oversized bodies.
File Description
test/​brpc_memcache_unittest.cpp Releases socket creation ref and asserts socket is destroyed to prevent test socket leaks.
test/​brpc_http_rpc_protocol_unittest.cpp Adds HTTP/2 flow-control regression test for oversized DATA handling and window restoration.
test/​brpc_couchbase_unittest.cpp Releases socket creation ref and asserts socket is destroyed to prevent test socket leaks.
src/​brpc/​policy/​http2_rpc_protocol.cpp Fixes DATA window accounting by recording full payload size before OnBody() can reject.

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review identifies no active issues, with the changes addressing HTTP/2 flow-control cleanup and socket-reference leaks through targeted regression coverage.

No open issues 🎉

3 resolved since last review

Review effort: Lite

@chenBright

Copy link
Copy Markdown
Contributor Author

@wwbmmm PTAL.

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.

2 participants