| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
LGTM |
Sorry, something went wrong.
Adding Bigtable RowResponse parsing helpers.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore: add owlbot for gapic generation * use only v2 for copying * use complete path for storage-v2-py
#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>
* chore: Finish factoring unit tests from presubmit * adjust cover requirement to 83 * add back test directory coverage * ignore some non-prod directories for coverage * amend omit arg in cover to work properly * reduce cov threshold to 84
| Back | FazBrowse Home | New Git URL |
No description provided.