Prevent Pekko stream lifecycle context retention - #12470
Conversation
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.
More details
The exact Pekko stream-stage matcher applies existing async propagation control only during preStart. The advice restores propagation after each exit.
🤖 Datadog Autotest · Commit 9c27dfe · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
|
🎯 Code Coverage (details) 🔗 Commit SHA: 9c27dfe | Docs | View more details | Give us feedback! |
🟢 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. |
What Does This Do
Pekko HTTP registers a shutdown callback from StreamUtils.preStart(). When this happens during a request, Scala’s callback instrumentation captures the active context and retains it until the stream shuts down.
This change temporarily disables async propagation only while that callback is registered. It uses the existing context-tracking instrumentation, without creating a no-op span or affecting the active request
context.
flowchart LR A[Active request context] --> B[StreamUtils.preStart] B -->|async propagation disabled| C[Register shutdown callback] C --> D[Restore async propagation] A -. not captured .-> CWhy?
The shutdown callback belongs to the stream lifecycle, not to the request that happened to initialize it. Propagating the request context there creates a continuation that can remain unresolved until server
shutdown.
The matcher is limited to the exact Pekko stream-stage type and its preStart() method.
Akka
Akka has similar code, but its equivalent IAST scenario does not retain a continuation. Tests passed with Akka HTTP 10.1, 10.2, and the latest supported dependencies, so no speculative Akka suppression was added.
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]