CREATE TABLE t ( `a` INT NOT NULL, PRIMARY KEY (`a`) ) ENGINE=InnoDB; INSERT INTO t VALUES(10); INSERT INTO t VALUES(20); SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; XA START '1'; SELECT * FROM t WHERE a > 20 FOR UPDATE; a INSERT INTO t VALUES(40); XA END '1'; XA PREPARE '1'; connect con1,localhost,root; SET innodb_lock_wait_timeout=1; INSERT INTO t VALUES(50); connection default; XA COMMIT '1'; XA START '1'; SELECT * FROM t WHERE a > 20 LOCK IN SHARE MODE; a 40 50 INSERT INTO t VALUES (5); XA END '1'; XA PREPARE '1'; connection con1; INSERT INTO t VALUES (60); INSERT INTO t VALUES (30); disconnect con1; connection default; XA COMMIT '1'; DROP TABLE t;