Skip to content

[Bug]: SET SESSION TRANSACTION ISOLATION LEVEL is a no-op; only SET transaction_isolation / tx_isolation changes isolation #26648

Closed

Description

1. Is there an existing issue for this?

  • I have searched the existing issues

2. Bug description and error info with logs

Summary

SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED (and REPEATABLE READ) succeeds without error but does not change @@transaction_isolation.

Changing isolation via system variables does work:

  • SET transaction_isolation = 'READ-COMMITTED'
  • SET tx_isolation = 1

This breaks Java/JDBC/Spring apps that call Connection.setTransactionIsolation(TRANSACTION_READ_COMMITTED) or use @Transactional(isolation = READ_COMMITTED), because Connector/J typically issues the standard SET SESSION TRANSACTION ISOLATION LEVEL ... form. The app believes RC is active while the session remains REPEATABLE-READ (silent mismatch).

No SQLException is raised — this is a silent no-op, which is harder to detect than an explicit "unsupported" error.

Minimal repro

SET transaction_isolation = 'REPEATABLE-READ';
SELECT @@transaction_isolation AS baseline;
-- REPEATABLE-READ

-- Standard SQL / JDBC path: NO EFFECT
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT @@transaction_isolation AS after_std_set_rc;
-- still REPEATABLE-READ  (expected: READ-COMMITTED)

-- Variable path: WORKS
SET transaction_isolation = 'READ-COMMITTED';
SELECT @@transaction_isolation AS after_var_set_rc;
-- READ-COMMITTED

-- Standard form still NO EFFECT the other way
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@transaction_isolation AS after_std_set_rr;
-- still READ-COMMITTED  (expected: REPEATABLE-READ)

Observed on local MO:

version(): 8.0.30-MatrixOne-v

Impact

  • MySQL-compatible clients/ORMs that set isolation via SET TRANSACTION ISOLATION LEVEL get wrong semantics with no error.
  • Confirmed from Java MyBatis PetClinic / JDBC scenario suites: Spring asks for RC, @@transaction_isolation on the transactional connection stays REPEATABLE-READ.

BVT gap

Existing BVT does not catch this:

  1. test/distributed/cases/set/set_transaction.sql — comment says:

    -- just pass syntax check. no actual semantic action.

    It runs set transaction isolation level read committed etc., but never asserts @@transaction_isolation afterward.

  2. system_variables_new.sql covers set tx_isolation = 1 and expects READ-COMMITTED — that path works; it does not cover the standard SET SESSION TRANSACTION ISOLATION LEVEL semantic.

Suggested BVT assertion (should fail on current behavior):

SET transaction_isolation = 'REPEATABLE-READ';
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
-- @result: READ-COMMITTED
SELECT @@transaction_isolation;

3. Expected and actual behavior

Statement Expected @@transaction_isolation Actual
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED READ-COMMITTED stays previous value (e.g. REPEATABLE-READ)
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ REPEATABLE-READ stays previous value
SET transaction_isolation = 'READ-COMMITTED' READ-COMMITTED READ-COMMITTED (OK)
SET tx_isolation = 1 READ-COMMITTED READ-COMMITTED (OK)

Expected: standard SET [SESSION] TRANSACTION ISOLATION LEVEL ... should update session isolation the same way as SET transaction_isolation / SET tx_isolation, matching MySQL.

4. Environment

  • MatrixOne: 8.0.30-MatrixOne-v (local mo-service)
  • Client: mysql CLI + Java Connector/J (Spring @Transactional(READ_COMMITTED))
  • How found: Java + MyBatis PetClinic / JDBC compatibility E2E against MO

5. Additional context

Docs state MO supports Read Committed and Snapshot Isolation (RR). RC itself is reachable via SET transaction_isolation / tx_isolation; the bug is specifically that the standard SET TRANSACTION ISOLATION LEVEL syntax is accepted but ignored.

Activity

  1. ghost added this to the MO-202608 milestone on Aug 3, 2026
  2. ghost added
    kind/bug
    on Aug 3, 2026
  3. ghost added
    severity/s0
    on Aug 3, 2026
  4. ghost added theissue type on Aug 3, 2026
  5. iamlinjunhong commented on Aug 4, 2026

    @iamlinjunhong
    Contributor

    ODBC compatibility impact reproduced on 8.0.30-MatrixOne-v25908 while building the MatrixOne ODBC suite in #26677.

    MySQL Connector/ODBC implements SQL_ATTR_TXN_ISOLATION by sending SET SESSION TRANSACTION ISOLATION LEVEL. The ODBC setter returns success for READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, and SERIALIZABLE, but SELECT @@transaction_isolation remains REPEATABLE-READ for every value.

    Minimal direct reproduction:

    SELECT @@transaction_isolation;
    SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
    SELECT @@transaction_isolation;
    SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
    SELECT @@transaction_isolation;

    Observed:

    REPEATABLE-READ
    REPEATABLE-READ
    REPEATABLE-READ
    

    I am adding this as a linked XFAIL in the public ODBC compatibility suite so it remains visible without duplicating this issue. The critical client contract is that the statement must not return success while leaving the session unchanged.

  6. added
    ai-light
    on Aug 11, 2026
  7. assigned and unassigned on Aug 12, 2026
  8. slyunnn commented on Aug 20, 2026

    @slyunnn

    Regression and extended verification for #26648 (2026-08-20)

    Verification Environment

    • MatrixOne origin/main: 2a38e2a4b50b92fefbef7f74ec9c9fe3f0d5cf3b — fix: recreate missing character sets table during upgrade (#27369).
    • Related fix PR: fix(frontend): handle SET TRANSACTION isolation level #26665, merge commit 310fa3f50dc8a96bd7749862139018678d9a2173 — fix(frontend): handle SET TRANSACTION isolation level (#26665).
    • Topology: Log service + TN + CN1 + CN2 + Proxy.
    • Endpoints: CN1 127.0.0.1:16001, CN2 127.0.0.1:16002, Proxy 127.0.0.1:6009.
    • Client protocol: MOTR through the MySQL text protocol.

    What Was Covered

    • OK — Original JDBC/ODBC path: SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED updates @@transaction_isolation from REPEATABLE-READ to READ-COMMITTED.
    • OK — Happy path: SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ updates the session back to REPEATABLE-READ.
    • OK — Compatibility control: SET transaction_isolation = 'READ-COMMITTED' and standard SET SESSION TRANSACTION ISOLATION LEVEL produce equivalent visible session state.
    • OK — Unhappy path: unsupported READ UNCOMMITTED returns ERROR 20105 and preserves REPEATABLE-READ.
    • OK — Unhappy path: unsupported SERIALIZABLE returns ERROR 20105 and preserves REPEATABLE-READ.
    • OK — Transaction-scope boundary: changing transaction characteristics during an active transaction returns ERROR 1568 and preserves the current session isolation.
    • OK — Replayed through Proxy, CN1 direct, and CN2 direct endpoints.
    • Not covered — Actual JDBC/ODBC driver execution; the exact SQL emitted by those drivers was covered through the MySQL text protocol.

    Findings

    The former silent no-op is fixed. Supported standard session isolation statements now update observable session state. Unsupported isolation levels fail explicitly instead of returning success while leaving the session unchanged.

    Large-data regression is not required: this is session-state parsing and transaction metadata behavior, independent of row count, block/batch boundaries, memory/spill, concurrency, skew, network transfer, or resource scale.

    MOTR / BVT Coverage

    • Added suites/14_issue_regression/t/issue_26648_session_transaction_isolation.test.
    • Added suites/14_issue_regression/r/issue_26648_session_transaction_isolation.result.
    • Recorded and replayed successfully through Proxy: 19/19.
    • Replayed successfully through CN1 direct: 19/19.
    • Replayed successfully through CN2 direct: 19/19.
    • MOTR branch: test/issue-26648-session-isolation.
    • MOTR commit: 1f9a47e — test: add MOTR regression for #26648.
    • The independent branch was pushed successfully. No issue-specific PR was created.

    Final Conclusion

    Fixed. Standard SET SESSION TRANSACTION ISOLATION LEVEL now changes supported session isolation levels, while unsupported values and invalid in-transaction changes return explicit errors without mutating session state. Large-data regression is not needed because data volume does not affect this session-state contract.

  9. daviszhen commented on Oct 17, 2026

    @daviszhen
    Contributor

    v4.2.5 release-specific reproduction (arm64), plus two related transaction-semantics observations

    Replay on the official matrixorigin/matrixone:latest image — arm64/linux, VERSION() = 8.0.30-MatrixOne-v4.2.5, single node; MySQL 8.0.46 as baseline. Same session sets and reads the variable back (a cross-connection read-back would be meaningless for a session variable).

    1. SET SESSION TRANSACTION ISOLATION LEVEL is still a no-op, exactly as reported here.

    SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
    SELECT @@transaction_isolation;   -- MO: REPEATABLE-READ   (MySQL: READ-UNCOMMITTED)
    SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
    SELECT @@transaction_isolation;   -- MO: REPEATABLE-READ   (MySQL: READ-COMMITTED)
    SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
    SELECT @@transaction_isolation;   -- MO: REPEATABLE-READ   (MySQL: REPEATABLE-READ)
    SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
    SELECT @@transaction_isolation;   -- MO: REPEATABLE-READ   (MySQL: SERIALIZABLE)

    All four levels report success and none of them changes the value.

    2. The observable behaviour is READ COMMITTED while the variable reports REPEATABLE-READ.

    Same session, REPEATABLE READ selected (reported value REPEATABLE-READ), a second session updates and commits row id=1 mid-transaction:

    session A: START TRANSACTION; SELECT v FROM iso WHERE id=1;   -> 10
    session B:               UPDATE iso SET v=111 WHERE id=1; COMMIT;
    session A: SELECT v FROM iso WHERE id=1;                      -> 111   (non-repeatable read)
    

    So the reported isolation level and the actual one disagree — which is worse than the no-op itself, because an application that reads @@transaction_isolation, sees REPEATABLE-READ, and relies on repeatable reads will silently get READ COMMITTED semantics. (I see #30377 tracks a related "stale global transaction_isolation from catalog silently overrides mode-resolve" path, so this may be the same root area.)

    3. A deadlock on v4.2.5 surfaces as 20701, not MySQL's 1213.

    Two sessions taking the same two row locks in opposite order (session A locks id=1 then id=2; session B locks id=2 then id=1):

    foreground: completed after ~8s, no error
    background: ERROR 20701
    

    One session was aborted (so the conflict is detected), but the code is 20701 rather than 1213/1205. Applications that classify "deadlock → retry the transaction" versus "lock wait timeout → retry the statement" by error code will mis-handle this. If 20701 is the intended MatrixOne code for this case, it would help to document the mapping (MySQL 1213 → MatrixOne 20701) together with the retry guidance — note this release also returns 1205 for a plain lock-wait timeout, so the two are distinguishable, just not by the MySQL code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-lightkind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions