Skip to content

feat(spanner): support transaction timeout#5518

Open
olavloite wants to merge 10 commits intogoogleapis:mainfrom
olavloite:spanner-transaction-timeout
Open

feat(spanner): support transaction timeout#5518
olavloite wants to merge 10 commits intogoogleapis:mainfrom
olavloite:spanner-transaction-timeout

Conversation

@olavloite
Copy link
Copy Markdown
Contributor

Adds support for setting a total timeout for a transaction. The timeout is applied to
each RPC in the transaction, and 'ticks down' as time passes. If the transaction does
not finish within the total timeout, it will fail with a DEADLINE_EXCEEDED error.

Note that the timeout is NOT applied to the Rollback RPC, to allow a TransactionRunner
or an application to rollback the transaction after a timeout error.

Depends on #5517

Adds support for setting a timeout, retry policy, and backoff policy per statement and read.
This allows an application to override the defaults for these options on a per statement-basis.

Note: This change adds the API for all types of statements. However, the retry and backoff policies
are not respected for the streaming RPCs ExecuteStreamingSql and StreamingRead yet. This will be
added in a follow-up pull request.
…treaming RPCs

Add support for custom timeouts, retry policies, and backoff policies for streaming RPCs
that return a ResultSet. This also refactors ResultSet to store its internal defaults as
a RetryPolicy and BackoffPolicy, instead of hardcoded custom values.
Adds support for setting a timeout, retry policy, and backoff policy per statement and read.
This allows an application to override the defaults for these options on a per statement-basis.

Note: This change adds the API for all types of statements. However, the retry and backoff policies
are not respected for the streaming RPCs ExecuteStreamingSql and StreamingRead yet. This will be
added in a follow-up pull request.
Adds support for setting an attempt timeout and a retry- and backoff policy for
a partition in a BatchReadOnlyTransaction. These settings are not serialized,
which means that any host that wants to apply any of these settings to its
execution of a partition must set these explicitly.
Adds support for setting a total timeout for a transaction. The timeout is applied to
each RPC in the transaction, and 'ticks down' as time passes. If the transaction does
not finish within the total timeout, it will fail with a DEADLINE_EXCEEDED error.

Note that the timeout is NOT applied to the Rollback RPC, to allow a TransactionRunner
or an application to rollback the transaction after a timeout error.
@olavloite olavloite requested review from a team as code owners April 24, 2026 13:14
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Apr 24, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 93.51670% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.71%. Comparing base (9f194b9) to head (223cf25).

Files with missing lines Patch % Lines
src/spanner/src/read_write_transaction.rs 84.72% 11 Missing ⚠️
src/spanner/src/batch_read_only_transaction.rs 88.73% 8 Missing ⚠️
src/spanner/src/client.rs 97.08% 6 Missing ⚠️
src/spanner/src/result_set.rs 97.29% 4 Missing ⚠️
src/spanner/src/statement.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5518      +/-   ##
==========================================
- Coverage   97.75%   97.71%   -0.05%     
==========================================
  Files         218      218              
  Lines       49498    49971     +473     
==========================================
+ Hits        48389    48829     +440     
- Misses       1109     1142      +33     

☔ 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: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant