Skip to content

Support proper async propagation for GAX retrying futures#11629

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
andrea.marziali/gax
Jun 15, 2026
Merged

Support proper async propagation for GAX retrying futures#11629
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
masterfrom
andrea.marziali/gax

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

This PR is a result of investigating why the PubSub instrumentation was leaking continuation.
It appeared that we have futures that are retriable and in fact the guava-concurrent was capturing continuations on those futures as soon as a listener was set.
Now, for retriable futures, gax retry calls setAttemptFuture twice per attempt:

  • first with a NonCancellableFuture placeholder (never completed)
  • then the real RPC future.

The guava AbstractFuture.addListener instrumentation captures a trace continuation on each attempt-completion listener. The placeholder's listener never runs and its continuation is never resolved

In this PR we introduce a new module to deal with those gax specific futures. Since there are no signals to hook on to know if the first future will be run or not, we just simply cancel the previously taken continuation when the second is captured.
In any case the first continuation won't be run when the second fire so the fix seems safe to me.

That approach also solves continuation leakage issues in the pubsub instrumentation so that the strictTraceWrites hack is now removed

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: feature Enhancements and improvements inst: others All other instrumentations tag: concurrency Virtual Threads, Coroutines, Async, RX, Executors labels Jun 11, 2026
@datadog-datadog-prod-us1

This comment has been minimized.

@amarziali amarziali force-pushed the andrea.marziali/gax branch from ebd0563 to 87e342a Compare June 11, 2026 15:52
@dd-octo-sts

dd-octo-sts Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

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 14.90 s 14.75 s [+0.2%; +1.9%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.61 s 13.64 s [-0.9%; +0.6%] (no difference)
startup:petclinic:appsec:Agent 16.78 s 16.54 s [+0.6%; +2.4%] (maybe worse)
startup:petclinic:iast:Agent 16.75 s 16.87 s [-1.6%; +0.2%] (no difference)
startup:petclinic:profiling:Agent 16.66 s 16.27 s [-2.3%; +7.0%] (no difference)
startup:petclinic:sca:Agent 16.84 s 16.62 s [+0.2%; +2.3%] (maybe worse)
startup:petclinic:tracing:Agent 15.99 s 16.06 s [-1.3%; +0.4%] (no difference)

Commit: 131db177 · 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.

@amarziali amarziali marked this pull request as ready for review June 11, 2026 16:45
@amarziali amarziali requested review from a team as code owners June 11, 2026 16:45
@amarziali amarziali requested review from dougqh, jordan-wong and mcculls and removed request for a team June 11, 2026 16:45

@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: 87e342a9e4

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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 2a14af2047

ℹ️ 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 amarziali requested a review from PerfectSlayer June 12, 2026 11:32

@PerfectSlayer PerfectSlayer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the follow up changes

@amarziali

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 15, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-15 09:49:09 UTC ℹ️ Start processing command /merge


2026-06-15 09:49:14 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-06-15 10:49:11 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 9b642bd into master Jun 15, 2026
573 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the andrea.marziali/gax branch June 15, 2026 10:49
@github-actions github-actions Bot added this to the 1.64.0 milestone Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: others All other instrumentations tag: concurrency Virtual Threads, Coroutines, Async, RX, Executors type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants