Commit fe66f766 authored by Vasil Dimov's avatar Vasil Dimov Committed by Daniele Sciascia

Fix and enable galera.galera_bf_abort_for_update

The test was not deterministic as it would not wait for the second
INSERT to be applied (and thus the victim transaction rolled back).
parent 90051082
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (1);
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 10);
BEGIN;
SELECT * FROM t1 FOR UPDATE;
f1 f2
1 10
UPDATE t1 SET f1 = 2;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
wsrep_local_aborts_increment
wsrep_local_bf_aborts_diff
1
BEGIN;
SELECT * FROM t1 FOR UPDATE;
f1 f2
2 10
UPDATE t1 SET f2 = 20;
COMMIT;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
wsrep_local_bf_aborts_diff
1
DROP TABLE t1;
......@@ -5,25 +5,52 @@
# Test a local transaction being aborted by a slave one while it is running a SELECT FOR UPDATE
#
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INT) ENGINE=InnoDB;
--connection node_2
--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (1, 10);
# Test updating the PK
--connection node_1
INSERT INTO t1 VALUES (1);
--let $wsrep_local_bf_aborts_before = `SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts'`
BEGIN;
SELECT * FROM t1 FOR UPDATE;
--connection node_2
UPDATE t1 SET f1 = 2;
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--let $wait_condition = SELECT COUNT(*) FROM t1 WHERE f1 = 2
--source include/wait_condition.inc
--connection node_1
--error ER_LOCK_DEADLOCK
COMMIT;
--disable_query_log
--eval SELECT variable_value - $wsrep_local_bf_aborts_before AS wsrep_local_bf_aborts_diff FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts'
--enable_query_log
# Test updating non-indexed column
--connection node_1
--let $wsrep_local_bf_aborts_before = `SELECT variable_value FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts'`
BEGIN;
SELECT * FROM t1 FOR UPDATE;
--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
--connection node_2
UPDATE t1 SET f2 = 20;
--connection node_1a
--let $wait_condition = SELECT COUNT(*) FROM t1 WHERE f2 = 20
--source include/wait_condition.inc
--connection node_1
--error ER_LOCK_DEADLOCK
COMMIT;
--disable_query_log
--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment;
--eval SELECT variable_value - $wsrep_local_bf_aborts_before AS wsrep_local_bf_aborts_diff FROM information_schema.global_status WHERE variable_name = 'wsrep_local_bf_aborts'
--enable_query_log
DROP TABLE t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment