feat: support isolation level repeatable read#1973
Merged
Conversation
Adds support for setting the transaction isolation level to repeatable read.
aakashanandg
reviewed
Apr 1, 2025
| // There is no 'unspecified' isolation level in JDBC, so we convert this to the default | ||
| // SERIALIZABLE isolation level in Spanner. | ||
| assertEquals( | ||
| Connection.TRANSACTION_SERIALIZABLE, |
There was a problem hiding this comment.
Is there a specific reason we're defaulting to the Serialization isolation level when the Spanner isolation level isn't specified?
Collaborator
Author
There was a problem hiding this comment.
Yes, the reason is the following:
- JDBC requires us to always return an actual isolation level (so for example
serializable). JDBC does not have anything like an 'unspecified isolation level'. - Spanner supports
ISOLATION_LEVEL_UNSPECIFIEDand this is the default that we are using in the Java client library. It basically means 'Spanner should use its own default'. At the moment, as a user, you cannot configure a default. So this means the default is alwaysserializable. - We use this method to convert the isolation level specified in the Spanner client library to the JDBC spec. As the Spanner client library can return
ISOLATION_LEVEL_UNSPECIFIEDand JDBC does not have an equivalent, we have to convert it to one of the actual isolation levels. And the only logical choice is then to returnserializable, as that is the isolation level that Spanner will be using when you useISOLATION_LEVEL_UNSPECIFIED.
aakashanandg
approved these changes
Apr 1, 2025
gcf-merge-on-green bot
pushed a commit
that referenced
this pull request
Apr 22, 2025
🤖 I have created a release *beep* *boop* --- ## [2.29.0](https://togithub.com/googleapis/java-spanner-jdbc/compare/v2.28.0...v2.29.0) (2025-04-22) ### Features * Support isolation level repeatable read ([#1973](https://togithub.com/googleapis/java-spanner-jdbc/issues/1973)) ([010a502](https://togithub.com/googleapis/java-spanner-jdbc/commit/010a502310db88f8c676960c641a7e9a6581bf11)) ### Dependencies * Update dependency com.google.cloud:google-cloud-spanner-bom to v6.90.0 ([#1970](https://togithub.com/googleapis/java-spanner-jdbc/issues/1970)) ([7153c39](https://togithub.com/googleapis/java-spanner-jdbc/commit/7153c39464fd9b83609bb7cc2ada5c0f9aab3af8)) * Update dependency com.google.cloud:google-cloud-spanner-bom to v6.91.1 ([#1993](https://togithub.com/googleapis/java-spanner-jdbc/issues/1993)) ([97d4840](https://togithub.com/googleapis/java-spanner-jdbc/commit/97d4840bd3e7cee7f1ddb9b26f3946f1b10ed894)) * Update dependency com.google.cloud:sdk-platform-java-config to v3.46.0 ([#1992](https://togithub.com/googleapis/java-spanner-jdbc/issues/1992)) ([ea0b557](https://togithub.com/googleapis/java-spanner-jdbc/commit/ea0b55729d1bf9e8b5994758314841591ea0c883)) * Update dependency io.opentelemetry:opentelemetry-bom to v1.49.0 ([#1982](https://togithub.com/googleapis/java-spanner-jdbc/issues/1982)) ([6b7ddf4](https://togithub.com/googleapis/java-spanner-jdbc/commit/6b7ddf4352d4db87eab6d9f3fd4945e5650e7798)) * Update dependency org.springframework.data:spring-data-bom to v2024.1.5 ([#1995](https://togithub.com/googleapis/java-spanner-jdbc/issues/1995)) ([6bedf12](https://togithub.com/googleapis/java-spanner-jdbc/commit/6bedf124b9da233e6f4001dff2c1b56f0249aaad)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
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.
Adds support for setting the transaction isolation level to repeatable read.