Skip to content

fix(internal/civisibility): fix orchestrion deadlock with parallel subtests#4554

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
fix/civisibility-orchestrion-parallel-deadlock
Mar 17, 2026
Merged

fix(internal/civisibility): fix orchestrion deadlock with parallel subtests#4554
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits into
mainfrom
fix/civisibility-orchestrion-parallel-deadlock

Conversation

@tonyredondo

@tonyredondo tonyredondo commented Mar 17, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This fixes a CI Visibility deadlock when Orchestrion instruments tests that call t.Parallel() on a parent test and then also call t.Parallel() in subtests.

The fix changes the gotesting Orchestrion advice for testing.T.Parallel() so we ask instrumentTestingParallel to forward the call before the stdlib Parallel() body runs, and return early when Datadog has already handled the handoff on the original wrapped test. That prevents the cloned wrapper test from blocking in its own local Parallel() path while still preserving real Go parallel scheduling.

This PR also adds a real Orchestrion civisibility integration regression that exercises a parallel parent test with parallel subtests, so the YAML-driven toolexec path is covered directly.

Validation run locally:

  • go test ./internal/civisibility/integrations/gotesting -count=1
  • GOWORK=off go test -shuffle=on -toolexec='orchestrion toolexec' ./civisibility

Motivation

This came from the Slack report. The customer reported that with dd-trace-go v2.6.0 and orchestrion v1.6.0, tests using a parent t.Parallel() plus parallel subtests could hang indefinitely under Orchestrion. They were able to reproduce it with a minimal test case and go test -toolexec='orchestrion toolexec' -timeout=30s -v ./....

The failure mode matched our additional-feature wrapper path in gotesting: the wrapper executes the test body on a cloned *testing.T, waits for that cloned execution to finish, and the old Orchestrion Parallel() advice deferred the Datadog forwarding hook until after the local stdlib Parallel() call. Once the cloned test parked in testing.(*T).Parallel(), the forwarding hook never ran soon enough, which created the deadlock.

This PR fixes that timing bug and adds coverage for the exact Orchestrion civisibility path that was reported.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running make lint locally.
  • New code doesn't break existing tests. You can check this by running make test locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • All generated files are up to date. You can check this by running make generate locally.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running make fix-modules locally.

@tonyredondo
tonyredondo requested review from a team as code owners March 17, 2026 15:36
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Mar 17, 2026

Copy link
Copy Markdown

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 59.39% (+3.61%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0fea100 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@pr-commenter

pr-commenter Bot commented Mar 17, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-03-17 16:41:24

Comparing candidate commit 0fea100 in PR branch fix/civisibility-orchestrion-parallel-deadlock with baseline commit 6e49f81 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 156 metrics, 8 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

@tonyredondo
tonyredondo force-pushed the fix/civisibility-orchestrion-parallel-deadlock branch from b689627 to 0fea100 Compare March 17, 2026 16:21
@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.14%. Comparing base (6e49f81) to head (0fea100).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
...egrations/gotesting/instrumentation_orchestrion.go 29.93% <ø> (ø)

... and 430 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit d224c35 into main Mar 17, 2026
91 of 92 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the fix/civisibility-orchestrion-parallel-deadlock branch March 17, 2026 20:42
darccio pushed a commit that referenced this pull request Mar 27, 2026
…btests (#4554)

### What does this PR do?

This fixes a CI Visibility deadlock when Orchestrion instruments tests that call `t.Parallel()` on a parent test and then also call `t.Parallel()` in subtests.

The fix changes the `gotesting` Orchestrion advice for `testing.T.Parallel()` so we ask `instrumentTestingParallel` to forward the call before the stdlib `Parallel()` body runs, and return early when Datadog has already handled the handoff on the original wrapped test. That prevents the cloned wrapper test from blocking in its own local `Parallel()` path while still preserving real Go parallel scheduling.

This PR also adds a real Orchestrion civisibility integration regression that exercises a parallel parent test with parallel subtests, so the YAML-driven `toolexec` path is covered directly.

Validation run locally:
- `go test ./internal/civisibility/integrations/gotesting -count=1`
- `GOWORK=off go test -shuffle=on -toolexec='orchestrion toolexec' ./civisibility`

### Motivation

This came from the Slack report. The customer reported that with `dd-trace-go v2.6.0` and `orchestrion v1.6.0`, tests using a parent `t.Parallel()` plus parallel subtests could hang indefinitely under Orchestrion. They were able to reproduce it with a minimal test case and `go test -toolexec='orchestrion toolexec' -timeout=30s -v ./...`.

The failure mode matched our additional-feature wrapper path in `gotesting`: the wrapper executes the test body on a cloned `*testing.T`, waits for that cloned execution to finish, and the old Orchestrion `Parallel()` advice deferred the Datadog forwarding hook until after the local stdlib `Parallel()` call. Once the cloned test parked in `testing.(*T).Parallel()`, the forwarding hook never ran soon enough, which created the deadlock.

This PR fixes that timing bug and adds coverage for the exact Orchestrion civisibility path that was reported.

### Reviewer's Checklist

- [x] Changed code has unit tests for its functionality at or near 100% coverage.
- [ ] [System-Tests](https://github.com/DataDog/system-tests/) covering this feature have been added and enabled with the va.b.c-dev version tag.
- [ ] There is a benchmark for any new code, or changes to existing code.
- [ ] If this interacts with the agent in a new way, a system test has been added.
- [ ] New code is free of linting errors. You can check this by running `make lint` locally.
- [x] New code doesn't break existing tests. You can check this by running `make test` locally.
- [ ] Add an appropriate team label so this PR gets put in the right place for the release notes.
- [x] All generated files are up to date. You can check this by running `make generate` locally.
- [ ] Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild. Make sure all nested modules are up to date by running `make fix-modules` locally.


Co-authored-by: kemal.akkoyun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants