Skip to content

Prevent smoke-test teardown race - #12455

Open
AlexeyKuznetsov-DD wants to merge 2 commits into
masterfrom
alexeyk/fix-output-threads-teardown-race
Open

Prevent smoke-test teardown race#12455
AlexeyKuznetsov-DD wants to merge 2 commits into
masterfrom
alexeyk/fix-output-threads-teardown-race

Conversation

@AlexeyKuznetsov-DD

Copy link
Copy Markdown
Contributor

What Does This Do

Use the number of threads actually returned by ThreadGroup.enumerate() when joining smoke-test output readers during teardown.

Add a deterministic regression test that models an output thread disappearing between activeCount() and enumerate().

Motivation

ThreadGroup.activeCount() is only an estimate. The teardown code sized an array from that estimate, ignored the smaller count returned by enumerate(), and attempted to join every array entry. This could dereference an unused null entry after an output reader exited.

Additional Notes

The failure was flaky because teardown first interrupts the output-reader thread. If that thread exited after activeCount() reported it but before enumerate() populated the array, the array retained a null tail entry:

java.lang.NullPointerException
    at datadog.smoketest.OutputThreads.close(OutputThreads.java:36)
    at datadog.smoketest.AbstractSmokeApp.afterAll(AbstractSmokeApp.java:265)

Whether the reader exited inside that narrow window depended on JVM thread scheduling, so the same test could pass on retry. Joining only indexes below the count returned by enumerate() follows the API contract and removes the race.

Validation:

  • ./gradlew :dd-smoke-tests:test -PtestJvm=11 --tests datadog.smoketest.ErrorLogSmokeTest --tests datadog.smoketest.OutputThreadsTest — 2 passed
  • ./gradlew :dd-smoke-tests:test -PtestJvm=11 — 60 passed
  • ./gradlew :dd-smoke-tests:spotlessJavaCheck — passed

No public API or user-facing behavior changes.

Contributor Checklist

Jira ticket: N/A

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD added type: bug fix Bug fix comp: testing Testing tag: no release notes Changes to exclude from release notes tag: ai generated Largely based on code generated by an AI or LLM labels Sep 10, 2026
@AlexeyKuznetsov-DD

Copy link
Copy Markdown
Contributor Author

@codex review

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD self-assigned this Sep 10, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 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-10T22:14:38.064002Z da93a6f Draft marked ready
🔒 Security Review Completed 2026-09-10T22:15:24.749718Z da93a6f Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: da93a6feec

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

@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD marked this pull request as ready for review September 10, 2026 22:12
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD requested a review from a team as a code owner September 10, 2026 22:12
@AlexeyKuznetsov-DD
AlexeyKuznetsov-DD requested review from dougqh and sarahchen6 and removed request for a team September 10, 2026 22:12

@datadog-official datadog-official 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 teardown loop now uses the count from ThreadGroup.enumerate(). It does not read null array entries when a thread stops during teardown.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@dd-octo-sts

dd-octo-sts Bot commented Sep 10, 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 14.81 s 14.68 s [-0.1%; +1.9%] (no difference)
startup:insecure-bank:tracing:Agent 13.70 s 13.69 s [-0.7%; +0.7%] (no difference)
startup:petclinic:appsec:Agent 17.51 s 17.40 s [-0.1%; +1.4%] (no difference)
startup:petclinic:iast:Agent 17.38 s 17.05 s [-2.8%; +6.7%] (no difference)
startup:petclinic:profiling:Agent 17.11 s 17.43 s [-3.1%; -0.6%] (maybe better)
startup:petclinic:sca:Agent 17.50 s 17.43 s [-0.8%; +1.6%] (no difference)
startup:petclinic:tracing:Agent 16.52 s 16.62 s [-1.4%; +0.3%] (no difference)

Commit: 4d5c7891 · 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.

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

Labels

comp: testing Testing tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants