Skip to content

fix(storage): Set the idempotency token in the implementation of async rewrites#16114

Open
kalragauri wants to merge 1 commit into
googleapis:mainfrom
kalragauri:feature/token-audit
Open

fix(storage): Set the idempotency token in the implementation of async rewrites#16114
kalragauri wants to merge 1 commit into
googleapis:mainfrom
kalragauri:feature/token-audit

Conversation

@kalragauri
Copy link
Copy Markdown
Contributor

@kalragauri kalragauri commented May 26, 2026

In the current implementation, during copy/move operations, if the final step commits on GCS but the client times out, AsyncRetryLoop will automatically retry. GCS will reject the retry as invalid since the session is closed and the rewrite_token is already consumed.

This PR includes an InvocationIdGenerator in RewriterConnectionImpl to generate the token once per Iterate() step, and map it into the ClientContext for all retries of that step.

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label May 26, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the generation and reuse of an idempotency token during asynchronous rewrite retries in RewriterConnectionImpl. It adds an InvocationIdGenerator member, captures the generated ID in the retry loop lambda, and includes a unit test to verify that the token is reused across retries. The feedback suggests moving the generated ID into the lambda capture using std::move to avoid an unnecessary string copy.

Comment thread google/cloud/storage/internal/async/rewriter_connection_impl.cc Outdated
@kalragauri kalragauri force-pushed the feature/token-audit branch from 247e403 to 9d9455f Compare May 26, 2026 08:32
@kalragauri kalragauri force-pushed the feature/token-audit branch from 9d9455f to 7e7fcd1 Compare May 26, 2026 08:37
@kalragauri kalragauri marked this pull request as ready for review May 26, 2026 08:38
@kalragauri kalragauri requested review from a team as code owners May 26, 2026 08:38
@kalragauri kalragauri requested a review from v-pratap May 26, 2026 08:38
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.71%. Comparing base (a899f46) to head (7e7fcd1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16114      +/-   ##
==========================================
- Coverage   92.71%   92.71%   -0.01%     
==========================================
  Files        2353     2353              
  Lines      218986   219029      +43     
==========================================
+ Hits       203031   203066      +35     
- Misses      15955    15963       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant