mirror of
https://github.com/MariaDB/server.git
synced 2026-02-24 11:38:42 +01:00
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
20 lines
651 B
Text
20 lines
651 B
Text
connection node_2;
|
|
connection node_1;
|
|
connect con1,127.0.0.1,root,,test,$NODE_MYPORT_1;
|
|
call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
|
|
CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT) ENGINE=InnoDB;
|
|
SET DEBUG_SYNC = 'wsrep_append_fk_toi_keys_before_close_tables SIGNAL may_alter';
|
|
ALTER TABLE t1 DROP COLUMN c2;
|
|
connection node_1;
|
|
SET DEBUG_SYNC = 'now WAIT_FOR may_alter';
|
|
ALTER TABLE t1 ADD COLUMN c3 INT;
|
|
connection con1;
|
|
INSERT INTO t1 (c1, c3) VALUES (1, 0);
|
|
connection node_2;
|
|
INSERT INTO t1 (c1, c3) VALUES (2, 0);
|
|
connection node_1;
|
|
SET DEBUG_SYNC = 'RESET';
|
|
DROP TABLE t1;
|
|
disconnect con1;
|
|
disconnect node_2;
|
|
disconnect node_1;
|