Skip to content

[release/8.0] Fix h3 connection-level and stream-level abort locking - #69152

Open
BrennanConroy wants to merge 1 commit into
release/8.0from
brecon/bp8
Open

[release/8.0] Fix h3 connection-level and stream-level abort locking#69152
BrennanConroy wants to merge 1 commit into
release/8.0from
brecon/bp8

Conversation

@BrennanConroy

Copy link
Copy Markdown
Member

Backport of #68102 to release/8.0

/cc @BrennanConroy @cincuranet

Fix h3 connection-level and stream-level abort locking

Description

Improve server reliability when using HTTP/3.

Fixes #68101

Customer Impact

Threads can get blocked resulting in more threads being created.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Follows similar pattern already implemented in HTTP/2

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

Copilot AI lite review requested due to automatic review settings September 8, 2026 18:02
@BrennanConroy BrennanConroy added feature-kestrel area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions labels Sep 8, 2026
@dotnet-policy-service dotnet-policy-service Bot added this to the 8.0.x milestone Sep 8, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hi @BrennanConroy. If this is not a tell-mode PR, please make sure to follow the instructions laid out in the servicing process document.
Otherwise, please add tell-mode label.

@BrennanConroy BrennanConroy changed the title Fix h3 connection-level and stream-level abort locking [release/8.0] Fix h3 connection-level and stream-level abort locking Sep 8, 2026

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.

Copilot review overview

🔵 Needs a closer look

This touches core HTTP/3 concurrency/locking in Kestrel where subtle ordering regressions can be hard to validate without targeted stress coverage.

Review tier: Lite
Findings: 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity src/​Servers/​Kestrel/​Core/​src/​Internal/​Http3/​Http3Stream.cs — Within AbortCore you're already holding _completionLock, but ApplyCompletionFlag() takes the…
What changed in this PR

Backports the HTTP/3 stream abort locking fix to release/8.0 to avoid deadlocks between connection-level/stream-level abort paths and inline output flushing, improving server reliability under heavy abort activity.

Changes:

  • Moves HTTP/3 abort side-effects (_http3Output.Stop(), pipe completion, frame-writer abort) to run outside _completionLock to avoid _completionLock_dataWriterLock deadlocks.
  • Adds an abort-completion barrier (_abortCompletedTcs) and waits for in-flight abort side-effects during request finalization before disposing/pooling the stream.
  • Marks the stream as Completed during finalization so any subsequent abort becomes a no-op.
File Description
src/​Servers/​Kestrel/​Core/​src/​Internal/​Http3/​Http3Stream.cs Refactors abort locking to avoid deadlocks and adds synchronization to prevent late abort side-effects from impacting pooled/reused stream transports.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 172 to 176
var (oldState, newState) = ApplyCompletionFlag(StreamCompletionFlags.Aborted);

if (oldState == newState)
{
return;
@BrennanConroy BrennanConroy added the Servicing-approved Shiproom has approved the issue label Sep 8, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hi @BrennanConroy. This PR was just approved to be included in the upcoming servicing release. Somebody from the @dotnet/aspnet-build team will get it merged when the branches are open. Until then, please make sure all the CI checks pass and the PR is reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-kestrel Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants