Skip to content
/ server Public

Commit e40277d

Browse files
committed
MDEV-38218 : Galera test failure on galera_bf_abort_flush_for_export
Problem was in wsrep_handle_mdl_conflict function was comparing thd->lex->sql_command variable for granted MDL-lock. There is two possible schedules: (1) FLUSH TABLES ... FOR EXPORT that will take MDL-lock (granted_thd). INSERT from other node is conflicting operation (request_thd) and sees MDL-conflict. Because granted_thd has not executed anything else thd->lex->sql_command == SQLCOM_FLUSH and this case was correctly handled in wsrep_handle_mdl_conflict i.e. INSERT needs to wait. (2) FLUSH TABLES ... FOR EXPORT that will take MDL-lock (granted_thd). SET SESSION wsrep_sync_wait=0; (granted_thd) INSERT from other node is conflicting operation (request_thd) However, thd->lex->sql_command is not stored to taken MDL-lock. Now as granted_thd is executing SET thd->lex->sql_command != SQLCOM_FLUSH and INSERT that is BF will abort it and that means also FTFE is killed and MDL-lock relesed. This is incorrect as FTFE has written file on filesystem and it can't be really killed. In this fix wsrep_handle_mdl_conflict is refactored not to use thd->lex->sql_command as a variable used for decisions. Instead connection state can be determined also via THD members. E.g.: * wsrep_thd_is_toi() || wsrep_thd_is_applying - ongoing TOI or applier * wsrep_thd_is_BF - thread is brute force * wsrep_thd_is_SR - thread is streaming replication thread * thd->current_backup_stage != BACKUP_FINISHED - there's ongoing BACKUP * thd->global_read_lock.is_acquired() - ongoing FTWRL * thd->locked_tables_mode == LTM_LOCK_TABLES - ongoing FTFE or LOCK TABLES
1 parent f92337a commit e40277d

17 files changed

+151
-91
lines changed

mysql-test/suite/galera/r/MDEV-22232.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ connection node_1;
99
SET DEBUG_SYNC = 'now WAIT_FOR may_run';
1010
TRUNCATE TABLE t1;
1111
connection con1;
12-
ERROR 70100: Query execution was interrupted
12+
Got one of the listed errors
1313
SET DEBUG_SYNC = 'RESET';
1414
--- CTAS with non-empty result set ---
1515
INSERT INTO t1 VALUES (10), (20), (30);
@@ -19,7 +19,7 @@ connection node_1;
1919
SET DEBUG_SYNC = 'now WAIT_FOR may_run';
2020
TRUNCATE TABLE t1;
2121
connection con1;
22-
ERROR 70100: Query execution was interrupted
22+
Got one of the listed errors
2323
SET DEBUG_SYNC = 'RESET';
2424
DROP TABLE t1;
2525
disconnect con1;

mysql-test/suite/galera/r/MDEV-32938.result

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ connection node_1;
33
connect con1,127.0.0.1,root,,test,$NODE_MYPORT_1;
44
call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
55
CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT) ENGINE=InnoDB;
6-
SET DEBUG_SYNC = 'wsrep_append_fk_toi_keys_before_close_tables SIGNAL may_alter WAIT_FOR bf_abort';
6+
SET DEBUG_SYNC = 'wsrep_append_fk_toi_keys_before_close_tables SIGNAL may_alter';
77
ALTER TABLE t1 DROP COLUMN c2;
88
connection node_1;
99
SET DEBUG_SYNC = 'now WAIT_FOR may_alter';
1010
ALTER TABLE t1 ADD COLUMN c3 INT;
1111
connection con1;
12-
ERROR 70100: Query execution was interrupted
13-
INSERT INTO t1 (c1, c2, c3) VALUES (1, 0, 0);
12+
INSERT INTO t1 (c1, c3) VALUES (1, 0);
1413
connection node_2;
15-
INSERT INTO t1 (c1, c2, c3) VALUES (2, 0, 0);
14+
INSERT INTO t1 (c1, c3) VALUES (2, 0);
1615
connection node_1;
1716
SET DEBUG_SYNC = 'RESET';
1817
DROP TABLE t1;

mysql-test/suite/galera/r/galera_as_slave_ctas.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ connection node_3;
2424
DROP TABLE source;
2525
DROP TABLE target;
2626
connection node_2;
27+
call mtr.add_suppression("WSREP: Inconsistency detected: Inconsistent by consensus on");
28+
call mtr.add_suppression("WSREP: Failed to apply write set: gtid:");
2729
connection node_1;
2830
STOP SLAVE;
2931
RESET SLAVE ALL;
32+
call mtr.add_suppression("WSREP: unexpected async replication event: 0");
3033
connection node_3;
3134
RESET MASTER;

mysql-test/suite/galera/r/galera_bf_abort.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ connection node_2a;
1212
connection node_2;
1313
INSERT INTO t1 VALUES (2, 'node_2');
1414
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
15+
COMMIT;
1516
wsrep_local_aborts_increment
1617
1
1718
DROP TABLE t1;
19+
disconnect node_2;
20+
disconnect node_1;

mysql-test/suite/galera/r/galera_create_table_as_select.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ COUNT(*) = 5
8888
1
8989
CREATE TABLE t1 AS SELECT * FROM t2;
9090
connection node_1;
91-
ERROR 70100: Query execution was interrupted
91+
Got one of the listed errors
9292
SET GLOBAL DEBUG_DBUG = '';
9393
SET DEBUG_SYNC = 'RESET';
9494
DROP TABLE t1, t2;

mysql-test/suite/galera/suite.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ push @::global_suppressions,
6868
qr|WSREP: Trying to continue unpaused monitor|,
6969
qr|WSREP: Wait for gtid returned error 3 while waiting for prior transactions to commit before setting position|,
7070
qr|WSREP: Failed to report last committed|,
71+
qr|bytes freed by|,
7172
);
7273

7374
sub which($) { return `sh -c "command -v $_[0]"` }

mysql-test/suite/galera/t/MDEV-22232.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ TRUNCATE TABLE t1;
3131

3232
--connection con1
3333
# CTAS gets BF aborted.
34-
--error ER_QUERY_INTERRUPTED
34+
--error ER_QUERY_INTERRUPTED, ER_LOCK_DEADLOCK
3535
--reap
3636

3737
# Cleanup
@@ -56,7 +56,7 @@ TRUNCATE TABLE t1;
5656

5757
--connection con1
5858
# CTAS gets BF aborted.
59-
--error ER_QUERY_INTERRUPTED
59+
--error ER_QUERY_INTERRUPTED, ER_LOCK_DEADLOCK
6060
--reap
6161

6262
# Cleanup

mysql-test/suite/galera/t/MDEV-32938.test

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# - after entering TOI mode, it would later find it'd been killed, and complete with an error
1515
# - at the same time, the command would successfully apply on every other node except the initiator.
1616
#
17-
# Fixed by checking killed state on THD before entering TOI.
17+
#
18+
# NOTE : After MDL-lock conflict resolution rework this test behaviour has
19+
# changed.
1820
#
1921

2022
--source include/galera_cluster.inc
@@ -28,26 +30,24 @@ call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
2830
CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT) ENGINE=InnoDB;
2931

3032
# Run ALTER DROP COLUMN and hang before closing tables on adding FK keys and before entering TOI.
31-
# Wait until it gets BF-aborted.
32-
SET DEBUG_SYNC = 'wsrep_append_fk_toi_keys_before_close_tables SIGNAL may_alter WAIT_FOR bf_abort';
33+
SET DEBUG_SYNC = 'wsrep_append_fk_toi_keys_before_close_tables SIGNAL may_alter';
3334
--send
3435
ALTER TABLE t1 DROP COLUMN c2;
3536

3637
--connection node_1
37-
# Run ALTER ADD COLUMN and BF-abort the previous ALTER DROP COLUMN.
38+
# Run ALTER ADD COLUMN
3839
SET DEBUG_SYNC = 'now WAIT_FOR may_alter';
3940
ALTER TABLE t1 ADD COLUMN c3 INT;
4041

4142
--connection con1
42-
# ALTER DROP COLUMN gets BF aborted.
43-
--error ER_QUERY_INTERRUPTED
43+
# ALTER DROP COLUMN waits
4444
--reap
4545

46-
INSERT INTO t1 (c1, c2, c3) VALUES (1, 0, 0);
46+
INSERT INTO t1 (c1, c3) VALUES (1, 0);
4747

4848
--connection node_2
49-
# ALTER DROP COLUMN must not be replicated.
50-
INSERT INTO t1 (c1, c2, c3) VALUES (2, 0, 0);
49+
# ALTER DROP COLUMN must be replicated.
50+
INSERT INTO t1 (c1, c3) VALUES (2, 0);
5151

5252
# Cleanup.
5353
--connection node_1

mysql-test/suite/galera/t/galera_as_slave_ctas.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ DROP TABLE target;
6666
--connection node_2
6767
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target';
6868
--source include/wait_condition.inc
69+
call mtr.add_suppression("WSREP: Inconsistency detected: Inconsistent by consensus on");
70+
call mtr.add_suppression("WSREP: Failed to apply write set: gtid:");
6971

7072
--connection node_1
7173
STOP SLAVE;
7274
RESET SLAVE ALL;
75+
call mtr.add_suppression("WSREP: unexpected async replication event: 0");
7376

7477
--connection node_3
7578
RESET MASTER;

mysql-test/suite/galera/t/galera_bf_abort.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ INSERT INTO t1 VALUES (1,'node_1');
2424
--connection node_2
2525
--error ER_LOCK_DEADLOCK
2626
INSERT INTO t1 VALUES (2, 'node_2');
27+
COMMIT;
2728

2829
--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
2930

@@ -32,3 +33,4 @@ INSERT INTO t1 VALUES (2, 'node_2');
3233
--enable_query_log
3334

3435
DROP TABLE t1;
36+
--source include/galera_end.inc

0 commit comments

Comments
 (0)