Skip to content

chore(spanner): bound streaming server retry delays and fall back on non-positive values - #15074

Open
sakthivelmanii wants to merge 2 commits into
mainfrom
chore/spanner-streaming-retry-delay-bounds
Open

sakthivelmanii wants to merge 2 commits into
mainfrom
chore/spanner-streaming-retry-delay-bounds

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Sanitize server-supplied RetryInfo delays when resuming interrupted Cloud Spanner streaming reads and queries so zero, negative, or oversized retry trailers cannot trigger zero-delay retry spin loops or stall consumer threads for hours.

  • Fall back to exponential backoff (>= 1 ms) when a server retry delay is zero, sub-millisecond, or negative instead of retrying immediately without sleeping.
  • Cap positive server retry delays at the configured maximum retry delay on streaming retry settings (defaulting to 1000 ms when unset or non-positive) before evaluating the remaining total timeout budget.
  • Use the same 1000 ms ceiling for client-side exponential backoff when maximum retry delay is unset on streaming retry settings.

…non-positive values

Sanitize server-supplied RetryInfo delays when resuming interrupted Cloud Spanner streaming reads and queries so zero, negative, or oversized retry trailers cannot trigger zero-delay retry spin loops or stall consumer threads for hours.

- Fall back to exponential backoff (>= 1 ms) when a server retry delay is zero, sub-millisecond, or negative instead of retrying immediately without sleeping.
- Cap positive server retry delays at the configured maximum retry delay on streaming retry settings (defaulting to 1000 ms when unset or non-positive) before evaluating the remaining total timeout budget.
- Use the same 1000 ms ceiling for client-side exponential backoff when maximum retry delay is unset on streaming retry settings.
@sakthivelmanii
sakthivelmanii requested review from a team as code owners November 18, 2026 22:28
@sakthivelmanii sakthivelmanii self-assigned this Nov 18, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates ResumableStreamIterator to improve the handling of server-supplied retry delays and backoff configurations. Positive server-supplied retry delays are now capped at the configured maximum retry delay (defaulting to 1000ms if unset or non-positive), while missing, zero, or negative delays correctly fall back to exponential backoff. It also introduces robust handling for sub-millisecond durations and potential arithmetic overflows when converting durations to milliseconds. Comprehensive unit tests have been added to verify these edge cases. I have no feedback to provide as there are no review comments.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant