Repository navigation
Conversation
|
@DataDog review |
There was a problem hiding this comment.
On kotlinx-coroutines 1.8, SelectBuilderImpl no longer implements Continuation, so Byte Buddy rejects the typed @Advice.This binding at transformation time before any runtime suppression can apply. The fix is to bind the receiver as Object and add a Continuation instanceof guard, letting modern select builders delegate to the already-instrumented CancellableContinuationImpl.
🤖 Bits Code Review · Commit a9bcd5c · @DataDog review to ask questions
🟢 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. |
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
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. |
There was a problem hiding this comment.
Two distinct issues are flagged: the CAS restoration guard in DatadogThreadContextElement cannot distinguish legitimate nested restorations from stale concurrent ones, risking lost manual scopes and mis-parented spans; and the method-name matcher in SuspensionInstrumentation does not cover the Kotlin-mangled getResult$kotlinx_coroutines_core variant introduced in coroutines 1.8, causing the wrong scope to be restored when a dispatcher switch follows an inline suspension.
🤖 Bits Code Review · Commit c46d067 · @DataDog review to ask questions
|
@DataDog review |
There was a problem hiding this comment.
Two distinct production bugs are flagged in DatadogThreadContextElement.java: clearing originalContext after the first restoration causes a NullPointerException when Kotlin 1.8's UndispatchedCoroutine attempts a second restoration via the same token; and a dispatch-ordering race allows the destination coroutine to claim element.exchange before the source records its manual scope, silently losing span parentage and producing stale context on resumption.
🤖 Bits Code Review · Commit c365c5d · @DataDog review to ask questions
|
@DataDog review |
There was a problem hiding this comment.
A synchronous suspendCoroutine call can leave a snapshot of a scope that subsequently closes. If a later coroutineScope child completes before source restoration, the resumed coroutine reactivates that closed scope and subsequent spans inherit the wrong parent.
🤖 Bits Code Review · Commit a40328e · @DataDog review to ask questions
|
@DataDog review |
There was a problem hiding this comment.
More details
Static analysis of exchange ownership, nested restoration, and suspension hooks supports the scope-stack handoff change. Runtime behavior remains unverified because tests were not executed.
🤖 Bits Code Review · Commit 2c6da9f · @DataDog review to ask questions
Dismissing stale review - reminder to myself to re-review the latest changes
|
#12864 describes an alternative approach, which requires more changes to the legacy scope manager but avoids having to continually take snapshots at suspension points. |
@mcculls yes your approach looks very interesting and I think can superseed this proposal. I'm drafting this PR while we're assessing the other approach so. thanks for having tested this alternative |
What Does This Do
A Kotlin coroutine can resume on another worker before the previous worker restores its thread context, losing a manually opened scope and leaving it unclosed.
Capture the scope stack before standard suspension and yield decisions, and prevent an older restoration from overwriting newer context. Enable instrumentation of
SafeContinuationwith a narrow allow-list exception.Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]