Skip to content

Instantly share code, notes, and snippets.

@nirbhayc
Created July 28, 2016 21:29
Show Gist options
  • Save nirbhayc/be4162d7e3490b8830a4471e04fb22e7 to your computer and use it in GitHub Desktop.
Save nirbhayc/be4162d7e3490b8830a4471e04fb22e7 to your computer and use it in GitHub Desktop.
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# Deadlock
#
--connection node_1
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET AUTOCOMMIT = OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (1), (2);
--connection node_2
SET AUTOCOMMIT = OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (2), (1);
--connection node_1
COMMIT;
--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
DROP TABLE t1;
#
# Rollback
#
--connection node_1
CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t2 VALUES (1), (2);
--connection node_2
START TRANSACTION;
INSERT INTO t2 VALUES (2), (1);
--connection node_1
ROLLBACK;
--connection node_2
COMMIT;
SELECT COUNT(*) = 2 FROM t2;
--connection node_1
#SELECT COUNT(*) = 2 FROM t2;
DROP TABLE t2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment