Skip to content

Fine tune async propagation for lettuce 5#11607

Open
amarziali wants to merge 2 commits into
masterfrom
andrea.marziali/lettuce-5-async-prop
Open

Fine tune async propagation for lettuce 5#11607
amarziali wants to merge 2 commits into
masterfrom
andrea.marziali/lettuce-5-async-prop

Conversation

@amarziali

@amarziali amarziali commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

This PR blocks async propagations around few boundaries in lettuce. Previously, the latestDepTest had a strictTraceWrites set to false since continuations were leaked from few places. Hence:

  • Stop activating the Lettuce connect span while Lettuce builds the connection future.
  • Disable async propagation while dispatching commands that do not expect a response, such as SHUTDOWN.
  • Disable async propagation while registering our own span-finishing callback.
  • Suppress async propagation inside onComplete so Lettuce internal completable future callbacks are not captured

I've tried to mutually exclude fixes in order to have the minimal changes applied to the propagation

Motivation

Additional Notes

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added type: bug Bug report and fix inst: lettuce Lettuce instrumentation labels Jun 9, 2026
@datadog-prod-us1-5

This comment has been minimized.

@amarziali amarziali marked this pull request as ready for review June 9, 2026 21:56
@amarziali amarziali requested a review from a team as a code owner June 9, 2026 21:56
@amarziali amarziali requested review from vandonr and removed request for a team June 9, 2026 21:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review


P2 Badge Disable propagation for connect callbacks

When connect/connectAsync is called while an application span is active, this whenComplete registration now runs with the connect span no longer active but with async propagation still enabled. Since ConnectionFuture is a completable future, the java-concurrent instrumentation can capture the caller's active span for this Datadog-internal completion callback, keeping that continuation alive until the connection attempt completes and reactivating it just to finish the connect span; slow or failed connects can therefore leak/delay the caller trace. The command path added a propagation guard around its own whenComplete, and the connect path needs the same guard here.

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

@amarziali

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfcbd9b949

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

isMethod().and(namedOneOf("complete", "completeExceptionally", "encode")),
getClass().getName() + "$Activate");
transformer.applyAdvice(
isMethod().and(named("onComplete")), getClass().getName() + "$SuppressAsyncPropagation");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve propagation for user onComplete callbacks

This matcher now applies to every AsyncCommand.onComplete invocation, not just Lettuce's internal registrations. When application code registers a completion callback under an active request span via onComplete, the new advice disables async propagation while onComplete delegates to the underlying CompletableFuture, so that callback and any async work it schedules are no longer linked to the request/Redis trace; previously this path was covered by Activate and propagated the command context. Please narrow the suppression to the internal registration path or keep user-visible onComplete callbacks propagating.

Useful? React with 👍 / 👎.

@dd-octo-sts

dd-octo-sts Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🟡 Java Benchmark SLOs — Performance SLO warning (near threshold)

Suite Status
Startup 🟡 warning

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 13.94 s 13.97 s [-1.3%; +0.9%] (no difference)
startup:insecure-bank:tracing:Agent 12.89 s 13.00 s [-1.6%; -0.1%] (maybe better)
startup:petclinic:appsec:Agent 17.61 s 17.35 s [+0.2%; +2.7%] (maybe worse)
startup:petclinic:iast:Agent 17.47 s 17.42 s [-0.7%; +1.3%] (no difference)
startup:petclinic:profiling:Agent 17.62 s 17.52 s [-0.8%; +1.8%] (no difference)
startup:petclinic:sca:Agent 17.50 s 17.45 s [-0.7%; +1.2%] (no difference)
startup:petclinic:tracing:Agent 16.66 s 16.53 s [-0.6%; +2.1%] (no difference)

Commit: bfcbd9b9 · 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

inst: lettuce Lettuce instrumentation type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant