Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the JDBC connection to correctly report the isolation level of the current transaction instead of always returning the default isolation level. It introduces a new getTransactionIsolationLevel() method to the Connection interface and implements it in ConnectionImpl. A test has been added to verify this behavior. The reviewer suggested preserving the check that the connection is not closed in ConnectionImpl.getTransactionIsolationLevel() to ensure that operations on a closed connection fail fast.
| public IsolationLevel getTransactionIsolationLevel() { | ||
| return isInTransaction() ? transactionIsolationLevel : getDefaultIsolationLevel(); | ||
| } |
There was a problem hiding this comment.
To maintain consistency with other methods in ConnectionImpl and ensure that operations on a closed connection fail fast, we should preserve the check that the connection is not closed.
| public IsolationLevel getTransactionIsolationLevel() { | |
| return isInTransaction() ? transactionIsolationLevel : getDefaultIsolationLevel(); | |
| } | |
| public IsolationLevel getTransactionIsolationLevel() { | |
| ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); | |
| return isInTransaction() ? transactionIsolationLevel : getDefaultIsolationLevel(); | |
| } |
With a
SERIALIZABLEconnection default,getTransactionIsolation()reportsSERIALIZABLEeven afterBEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ. This change reads the isolation level from the active Spanner transaction and falls back to the connection default outside a transaction.The mock-server regression test checks the default before
BEGIN,REPEATABLE READduring the transaction, and the default again afterROLLBACK.Fixes #14968
Validated with 218 tests across
ConnectionStatementExecutorTest,JdbcConnectionTest, andTransactionMockServerTest.