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 — test(spanner): unflake InlineBeginTransactionTest by sakthivelmanii · Pull Request #14783 · googleapis/google-cloud-java

Conversation

@sakthivelmanii

@sakthivelmanii sakthivelmanii commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

In GrpcResultSet.close(), a previous commit inadvertently moved iterator.close() ahead of listener.onDone(). Cancelling the stream unblocked concurrent reader threads in next() with CANCELLED, triggering yieldError() which completed transactionIdFuture with ABORTED before listener.onDone() could complete it with FAILED_PRECONDITION. This race caused flaky test failures in InlineBeginTransactionTest.

This PR fixes the issue by reordering listener.onDone(withBeginTransaction) before iterator.close(), guaranteeing the future is marked FAILED_PRECONDITION before the stream is cancelled. It also includes a deterministic regression test to ensure the fix is robust.

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
@sakthivelmanii
test(spanner): unflake InlineBeginTransactionTest
0e31d2c
In GrpcResultSet.close(), a previous commit inadvertently moved iterator.close() ahead of listener.onDone(). Cancelling the stream unblocked concurrent reader threads in next() with CANCELLED, triggering yieldError() which completed transactionIdFuture with ABORTED before listener.onDone() could complete it with FAILED_PRECONDITION. This race caused flaky test failures in InlineBeginTransactionTest.

This PR fixes the issue by reordering listener.onDone(withBeginTransaction) before iterator.close(), guaranteeing the future is marked FAILED_PRECONDITION before the stream is cancelled. It also includes a deterministic regression test to ensure the fix is robust.
@sakthivelmanii
sakthivelmanii requested review from a team as code owners October 27, 2026 07:55
@sakthivelmanii
sakthivelmanii enabled auto-merge (squash) October 27, 2026 07:55
@sakthivelmanii

sakthivelmanii commented Oct 27, 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 27, 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 updates GrpcResultSet.close() to notify the listener before closing the iterator, preventing a race condition where a concurrent reader thread fails with a CANCELLED error before the listener is notified. A new unit test has been added to verify this behavior. The review feedback suggests wrapping the listener notification and iterator closing in a try-finally block to ensure the iterator is always closed, even if the listener throws an unexpected exception.

Sorry, something went wrong.

Uh oh!

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

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

Uh oh!

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

gemini-code-assist[bot]
gemini-code-assist Bot reviewed Oct 27, 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 updates GrpcResultSet to notify the listener before closing the iterator, preventing a race condition where concurrent threads blocked in next() might fail with a cancellation error instead of the correct transaction outcome. A corresponding unit test is also added to verify this behavior. The review feedback suggests wrapping the listener notification in a try-finally block to guarantee that the iterator is always closed, and replacing Thread.yield() with Thread.sleep(10) in the test's waiting loop to avoid high CPU utilization and potential test flakiness.

Sorry, something went wrong.

Uh oh!

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

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

Uh oh!

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

Comment thread java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java Resolved

Uh oh!

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

@sakthivelmanii
Addressed comments
717b619
@sakthivelmanii

sakthivelmanii commented Oct 27, 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.

@sakthivelmanii
Addressed comments
3d69249
gemini-code-assist[bot]
gemini-code-assist Bot reviewed Oct 27, 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 modifies GrpcResultSet.close() to notify the listener before cancelling the stream, preventing race conditions with concurrent readers, and adds a corresponding unit test. However, the change accidentally omitted the call to iterator.close(), leaving an empty finally block. This critical issue will cause resource leaks, and the iterator must be closed within the finally block as suggested.

Sorry, something went wrong.

Uh oh!

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

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

Uh oh!

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

@sakthivelmanii

sakthivelmanii commented Oct 27, 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 27, 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 modifies GrpcResultSet.close() to notify the listener before closing the iterator, preventing a race condition where a concurrent thread blocked in next() fails with a CANCELLED error before the listener is notified. A unit test was added to verify this behavior. The review feedback suggests improving the unit test by checking if the reader thread's future is done inside the waiting loop to fail fast if the thread terminates unexpectedly.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java Resolved

Uh oh!

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

@sakthivelmanii
Addressed comments
287394b
@sakthivelmanii

sakthivelmanii commented Oct 27, 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 27, 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 modifies GrpcResultSet.close() to notify the listener before closing the iterator (cancelling the stream) using a try-finally block. This prevents a race condition where a concurrent thread blocked in next() fails with a CANCELLED error before the listener is notified. Additionally, a unit test testCloseNotifiesListenerBeforeCancelErrorFromConcurrentReader has been added to GrpcResultSetTest.java to verify this behavior. I have no feedback to provide.

Sorry, something went wrong.

Uh oh!

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

All reactions
@sakthivelmanii

sakthivelmanii commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #14770.

All reactions

Sorry, something went wrong.

Uh oh!

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

@sakthivelmanii sakthivelmanii closed this Oct 27, 2026
auto-merge was automatically disabled October 27, 2026 09:51

Pull request was closed

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

Reviewers

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.

1 participant

@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.