GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(spanner): unify streaming read and query startup by olavloite · Pull Request #14776 · googleapis/google-cloud-java

Conversation

@olavloite

@olavloite olavloite commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Streaming SQL queries and streaming key-value reads previously duplicated the same request setup and stream startup logic in two separate code paths. This change unifies both operations behind a single internal request abstraction so that option configuration, retry settings, and stream lifecycle handling are maintained in one place.

As part of unifying stream startup, this also hardens how inlined BeginTransaction state is tracked across the stream lifecycle:

  • Records whether a request carries an inlined BeginTransaction on the request itself and passes it to the stream iterator at construction time rather than when the gRPC call is attached, keeping the state available across retry backoffs while ensuring it is cleared once the iterator is closed.
  • Ensures that if starting an inlined-begin stream fails before the stream can be consumed, the pending transaction ID future is failed immediately with a consistent exception so concurrent callers on the same transaction do not wait for a timeout.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction
@olavloite
olavloite requested review from a team as code owners October 26, 2026 09:35
gemini-code-assist[bot]
gemini-code-assist Bot reviewed Oct 26, 2026
View reviewed changes

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

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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 a new package-private abstraction ReadOrQueryRequest (with Query and Read subclasses) to/unify common request options, streaming request preparation, and execution within AbstractReadContext. It refactors stream-start error handling and transaction selector management, particularly for inlined BeginTransaction options, ensuring that failures during initial statements are correctly propagated and handled without hanging. Additionally, it updates the GrpcStreamIterator and TransactionRunnerImpl classes to support these changes and adds extensive unit tests covering stream retries, start failures, and concurrency scenarios. There are no review comments to address, and I have no feedback to provide.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@olavloite
refactor(spanner): unify streaming read and query startup
393f3b2
Streaming SQL queries and streaming key-value reads previously duplicated the
same request setup and stream startup logic in two separate code paths. This
change unifies both operations behind a single internal request abstraction so
that option configuration, retry settings, and stream lifecycle handling are
maintained in one place.

As part of unifying stream startup, this also hardens how inlined
BeginTransaction state is tracked across the stream lifecycle:

- Records whether a request carries an inlined BeginTransaction on the request
  itself and passes it to the stream iterator at construction time rather than
  when the gRPC call is attached, keeping the state available across retry
  backoffs while ensuring it is cleared once the iterator is closed.
- Ensures that if starting an inlined-begin stream fails before the stream can
  be consumed, the pending transaction ID future is failed immediately with a
  consistent exception so concurrent callers on the same transaction do not
  wait for a timeout.
@olavloite
olavloite force-pushed the spanner-unify-query-and-read-startup branch from 8249a04 to 393f3b2 Compare October 26, 2026 10:02
olavloite
olavloite commented Oct 26, 2026
View reviewed changes
Comment thread ...spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java
ExecuteSqlRequest.newBuilder()
.setSql(statement.getSql())
.setQueryMode(queryMode)
.setSession(session.getName());

@olavloite olavloite Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

All options that are common for Read and Query have been moved into ReadOrQueryRequest, and are therefore removed here to reduce code duplication.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@olavloite

olavloite commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

gemini-code-assist[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gemini-code-assist[bot]
gemini-code-assist Bot reviewed Oct 26, 2026
View reviewed changes

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

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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 a new package-private abstraction, ReadOrQueryRequest, to unify the preparation and execution of read and query requests within AbstractReadContext. It refactors the streaming result set creation to utilize this unified request model, simplifying the codebase and improving consistency. Additionally, error handling and propagation for inlined begin transactions are enhanced in TransactionRunnerImpl and GrpcStreamIterator, backed by comprehensive new test cases. Feedback on the changes suggests a minor improvement in TransactionRunnerImpl.java to check exception.getErrorCode() == ErrorCode.ABORTED instead of using instanceof AbortedException for better robustness and consistency with the rest of the SDK.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...anner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@olavloite
olavloite requested a review from sakthivelmanii October 26, 2026 10:17
@olavloite
Merge branch 'main' into spanner-unify-query-and-read-startup
75e9e60
sakthivelmanii
sakthivelmanii approved these changes Nov 2, 2026
View reviewed changes
@olavloite
olavloite merged commit 48e1c30 into main Nov 2, 2026
203 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@olavloite
olavloite deleted the spanner-unify-query-and-read-startup branch November 2, 2026 08:51
@olavloite olavloite mentioned this pull request Nov 2, 2026
fix(spanner): restore setCall overload for stream test compatibility #14885
Merged
sakthivelmanii pushed a commit that referenced this pull request Nov 2, 2026
@olavloite
fix(spanner): restore setCall overload for stream test compatibility (#…
cfe728e
…14885)

Merging PR #14770 and PR #14776 concurrently broke the build on main.
One PR added unit tests that configure mock streams using a two-argument
setCall method to indicate whether a transaction is inlined, while the
other PR removed that parameter because production code now configures
this during stream construction.

This change restores the two-argument setCall method for testing and
keeps the inlined transaction state configurable during test setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sakthivelmanii sakthivelmanii sakthivelmanii approved these changes
+1 more reviewer
@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@olavloite @sakthivelmanii
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.