Lab: statement errors, rollback and two-session isolation¶
Connect two clients to the same isolated v4.2.5 CN and record transaction mode. Prepare:
DROP DATABASE IF EXISTS kernel_txn_518;
CREATE DATABASE kernel_txn_518;
USE kernel_txn_518;
CREATE TABLE accounts(id INT PRIMARY KEY, balance INT);
INSERT INTO accounts VALUES(1,100),(2,100);
Run session A statement by statement without exiting on the expected duplicate-key error:
USE kernel_txn_518;
SET mo_rollback_txn_on_error=0;
BEGIN;
UPDATE accounts SET balance=90 WHERE id=1;
INSERT INTO accounts VALUES(1,999);
SELECT balance FROM accounts WHERE id=1;
ROLLBACK;
The expected failure/session timing is not executed by single-connection CI. A should still read its 90 after the error. Before A rolls back, run on B:
USE kernel_txn_518;
SELECT balance FROM accounts WHERE id=1;
B should read committed 100; after rollback both read 100. Start another transaction with mo_rollback_txn_on_error=1, repeat UPDATE and failed INSERT, and confirm the earlier UPDATE was rolled back. Restore the setting to 0.
Extend by holding row 1 on A and updating it on B to observe waiting, then acquire row 2 in reverse order for a deadlock. Record actual error/state without prescribing the victim. Confirm real mode before RC/SI comparisons; compatible strings are insufficient.
End all transactions and DROP DATABASE kernel_txn_518. See errors/visibility.