Repository navigation
Fix Kotlin coroutine context isolation and continuation ownership - #12914
gh-worker-dd-mergequeue-cf854d[bot] merged 7 commits into
Conversation
Extract the Kotlin fixes and independent regression tests from PR #12864. Give builder-created coroutines fresh context elements while preserving context element order. Only release an element's continuation when its owning coroutine completes, including children of already-cancelled jobs. Skip redundant trace continuations for eligible structured children. Keep the existing context capture and swap/restore behavior. Parent live stack seeding, shared scope stacks, AgentTracer/CoreTracer/scope-manager changes, and the handoff tests requiring them are deliberately excluded. Include context replacement and trace-lifetime regressions, run the latest dependency suite on kotlinx-coroutines 1.8, and regenerate the module lockfile. Source: #12864 Validation: test and latestDepTest on JDK 17 (276 tests per run), with both legacy and non-legacy context managers; module spotlessCheck.
Add coroutines16Test and coroutines18Test suites pinned to 1.6.4 and 1.8.1, reusing the existing latest-dependency test sources and shared fixtures. Keep the minimum-version suite on 1.3.0 and advance latestDepTest to 1.+, currently locked to 1.11.0. Give the flow builders explicit Int element types so the shared tests compile with the newer dependency using the existing Kotlin compiler. Regenerate the module dependency lockfile for all suites. Validation: all four suites on JDK 17 with both legacy and non-legacy context managers (562 tests per matrix); module spotlessCheck.
Identify the trace held open by a coroutine or its parent using the local root AgentSpan rather than AgentTraceCollector. Compare local root span identity when deciding whether a structured child needs its own trace continuation, and rename the ownership fields and helper accordingly. Validation: all four coroutine version suites on JDK 17 with legacy and non-legacy context managers (562 tests per matrix); module spotlessCheck.
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Build pipeline has failing jobs for 726ca5e: What to do next?
DetailsSince those jobs are not marked as being allowed to fail, the pipeline will most likely fail. |
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
stuart.mcculloch@datadoghq.com cancelled this merge request build |
|
/merge --cancel |
|
View all feedbacks in Devflow UI.
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What Does This Do
Fix Kotlin coroutine context isolation and trace-continuation ownership:
Add regression coverage for context replacement, callback order, and trace lifetimes. Reuse the flow and lifecycle tests across coroutines 1.6.4, 1.8.1, and the latest 1.x release (locked to 1.11.0), alongside the minimum-version suite on 1.3.0. Regenerate the module lockfile.
Motivation
Reusing a parent's context element can mix independent coroutine state, while completing a scoped coroutine can release the parent's continuation too early. These fixes preserve context isolation and keep traces open until their coroutine work finishes.
Additional Notes
Extracted from #12864. This PR retains the existing context capture and swap/restore behavior; the shared scope-stack implementation and AgentTracer/CoreTracer/scope-manager changes remain in PR #12864.
Validation on JDK 17:
spotlessCheckpass.