Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to coordinate concurrent requests beginning a transaction in the Spanner client by adding a _wait_for_transaction_begin method and an event-based synchronization mechanism to prevent race conditions. It also updates the cross-sync generation script to use ruff for formatting generated artifacts and includes various documentation and cleanup improvements across the package. I have no feedback to provide on this pull request.
snapshot.py is generated from _async/snapshot.py, but the generated file had picked up code the async source never had. Running the generator deleted it. The drift came in via 25aba4f (PR #16488): a branch authored before the CrossSync migration but merged after it, so it edited snapshot.py as if that file were still hand-maintained. Fixes: - Port the _transaction_begin_event guard and the read()/execute_sql() docstrings back into _async/snapshot.py, so the generator reproduces them instead of dropping them. - Use CrossSync.Lock / CrossSync.Event instead of raw threading, so the primitives survive the async -> sync conversion. - De-duplicate the guard: read() and execute_sql() had identical copies, now one _wait_for_transaction_begin() helper. - Async fix: read()/execute_sql() raised "Transaction has not begun." when a concurrent inline begin was in flight. They now wait for it, matching the sync client. - generate.py: format with ruff instead of black. The repo uses ruff, so every run produced a formatting-only diff. - generate.py: exit non-zero when given a file instead of a directory. It used to print "Generated 0 artifacts" and do nothing, which is how the drift went unnoticed. - Delete snapshot_helpers.py, an orphaned generated file with a stale copy of execute_sql that nothing imports. - Add tests for the guard, which had none. - Speed up 4 tests that each waited out the real 30s begin timeout. They passed, just slowly; two were already slow on main. They now patch the timeout constant and assert the specific error message. Unit suite: 204s -> 57s. Regenerating now leaves the tree unchanged: PYTHONPATH=.cross_sync python3 .cross_sync/generate.py \ google/cloud/spanner_v1/_async/ git diff --exit-code google/cloud/spanner_v1/
olavloite
force-pushed
the
spanner-restore-cross-sync-parity
branch
from
September 15, 2026 15:36
27f2404 to
e4797f5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
snapshot.py is generated from _async/snapshot.py, but the generated file had picked up code the async source never had. Running the generator deleted it. The drift came in via 25aba4f (PR #16488): a branch authored before the CrossSync migration but merged after it, so it edited snapshot.py as if that file were still hand-maintained.
Fixes:
Regenerating now leaves the tree unchanged:
PYTHONPATH=.cross_sync python3 .cross_sync/generate.py \ google/cloud/spanner_v1/_async/ git diff --exit-code google/cloud/spanner_v1/