Skip to content

Prevent Netty periodic purge tasks from inheriting context - #12499

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
andrea.marziali/diag-fix-netty-concurrent
Sep 16, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
masterfrom
andrea.marziali/diag-fix-netty-concurrent

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

Prevents Netty’s lazily created event-loop maintenance tasks from inheriting the request context that happens to start the event executor.

Netty 4.0 creates a periodic purge task inside SingleThreadEventExecutor.startThread(). When the executor starts during a traced request, that long-lived internal task can capture the request context and retain
its continuation after the request completes.

Async propagation is now temporarily disabled only while the private, no-argument startThread() method creates these internal tasks. The previous propagation state is restored on both normal and exceptional
exits.

sequenceDiagram
    participant Request as Traced request
    participant Executor as Netty event executor
    participant Agent as Context instrumentation
    participant Task as Periodic purge task

    Request->>Executor: first operation
    Executor->>Agent: enter startThread()
    Agent->>Agent: save propagation state
    Agent->>Agent: disable async propagation
    Executor->>Task: create periodic maintenance task
    Note over Task: No request context captured
    Executor-->>Agent: exit startThread()
    Agent->>Agent: restore propagation state
    Executor-->>Request: continue request
Loading

Motivation

The purge task belongs to the event executor, not to the request that caused its lazy initialization. Its lifecycle can span many requests, so retaining the first request’s continuation is not useful and this continuation is never closed.

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added the type: bug fix Bug fix label Sep 15, 2026
@amarziali
amarziali requested a review from a team as a code owner September 15, 2026 10:19
@amarziali amarziali added the inst: netty Netty instrumentation label Sep 15, 2026
@amarziali
amarziali requested review from ygree and removed request for a team September 15, 2026 10:19
@amarziali amarziali added the tag: ai generated Largely based on code generated by an AI or LLM label Sep 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T10:56:14.770089Z acbd49d Manual request
🔒 Security Review Completed 2026-09-15T10:56:20.571260Z acbd49d Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot 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.

Datadog Autotest: PASS

More details

The advice matches only the private startThread method that has no arguments. It restores async propagation after normal and exceptional exits.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 07550cf · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

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

Copy link
Copy Markdown

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: 07550cf4c6

ℹ️ 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".

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 62.71% (+3.67%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: acbd49d | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

🟢 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.94 s 13.85 s [-0.3%; +1.6%] (no difference)
startup:insecure-bank:tracing:Agent 12.90 s 12.98 s [-1.4%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.00 s 16.84 s [+0.3%; +1.6%] (maybe worse)
startup:petclinic:iast:Agent 16.98 s 16.97 s [-0.8%; +0.9%] (no difference)
startup:petclinic:profiling:Agent 16.66 s 16.71 s [-1.5%; +0.9%] (no difference)
startup:petclinic:sca:Agent 16.80 s 16.83 s [-1.1%; +0.8%] (no difference)
startup:petclinic:tracing:Agent 16.13 s 15.99 s [-0.1%; +1.8%] (no difference)

Commit: acbd49df · 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

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: acbd49df68

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: acbd49df68

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@ygree ygree 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.

IDM approved. Not sure if the title should really be 'periodic purge task' instead of 'startup tasks'.

@amarziali amarziali changed the title Prevent Netty startup tasks from inheriting context Prevent Netty periodic purge tasks from inheriting context Sep 16, 2026
@amarziali

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Sep 16, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-09-16 07:56:45 UTC ℹ️ Start processing command /merge


2026-09-16 07:56:50 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-09-16 09:07:22 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 6c9c7ee into master Sep 16, 2026
605 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the andrea.marziali/diag-fix-netty-concurrent branch September 16, 2026 09:07
@github-actions github-actions Bot added this to the 1.67.0 milestone Sep 16, 2026
jandro996 pushed a commit that referenced this pull request Sep 17, 2026
Prevent Netty startup tasks from inheriting context

Cover shaded Netty event executors

Co-authored-by: andrea.marziali <andrea.marziali@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: netty Netty instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants