Skip to content

Fix continuation leakage on netty http2 client pipeline#11595

Draft
amarziali wants to merge 2 commits into
masterfrom
andrea.marziali/netty-http2
Draft

Fix continuation leakage on netty http2 client pipeline#11595
amarziali wants to merge 2 commits into
masterfrom
andrea.marziali/netty-http2

Conversation

@amarziali
Copy link
Copy Markdown
Contributor

What Does This Do

Fixes an orphaned async continuation in Netty 4.1 HTTP/2 client flows.

For HTTP/1, the connect continuation captured in ConnectAdvice is later consumed by the request handler. In HTTP/2 prior-knowledge mode, the continuation is captured on the connection channel but requests are written on stream channels, so the continuation was never consumed or canceled.

This change marks channels that have an HTTP/2 connection codec as HTTP/2 connections and skips capturing the connect continuation for them. This avoids creating a continuation with no consumer. The request handler now also checks the parent channel for an existing connect continuation, covering stream-channel request paths where a parent-channel continuation is valid.

Issue spotted using an experimental continuation lifecycle tracker that gave:

continuation #35 captured-never-activated-or-canceled
    captured by: captureActiveSpan
    span: parent trace_id=9 span_id=8
    capture thread: reactor-http-nio-6
    activations=0, closed_scopes=0, cancels=0
    capture stack:
      at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipeline.java:978)
      at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:253)
      at reactor.netty.transport.TransportConnector.lambda$doConnect$3(TransportConnector.java:149)
      at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98)

Motivation

Additional Notes

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@amarziali amarziali requested a review from a team as a code owner June 8, 2026 10:02
@amarziali amarziali added the type: bug Bug report and fix label Jun 8, 2026
@amarziali amarziali requested review from vandonr and removed request for a team June 8, 2026 10:02
@amarziali amarziali added the inst: netty Netty instrumentation label Jun 8, 2026
@datadog-prod-us1-3

This comment has been minimized.

@amarziali amarziali marked this pull request as draft June 8, 2026 10:02
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bf8a318e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +257 to +260
if (Boolean.TRUE.equals(
pipeline.channel().attr(HTTP2_CONNECTION_CODEC_ATTRIBUTE_KEY).get())) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve connect error spans for HTTP/2

For HTTP/2 prior-knowledge clients the Http2FrameCodec is added during channel initialization, before ChannelPipeline.connect, so this early return also skips capturing the continuation that ChannelFutureListenerInstrumentation.OperationCompleteAdvice consumes to create netty.connect error spans on failed connects. In the inspected Netty 4.1 workflow, a refused/timeout H2 connection never reaches the request handler, so there is no later consumer to report the connection failure under the active parent trace.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. should be fixed by 9652b38

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Jun 8, 2026

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.91 s 13.99 s [-1.4%; +0.3%] (no difference)
startup:insecure-bank:tracing:Agent 12.86 s 13.08 s [-2.5%; -0.8%] (maybe better)
startup:petclinic:appsec:Agent 16.63 s 16.62 s [-1.5%; +1.6%] (no difference)
startup:petclinic:iast:Agent 16.64 s 16.83 s [-2.6%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 15.71 s 16.62 s [-13.7%; +2.8%] (unstable)
startup:petclinic:sca:Agent 16.60 s 15.72 s [-3.5%; +14.6%] (unstable)
startup:petclinic:tracing:Agent 15.21 s 16.05 s [-13.3%; +2.9%] (unstable)

Commit: 9652b38c · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@amarziali amarziali force-pushed the andrea.marziali/netty-http2 branch from 9652b38 to c2a3193 Compare June 8, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: netty Netty instrumentation type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant