1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
connection node_2;
connection node_1;
Test phase 1 to make sure that natral deadlock in trigger SP execution is
handled correctly
CREATE TABLE t1(a INT);
CREATE TABLE t2(f1 INT, f2 INT, f3 INT);
CREATE PROCEDURE proc()
BEGIN
INSERT INTO t2 VALUES(100, 200, 300);
UPDATE t2 SET f3 = f3 + 100;
END|
CREATE TRIGGER t1 BEFORE INSERT ON t1 FOR EACH ROW CALL proc();
INSERT INTO t1 VALUES(2);;
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
INSERT INTO t1 VALUES(1);;
connection node_1;
connection node_1a;
connection node_1;
wsrep__bf_aborts
0
DROP TABLE t1;
DROP TABLE t2;
DROP PROCEDURE proc;
Test phase 2 to make sure that BF abort for SP execution is
handled correctly
connection node_1;
SET SESSION wsrep_retry_autocommit = 0;
SET SESSION wsrep_sync_wait = 0;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
connection node_1a;
SET SESSION wsrep_retry_autocommit = 0;
SET SESSION wsrep_sync_wait = 0;
CREATE PROCEDURE proc_update()
BEGIN
UPDATE t1 SET f2 = 'b';
END|
INSERT INTO t1 VALUES(1, 'a');
connection node_1;
SET debug_sync='wsrep_before_certification SIGNAL ready WAIT_FOR cont';
CALL proc_update;
connection node_1a;
SET debug_sync='now WAIT_FOR ready';
connection node_2;
UPDATE t1 SET f2='c';
connection node_1a;
SET debug_sync='now SIGNAL cont';
connection node_1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
connection node_1a;
SET debug_sync='RESET';
DROP PROCEDURE proc_update;
connection node_1;
Test phase 3 to make sure natural deadlock is not treated as BF abort
TRUNCATE t1;
INSERT INTO t1 VALUES (1, 'a'), (2, 'a');
connection node_1a;
START TRANSACTION;
UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
connection node_1;
START TRANSACTION;
UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
connection node_1a;
UPDATE t1 SET f2 = 'b' WHERE f1 = 2;
connection node_1;
UPDATE t1 SET f2 = 'c' WHERE f1 = 1;
connection node_1a;
COMMIT;
wsrep__bf_aborts
0
connection node_1;
ROLLBACK;
Test phase 4 to make sure natural deadlock inside SP execution
is not treated as BF abort
connection node_1a;
TRUNCATE t1;
INSERT INTO t1 VALUES (1, 'a'), (2, 'a');
CREATE PROCEDURE proc_update_1()
BEGIN
START TRANSACTION;
UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
SELECT SLEEP(5);
UPDATE t1 SET f2 = 'b' WHERE f1 = 2;
COMMIT;
END|
CREATE PROCEDURE proc_update_2()
BEGIN
START TRANSACTION;
UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
SELECT SLEEP(5);
UPDATE t1 SET f2 = 'c' WHERE f1 = 1;
COMMIT;
END|
connection node_1;
CALL proc_update_1;
connection node_1a;
CALL proc_update_2;
SLEEP(5)
0
wsrep__bf_aborts
0
connection node_1;
SLEEP(5)
0
DROP PROCEDURE proc_update_1;
DROP PROCEDURE proc_update_2;
DROP TABLE t1;
|