From fe66f766bb74c29c88e4ff0f84fb2b1198083d19 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Wed, 20 Sep 2017 18:38:08 +0300 Subject: 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). --- .../galera/r/galera_bf_abort_for_update.result | 23 ++++++++--- .../suite/galera/t/galera_bf_abort_for_update.test | 45 +++++++++++++++++----- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_bf_abort_for_update.result b/mysql-test/suite/galera/r/galera_bf_abort_for_update.result index 3978a3df193..2367924466c 100644 --- a/mysql-test/suite/galera/r/galera_bf_abort_for_update.result +++ b/mysql-test/suite/galera/r/galera_bf_abort_for_update.result @@ -1,10 +1,21 @@ -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; diff --git a/mysql-test/suite/galera/t/galera_bf_abort_for_update.test b/mysql-test/suite/galera/t/galera_bf_abort_for_update.test index 24c29778e5d..13e48f8f3ce 100644 --- a/mysql-test/suite/galera/t/galera_bf_abort_for_update.test +++ b/mysql-test/suite/galera/t/galera_bf_abort_for_update.test @@ -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; -- cgit v1.2.1 From 9a21fd34af0506c5b45133c87c23862b84b36717 Mon Sep 17 00:00:00 2001 From: Daniele Sciascia Date: Wed, 14 Mar 2018 10:27:31 +0100 Subject: MDEV-13549 Re-enable test galera.galera_bf_abort_for_update Test passes reliably after applying missing commit from upstream. --- mysql-test/suite/galera/disabled.def | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index d82d5dd2023..3e70924aa3c 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -34,7 +34,6 @@ galera_ist_mysqldump : MDEV-13549 Galera test failures mysql-wsrep#31 : MDEV-13549 Galera test failures galera_migrate : MariaDB 10.0 does not support START SLAVE USER galera_concurrent_ctas : MDEV-13549 Galera test failures -galera_bf_abort_for_update : MDEV-13549 Galera test failures galera_wsrep_desync_wsrep_on : MDEV-13549 Galera test failures galera_ssl_upgrade : MDEV-13549 Galera test failures mysql-wsrep#33 : MDEV-13549 Galera test failures -- cgit v1.2.1