Skip to content

fix(spanner): do not execute queued queries on ended transactions - #9305

Merged
olavloite merged 1 commit into
mainfrom
spanner-skip-queries-on-ended-tx
Sep 14, 2026
Merged

olavloite merged 1 commit into
mainfrom
spanner-skip-queries-on-ended-tx

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

When multiple queries run concurrently on an unbegun read-write transaction, subsequent queries are queued while the first query executes with an inline begin.

If the transaction ends or aborts before an inline transaction ID is established, queued queries should be discarded. Calling _releaseWaitingRequests() during end() mistakenly executed those waiting requests against Spanner on an already ended transaction. This removes that call from end() and clears the queue.

@olavloite
olavloite requested a review from a team as a code owner September 12, 2026 15:39
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Sep 12, 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 modifies how waiting requests are handled when a transaction ends by directly clearing the _waitingRequests array, and adds a corresponding test. However, simply clearing the array causes queued queries to hang indefinitely because their callbacks or promises are never resolved or rejected. The feedback recommends iterating through the queued requests and failing them with an appropriate error, and updating the test to assert that the callback for the discarded query is invoked with an error.

Comment thread handwritten/spanner/src/transaction.ts Outdated
Comment thread handwritten/spanner/test/transaction.ts Outdated
When multiple queries run concurrently on an unbegun read-write transaction,
subsequent queries are queued while the first query executes with an inline begin.

If the transaction ends or aborts before an inline transaction ID is established,
queued queries should be discarded. Calling _releaseWaitingRequests() during end()
mistakenly executed those waiting requests against Spanner on an already ended
transaction. This removes that call from end() and clears the queue.
@olavloite
olavloite force-pushed the spanner-skip-queries-on-ended-tx branch from 632f230 to b81bf68 Compare September 14, 2026 13:29
@olavloite
olavloite merged commit f74f198 into main Sep 14, 2026
50 checks passed
@olavloite
olavloite deleted the spanner-skip-queries-on-ended-tx branch September 14, 2026 13:57
danieljbruce pushed a commit that referenced this pull request Sep 14, 2026
🤖 I have created a release *beep* *boop*
---


##
[8.13.0](spanner-v8.12.0...spanner-v8.13.0)
(2026-09-14)


### Features

* PNPM workspace
([#8973](#8973))
([1ea27c9](1ea27c9))


### Bug Fixes

* **spanner:** Do not execute queued queries on ended transactions
([#9305](#9305))
([f74f198](f74f198))


### Performance Improvements

* **spanner:** Avoid cloning metadata map in metrics interceptor
([#9307](#9307))
([6eec761](6eec761))
* **spanner:** Avoid redundant clock reads in isGlobalTracingEnabled
([#9311](#9311))
([c42f144](c42f144))
* **spanner:** Bypass stream pipeline for single-chunk query results
([#9279](#9279))
([e46a407](e46a407))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
thiyaguk09 pushed a commit to thiyaguk09/google-cloud-node-fork that referenced this pull request Sep 15, 2026
🤖 I have created a release *beep* *boop*
---


##
[8.13.0](googleapis/google-cloud-node@spanner-v8.12.0...spanner-v8.13.0)
(2026-09-14)


### Features

* PNPM workspace
([googleapis#8973](googleapis#8973))
([1ea27c9](googleapis@1ea27c9))


### Bug Fixes

* **spanner:** Do not execute queued queries on ended transactions
([googleapis#9305](googleapis#9305))
([f74f198](googleapis@f74f198))


### Performance Improvements

* **spanner:** Avoid cloning metadata map in metrics interceptor
([googleapis#9307](googleapis#9307))
([6eec761](googleapis@6eec761))
* **spanner:** Avoid redundant clock reads in isGlobalTracingEnabled
([googleapis#9311](googleapis#9311))
([c42f144](googleapis@c42f144))
* **spanner:** Bypass stream pipeline for single-chunk query results
([googleapis#9279](googleapis#9279))
([e46a407](googleapis@e46a407))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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.

2 participants