Skip to content

feat(spanner): set read lock mode at client level#16068

Merged
scotthart merged 1 commit intogoogleapis:mainfrom
skuruppu:spanner-read-lock-mode-samples
Apr 7, 2026
Merged

feat(spanner): set read lock mode at client level#16068
scotthart merged 1 commit intogoogleapis:mainfrom
skuruppu:spanner-read-lock-mode-samples

Conversation

@skuruppu
Copy link
Copy Markdown
Contributor

@skuruppu skuruppu commented Apr 7, 2026

The read lock mode can be set at the client level, which is then set as the read lock mode in all RW transactions. However, the client-level read lock mode can be overridden at a transaction level by explicitly specifying the read lock mode in the transaction options.

Also adds a sample for setting the read lock mode at the client level and overriding it at the transaction level.

The read lock mode can be set at the client level, which is then set as
the read lock mode in all RW transactions. However, the read lock mode
can be overridden at a transaction level by explicitly specifying the
read lock mode in the transaction options.

Also adds a sample for setting the read lock mode at the client level
and overriding it at the transaction level.
@skuruppu skuruppu requested a review from a team as a code owner April 7, 2026 04:07
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Apr 7, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a 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 introduces the TransactionReadLockModeOption to allow configuration of transaction read lock modes (Optimistic or Pessimistic) in Google Cloud Spanner. The changes include updating the transaction option mapping logic to support this new setting, adding a code sample to demonstrate its usage at both the client and transaction levels, and implementing unit tests to verify the precedence of these options. I have no feedback to provide as there were no review comments.

@scotthart
Copy link
Copy Markdown
Member

/gcbrun

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 53.96825% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.68%. Comparing base (fc9f8f0) to head (f65db3f).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
google/cloud/spanner/samples/samples.cc 9.37% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16068      +/-   ##
==========================================
- Coverage   92.69%   92.68%   -0.02%     
==========================================
  Files        2343     2343              
  Lines      216674   216737      +63     
==========================================
+ Hits       200852   200884      +32     
- Misses      15822    15853      +31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scotthart scotthart merged commit aa026f9 into googleapis:main Apr 7, 2026
53 of 54 checks passed
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.

3 participants