mirror of
https://github.com/MariaDB/server.git
synced 2026-03-07 00:48:41 +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
561 B
Text
20 lines
561 B
Text
connection node_2;
|
|
connection node_1;
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(6)) ENGINE=InnoDB;
|
|
connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2;
|
|
connection node_2;
|
|
SET AUTOCOMMIT=OFF;
|
|
START TRANSACTION;
|
|
INSERT INTO t1 VALUES (1,'node_2');
|
|
connection node_1;
|
|
INSERT INTO t1 VALUES (1,'node_1');
|
|
connection node_2a;
|
|
connection node_2;
|
|
INSERT INTO t1 VALUES (2, 'node_2');
|
|
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
|
|
COMMIT;
|
|
wsrep_local_aborts_increment
|
|
1
|
|
DROP TABLE t1;
|
|
disconnect node_2;
|
|
disconnect node_1;
|