mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-7818: Deadlock occurring with parallel replication and FTWRL
Problem is that FLUSH TABLES WITH READ LOCK first blocks threads from starting new commits, then waits for running commits to complete. But in-order parallel replication needs commits to happen in a particular order, so this can easily deadlock. To fix this problem, this patch introduces a way to temporarily pause the parallel replication worker threads. Before starting FTWRL, we let all worker threads complete in-progress transactions, and then wait. Then we proceed to take the global read lock. Once the lock is obtained, we unpause the worker threads. Now commits are blocked from starting by the global read lock, so the deadlock will no longer occur.
This commit is contained in:
@ -4284,6 +4284,17 @@ end_with_restore_list:
|
||||
break;
|
||||
}
|
||||
|
||||
if (lex->type & REFRESH_READ_LOCK)
|
||||
{
|
||||
/*
|
||||
We need to pause any parallel replication slave workers during FLUSH
|
||||
TABLES WITH READ LOCK. Otherwise we might cause a deadlock, as
|
||||
worker threads eun run in arbitrary order but need to commit in a
|
||||
specific given order.
|
||||
*/
|
||||
if (rpl_pause_for_ftwrl(thd))
|
||||
goto error;
|
||||
}
|
||||
/*
|
||||
reload_acl_and_cache() will tell us if we are allowed to write to the
|
||||
binlog or not.
|
||||
@ -4314,6 +4325,8 @@ end_with_restore_list:
|
||||
if (!res)
|
||||
my_ok(thd);
|
||||
}
|
||||
if (lex->type & REFRESH_READ_LOCK)
|
||||
rpl_unpause_after_ftwrl(thd);
|
||||
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user