[do not merge]: Dry run for packages/google-cloud-spanner migration#16058
[do not merge]: Dry run for packages/google-cloud-spanner migration#16058
Conversation
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: surbhigarg92 <surbhigarg.92@gmail.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* fix: fix to reload table * changes * lint
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* docs: Minor formatting chore: Update gapic-generator-python to v1.11.5 build: Update rules_python to 0.24.0 PiperOrigin-RevId: 563436317 Source-Link: googleapis/googleapis@42fd37b Source-Link: googleapis/googleapis-gen@280264c Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjgwMjY0Y2EwMmZiOTMxNmI0MjM3YTk2ZDBhZjFhMjM0M2E4MWE1NiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@dede53f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:fac304457974bb530cc5396abd4ab25d26a469cd3bc97cbfb18c8d4324c584eb Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* feat: add BatchWrite API PiperOrigin-RevId: 567412157 Source-Link: googleapis/googleapis@64fd42c Source-Link: googleapis/googleapis-gen@9e53103 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWU1MzEwM2ZmM2MwNmFmOTRlNTgzYWY3YmFhM2M3ZmNhZmU3ODMyMiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
…1020) Source-Link: googleapis/synthtool@0c7b033 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:08e34975760f002746b1d8c86fdc90660be45945ee6d9db914d1508acdf9a547 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* feat(spanner): add autoscaling config to the instance proto PiperOrigin-RevId: 573098210 Source-Link: googleapis/googleapis@d6467db Source-Link: googleapis/googleapis-gen@9ea8b73 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWVhOGI3MzQ1ZWYyZDkzYTQ5YjE1YTMzMmE2ODJhNjE3MTRmMDczZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* changes * adding tests * comment changes
Source-Link: googleapis/synthtool@d52e638 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:4f9b3b106ad0beafc2c8a415e3f62c1a0cc23cabea115dbe841b848f581cfe99 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore: Update gapic-generator-python to v1.11.7 PiperOrigin-RevId: 573230664 Source-Link: googleapis/googleapis@93beed3 Source-Link: googleapis/googleapis-gen@f4a4eda Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjRhNGVkYWE4MDU3NjM5ZmNmNmFkZjkxNzk4NzIyODBkMWE4ZjY1MSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to v1.11.8 PiperOrigin-RevId: 574178735 Source-Link: googleapis/googleapis@7307199 Source-Link: googleapis/googleapis-gen@ce3af21 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2UzYWYyMWI3YzU1OWE4N2MyYmVmYzA3NmJlMGUzYWVkYTNhMjZmMCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to v1.11.9 PiperOrigin-RevId: 574520922 Source-Link: googleapis/googleapis@5183984 Source-Link: googleapis/googleapis-gen@a59af19 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTU5YWYxOWQ0YWM2NTA5ZmFlZGYxY2MzOTAyOTE0MWI2YTViODk2OCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: add PG.OID type cod annotation PiperOrigin-RevId: 577053414 Source-Link: googleapis/googleapis@727c286 Source-Link: googleapis/googleapis-gen@2015275 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjAxNTI3NWE3ZGRhMmFkM2QxNjA5ZjA2YzQyMDgxMjVjN2RlOGE5ZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * remove obsolete rst files --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* feat(spanner): add directed_read_option in spanner.proto docs(spanner): updated comment formatting PiperOrigin-RevId: 578551679 Source-Link: googleapis/googleapis@7c80b96 Source-Link: googleapis/googleapis-gen@7b1172b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiN2IxMTcyYmE1ZTAyMGVhZWY3ZGU3NTA2MmE1NzZhMTFiOGUxMTdlNCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@bc07fd4 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:30470597773378105e239b59fce8eb27cc97375580d592699206d17d117143d0 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@febaccc Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:caffe0a9277daeccc4d1de5c9b55ebba0901b57c2f713ec9c876b0d4ec064f61 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…tion (#1032) * Executing existing DDL statements on executemany statement execution * Fixing test * Added more tests and resolved comments * Fixing test * Resolved comments
…mit) (#1037) * Implementing client side statement in dbapi starting with commit * Fixing comments * Adding dependency on "deprecated" package * Fix in setup.py * Fixing tests * Lint issue fix * Resolving comments * Fixing formatting issue
* chore: Update gapic-generator-python to v1.12.0 PiperOrigin-RevId: 586356061 Source-Link: googleapis/googleapis@72a1f55 Source-Link: googleapis/googleapis-gen@558a04b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTU4YTA0YmNkMWNjMDU3NmU4ZmFjMTA4OWU0OGU0OGIyN2FjMTYxYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: Update gapic-generator-python to v1.13.0 PiperOrigin-RevId: 586460538 Source-Link: googleapis/googleapis@44582d0 Source-Link: googleapis/googleapis-gen@5e7073c Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWU3MDczYzlkZTg0NzkyOWM0YWU5N2Y4YTQ0NGMzZmNhMmQ0NWE2YiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: added Generator API docs: updated doc for speech mode PiperOrigin-RevId: 586469693 Source-Link: googleapis/googleapis@e8148d6 Source-Link: googleapis/googleapis-gen@85136bd Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODUxMzZiZDA0MzgzZWQ3MTcyYmIxOGI3YjhkMjIwZGQ3ZmY2YjNhMCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* chore(python): Add Python 3.12 Source-Link: googleapis/synthtool@af16e6d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5 * Update trove classifier to include python 3.12 * Update required checks to include all samples presubmits --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* feat: Introduce compatibility with native namespace packages * update .coveragerc to reflect changes * remove replacement in owlbot.py * exclude coverage for .nox/* and /tmp/*
Co-authored-by: Astha Mohta <35952883+asthamohta@users.noreply.github.com>
* feat: Batch Write API implementation and samples * Update sample * review comments * return public class for mutation groups * Update google/cloud/spanner_v1/batch.py Co-authored-by: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> * Update google/cloud/spanner_v1/batch.py Co-authored-by: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> * review comments * remove doc * feat(spanner): nit sample data refactoring * review comments * fix test --------- Co-authored-by: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> Co-authored-by: Sri Harsha CH <sriharshach@google.com>
) * fix: Refactoring tests to use fixtures properly * Not using autouse fixtures for few tests where not needed * feat: Implementation for Begin and Rollback clientside statements * Incorporating comments * Formatting * Comments incorporated * Fixing tests * Small fix * Test fix as emulator was going OOM
…ult (#1410) This change enables OpenTelemetry metrics and tracing by default. [Fix for [Issues 1222](https://github.com/googleapis/python-spanner/issues/1222)]
- [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: Exposing AutoscalingConfig in InstancePartition fix: Deprecate credentials_file argument END_COMMIT_OVERRIDE PiperOrigin-RevId: 825184314 Source-Link: googleapis/googleapis@72e7439 Source-Link: googleapis/googleapis-gen@007caa0 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDA3Y2FhMDZiYWM2NzY1NzdmOGQ4NDViODc5M2MxNmVmZjY2YWM5YSJ9 BEGIN_NESTED_COMMIT fix: Deprecate credentials_file argument chore: Update gapic-generator-python to 1.28.0 PiperOrigin-RevId: 816753840 Source-Link: googleapis/googleapis@d06cf27 Source-Link: googleapis/googleapis-gen@a524e73 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTUyNGU3MzEwODgyYmJiOTliZmUxMzk5YjE4YmVkMzI4OTc5MjExYyJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
…butes (#1449) This change enhances observability by introducing these new features: 1. **Cloud Region Attribute**: The `cloud.region` attribute is now added to all OpenTelemetry spans generated by the Spanner client. This provides better geographical context for traces, aiding in performance analysis and debugging across different regions. 2. **Transaction Tag**: The `transaction_tag` set on a `Transaction` object is now correctly propagated and included in the `Commit` request. This allows for better end-to-end traceability of transactions. 3. **Request Tag**: This introduces support for `request_tag` on individual Spanner operations like `read`, `execute_sql`, and `execute_update`. When a `request_tag` is provided in the `request_options`, it is now added as a `spanner.request_tag` attribute to the corresponding OpenTelemetry span. This allows for more granular tracing and debugging of specific requests within a transaction or a snapshot. --------- Co-authored-by: surbhigarg92 <surbhigarg.92@gmail.com>
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 833474957 Source-Link: googleapis/googleapis@7418c8b Source-Link: googleapis/googleapis-gen@f969a4a Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjk2OWE0YTVhZDk5N2JhZjE4OWMzOTkzMTYyOTdkNjBhODE5ODg1YiJ9 BEGIN_NESTED_COMMIT feat: Add Send and Ack mutations for Queues feat: Add QueryAdvisorResult for query plan docs: Update description for the BatchCreateSessionsRequest and Session docs: Update description for the IsolationLevel PiperOrigin-RevId: 832425466 Source-Link: googleapis/googleapis@0eeb1be Source-Link: googleapis/googleapis-gen@bae4179 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmFlNDE3OTI1MjAzZTY4YzgwNmQ5ZjZiZmUzYzIwYWIzY2JmNWQ4NiJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Make built-in metrics enabled by default This change inverts the logic for enabling built-in OpenTelemetry metrics. Previously, metrics were disabled by default and could be enabled by setting `ENABLE_SPANNER_METRICS_ENV_VAR=true`. With this update, metrics are now enabled by default to provide better out-of-the-box observability for users. To disable metrics, users must now set the new environment variable: `SPANNER_DISABLE_BUILTIN_METRICS=true` The old `ENABLE_SPANNER_METRICS_ENV_VAR` is no longer used. Unit tests have been updated to reflect this new opt-out behavior. **BREAKING CHANGE**: Built-in metrics are now enabled by default. Users who previously did not set any environment variables will have metrics collection and export turned on automatically after upgrading. To restore the previous behavior and disable metrics, thry have to set the `SPANNER_DISABLE_BUILTIN_METRICS` environment variable to `true`.
This PR adds support for Python 3.14 to the library. Key changes include: Key changes include: - Updates to `owlbot.py` to include Python 3.14. - Adding Python 3.14 to the test matrix in `.github/workflows/presubmit.yaml`. - Verified `setup.py` includes the Python 3.14 classifier. - Verified `CONTRIBUTING.rst` includes Python 3.14. - Verified `noxfile.py` updates for 3.14. - Updated Kokoro configurations in `.kokoro/presubmit/` to use `system-3.14` session. - Updated `librarian.py` to account for post-processing. - Fixed a concurrency issue in `tests/unit/test_spanner.py` to make the test suite pass on Python 3.14. Towards internal issue: b/375664027 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: gcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Subham Sinha <35077434+sinhasubham@users.noreply.github.com> Co-authored-by: surbhigarg92 <surbhigarg.92@gmail.com>
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v1.0.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:8e2c32496077054105bd06c54a59d6a6694287bc053588e24debe6da6920ad91 <details><summary>google-cloud-spanner: 3.60.0</summary> ## [3.60.0](https://togithub.com/googleapis/python-spanner/compare/v3.59.0...v3.60.0) (2025-12-10) ### Features * make built-in metrics enabled by default (#1459) ([64aebe7e](https://togithub.com/googleapis/python-spanner/commit/64aebe7e)) * Exposing AutoscalingConfig in InstancePartition ([8b6f1540](https://togithub.com/googleapis/python-spanner/commit/8b6f1540)) * add support for experimental host (#1452) ([9535e5e0](https://togithub.com/googleapis/python-spanner/commit/9535e5e0)) * enable OpenTelemetry metrics and tracing by default (#1410) ([bb5095df](https://togithub.com/googleapis/python-spanner/commit/bb5095df)) * add cloud.region, request_tag and transaction_tag in span attributes (#1449) ([d37fb80a](https://togithub.com/googleapis/python-spanner/commit/d37fb80a)) * Add QueryAdvisorResult for query plan (PiperOrigin-RevId: 832425466) ([e08260fe](https://togithub.com/googleapis/python-spanner/commit/e08260fe)) * Add Send and Ack mutations for Queues (PiperOrigin-RevId: 832425466) ([e08260fe](https://togithub.com/googleapis/python-spanner/commit/e08260fe)) * Add Spanner location API (#1457) (PiperOrigin-RevId: 833474957) ([e08260fe](https://togithub.com/googleapis/python-spanner/commit/e08260fe)) ### Bug Fixes * Deprecate credentials_file argument ([8b6f1540](https://togithub.com/googleapis/python-spanner/commit/8b6f1540)) * configure keepAlive time for gRPC TCP connections (#1448) ([efb2833e](https://togithub.com/googleapis/python-spanner/commit/efb2833e)) * Provide Spanner Option to disable metrics (#1460) ([f1ebc43b](https://togithub.com/googleapis/python-spanner/commit/f1ebc43b)) ### Documentation * Update description for the BatchCreateSessionsRequest and Session (PiperOrigin-RevId: 832425466) ([e08260fe](https://togithub.com/googleapis/python-spanner/commit/e08260fe)) * Update description for the IsolationLevel (PiperOrigin-RevId: 832425466) ([e08260fe](https://togithub.com/googleapis/python-spanner/commit/e08260fe)) </details>
feat: update image to us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.7.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209 <details><summary>google-cloud-spanner: 3.61.0</summary> ## [3.61.0](googleapis/python-spanner@v3.60.0...v3.61.0) (2025-12-16) ### Features * support mTLS certificates when available (#1467) ([df87c3ed](googleapis/python-spanner@df87c3ed)) </details>
When using multiplexed sessions, the transaction_tag should also be set on the BeginTransactionRequest. --------- Co-authored-by: rahul2393 <irahul@google.com>
…1472) 1. add cryptography to prerelease dependencies The prerelease dependency check installs packages with `--no-deps`, which causes `google-auth` to fail because its dependency `cryptography` and `cffi` is missing. This change explicitly adds `cryptography` and `cffi` to the `prerel_deps` list in `noxfile.py` to ensure it is installed during the test session. 2. bypass sqlparse for RUN PARTITION commands Check for RUN PARTITION command to avoid sqlparse processing it. sqlparse fails with "Maximum grouping depth exceeded" on long partition IDs causing flakiness in system tests.
Signed-off-by: Sri Harsha CH <sriharshach@google.com> Co-authored-by: Subham Sinha <suvham@google.com>
***Handle errors during stream restart in snapshot*** **Root Cause** When `_restart_on_unavailable` caught a `ServiceUnavailable` or resumable `InternalServerError`, it attempted to re-initialize the iterator immediately within the `except` block. If this re-initialization failed (e.g. due to a persistent transient error), the exception would propagate unhandled, breaking the retry loop. **Fix** This change modifies the logic to reset the iterator to `None` and `continue` the loop, forcing the re-initialization to occur inside the `try` block. This ensures that subsequent errors during restart are properly caught and retried. **Testing** Added unit tests to cover this specific behavior
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v1.0.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209 <details><summary>google-cloud-spanner: 3.62.0</summary> ## [3.62.0](googleapis/python-spanner@v3.61.0...v3.62.0) (2026-01-14) ### Features * add uuid support (#1310) ([3b1792aa](googleapis/python-spanner@3b1792aa)) ### Bug Fixes * transaction_tag should be set on BeginTransactionRequest (#1463) ([3d3cea0b](googleapis/python-spanner@3d3cea0b)) * resolve pre-release dependency failures and sqlparse recursion (#1472) ([9ec95b7d](googleapis/python-spanner@9ec95b7d)) * handle errors during stream restart in snapshot (#1471) ([c0668735](googleapis/python-spanner@c0668735)) </details>
Adding a new span attribute called gcp.resource.name which contains an
identifier to a particular spanner instance and database in the
following format:
//spanner.googleapis.com/projects/{project}/instances/{instance_id}/databases/{database_id}
Example:
//spanner.googleapis.com/projects/my_project/instances/my_instance/databases/my_database
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-spanner/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
Snippet shows how to set the read lock mode at the client-level and how to override the option at the transaction-level.
#1492) ****Summary:**** This PR fixes a critical memory and thread leak in the google-cloud-spanner client when built-in metrics are enabled (default behavior). Previously, the Client constructor unconditionally initialized a new OpenTelemetry MeterProvider and PeriodicExportingMetricReader on every instantiation. Each reader spawned a new background thread for metric exporting that was never cleaned up or reused. In environments where Client objects are frequently created (e.g., Cloud Functions, web servers, or data pipelines), this caused a linear accumulation of threads, leading to RuntimeError: can't start new thread and OOM crashes. ****Fix Implementation:**** ***Refactored Metrics Initialization (Thread Safety & Memory Leak Fix)***: Implemented a Singleton pattern for the OpenTelemetry MeterProvider using threading.Lock to prevent infinite background thread creation (memory leak). Moved metrics initialization logic to a cleaner helper function _initialize_metrics in client.py. Replaced global mutable state in SpannerMetricsTracerFactory with contextvars.ContextVar to ensure thread-safe, isolated metric tracing across concurrent requests. Updated MetricsInterceptor and MetricsCapture to correctly use the thread-local tracer. ***Fixed Batch.commit Idempotency (AlreadyExists Regression):*** Modified Batch.commit to initialize nth_request and the attempt counter outside the retry loop. This ensures that retries (e.g., on ABORTED) reuse the same Request ID, allowing Cloud Spanner to correctly deduplicate requests and preventing spurious AlreadyExists (409) errors. ***Verification:*** Added tests/unit/test_metrics_concurrency.py to verify tracer isolation and thread safety. Cleaned up tests/unit/test_metrics.py and consolidated mocks in conftest.py.
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v1.0.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209 <details><summary>google-cloud-spanner: 3.63.0</summary> ## [3.63.0](googleapis/python-spanner@v3.62.0...v3.63.0) (2026-02-13) ### Features * add requestID info in error exceptions (#1415) ([2c5eb96c](googleapis/python-spanner@2c5eb96c)) ### Bug Fixes * prevent thread leak by ensuring singleton initialization (#1492) ([e792136a](googleapis/python-spanner@e792136a)) ### Documentation * snippet for setting read lock mode (#1473) ([7e79920c](googleapis/python-spanner@7e79920c)) </details>
Previously googleapis/python-spanner#1452 introduced changes to support python spanner client against spanner experimental host endpoints over insecure communication This PR extends those changes to support python spanner client connections to experimental host endpoints over TLS / mTLS connections as well. It also includes changes to run Integration Tests against experimental hosts across all 3 modes of network communication (plain-text, TLS, mTLS) To run IT tests against experimental host set below variables ``` export SPANNER_EXPERIMENTAL_HOST=localhost:15000 ``` For tls/mTLS set below additonal variables: - (mTLS/TLS) ``` export CA_CERTIFICATE=/tmp/experimental_host/ca-certificates/ca.crt ``` - (mTLS) ``` export CLIENT_CERTIFICATE=/tmp/experimental_host/certs/client.crt export CLIENT_KEY=/tmp/experimental_host/certs/client.key ``` Then we can run below command to tigger the tests: ``` python -m pytest -v -s --disable-warnings tests/system/ ``` --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com>
Re-opening #1495 due to permissions issues. Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-spanner/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕 --------- Co-authored-by: Knut Olav Løite <koloite@gmail.com>
…into migration.python-spanner.migration.2026-03-09_19-45-52.migrate
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on migrating the Cloud Spanner library's codebase to a new location while ensuring that the project's history is maintained. It also introduces new configuration files for development and code quality. Highlights
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request appears to be a large-scale migration for the google-cloud-spanner package. The changes introduce a vast number of new configuration files, documentation, and scripts. My review has identified several critical issues that will cause CI failures, particularly in the GitHub Actions workflows due to an invalid action version, and in a benchmark script that uses Python 2 syntax in a Python 3+ environment. Additionally, there are high-severity inconsistencies in dependency management and several medium-severity issues related to outdated documentation and configuration file formatting. Addressing these issues will be crucial for the stability and maintainability of the package.
Note: Security Review did not run due to the size of the PR.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/google-cloud-spanner/.github/workflows/presubmit.yaml (36)
The action actions/setup-python@v6 is not a valid version and will cause this workflow to fail. The latest stable version is v5. Please update to a valid version.
uses: actions/setup-python@v5packages/google-cloud-spanner/benchmark/ycsb.py (148)
The .itervalues() method is a Python 2 feature. In Python 3, you should use .values(). This code will fail at runtime. Additionally, the list comprehension is redundant; you can pass the values() view directly to sum().
overall_op_count = sum(op_counts.values())packages/google-cloud-spanner/.github/workflows/integration-tests-against-emulator.yaml (22)
The action actions/setup-python@v6 is not a valid version and will cause this workflow to fail. The latest stable version is v5. Please update to a valid version. Also, consider using stable action versions like actions/checkout@v4 instead of pre-releases like v5 for better stability.
uses: actions/setup-python@v5packages/google-cloud-spanner/.github/workflows/integration-tests-against-emulator-with-regular-session.yaml (22)
The action actions/setup-python@v6 is not a valid version and will cause this workflow to fail. The latest stable version is v5. Please update to a valid version. Also, consider using stable action versions like actions/checkout@v4 instead of pre-releases like v5 for better stability.
uses: actions/setup-python@v5packages/google-cloud-spanner/.github/workflows/presubmit.yaml (18)
The action actions/setup-python@v6 is not a valid version and will cause this workflow to fail. The latest stable version is v5. Please update to a valid version. This issue is also present in the units job.
uses: actions/setup-python@v5packages/google-cloud-spanner/benchmark/ycsb.py (146-147)
The .iteritems() method is specific to Python 2 and has been removed in Python 3. Since this project requires Python 3.9+, this will cause a runtime AttributeError. Please use the .items() method instead.
op_counts = {operation: len(latency) for operation, latency in latencies_ms.items()}packages/google-cloud-spanner/.github/workflows/mock_server_tests.yaml (15)
The action actions/setup-python@v6 is not a valid version and will cause this workflow to fail. The latest stable version is v5. Please update to a valid version. Also, consider using stable action versions like actions/checkout@v4 instead of pre-releases like v5 for better stability.
uses: actions/setup-python@v5packages/google-cloud-spanner/.devcontainer/Dockerfile (16)
The apt-key command is deprecated and its usage is discouraged for security reasons. It's recommended to download the GPG key and store it directly in /usr/share/keyrings. Additionally, combining apt-get commands into a single RUN instruction and cleaning up the apt cache (/var/lib/apt/lists/*) would optimize the Docker image size and build time.
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg && apt-get update -y && apt-get install -y google-cloud-cli
packages/google-cloud-spanner/.devcontainer/requirements.in (1)
The version of nox specified here (2024.10.9) is inconsistent with requirements.txt, which lists nox==2025.5.1. Since requirements.txt is generated from this file, they should be in sync. Please update this file to match the version in requirements.txt and regenerate it to ensure a reproducible environment.
nox==2025.5.1
packages/google-cloud-spanner/.github/header-checker-lint.yml (15)
This file does not end with a newline character. It's a good practice for all text files to end with a newline for POSIX compatibility and to avoid issues with some tools.
packages/google-cloud-spanner/.librarian/generator-input/librarian.py (213)
The unit_test_python_versions list includes Python 3.7 and 3.8. However, other configuration files in this PR, such as setup.py (python_requires=">=3.9") and noxfile.py, indicate that support starts from Python 3.9. To ensure consistency across the project's configuration, please remove Python 3.7 and 3.8 from this list.
unit_test_python_versions=["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
packages/google-cloud-spanner/CONTRIBUTING.rst (25)
The list of supported Python versions is missing Python 3.14, which is included in the test matrix in noxfile.py and listed in setup.py. Please update the documentation to reflect this.
3.9, 3.10, 3.11, 3.12, 3.13, and 3.14 on both UNIX and Windows.
packages/google-cloud-spanner/.devcontainer/postCreate.sh (3)
The file does not end with a newline character. According to POSIX standards, a text file should end with a newline. Some tools may not process the last line correctly without it.
packages/google-cloud-spanner/.devcontainer/requirements.in (1)
The file does not end with a newline character. It is a POSIX standard and a general best practice for text files to end with a newline to ensure they are processed correctly by various tools.
See #10952.
This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.