mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-10356: rpl.rpl_parallel_temptable failure due to incorrect commit optimization of temptables
The problem was that parallel replication of temporary tables using statement-based binlogging could overlap the COMMIT in one thread with a DML or DROP TEMPORARY TABLE in another thread using the same temporary table. Temporary tables are not safe for concurrent access, so this caused reference to freed memory and possibly other nastiness. The fix is to disable the optimisation with overlapping commits of one transaction with the start of a later transaction, when temporary tables are in use. Then the following event groups will be blocked from starting until the one using temporary tables is completed. This also fixes occasional test failures of rpl.rpl_parallel_temptable seen in Buildbot. Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
@ -218,6 +218,7 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id,
|
||||
waiting for this). In most cases (normal DML), it will be a no-op.
|
||||
*/
|
||||
rgi->mark_start_commit_no_lock();
|
||||
rgi->commit_orderer.wakeup_blocked= false;
|
||||
|
||||
if (entry->last_committed_sub_id < sub_id)
|
||||
{
|
||||
@ -1425,7 +1426,22 @@ handle_rpl_parallel_thread(void *arg)
|
||||
if (!thd->killed)
|
||||
{
|
||||
DEBUG_SYNC(thd, "rpl_parallel_before_mark_start_commit");
|
||||
rgi->mark_start_commit();
|
||||
if (thd->lex->stmt_accessed_temp_table())
|
||||
{
|
||||
/*
|
||||
Temporary tables are special, they require strict
|
||||
single-threaded use as they have no locks protecting concurrent
|
||||
access. Therefore, we cannot safely use the optimization of
|
||||
overlapping the commit of this transaction with the start of the
|
||||
following.
|
||||
So we skip the early mark_start_commit() and also block any
|
||||
wakeup_subsequent_commits() until this event group is fully
|
||||
done, inside finish_event_group().
|
||||
*/
|
||||
rgi->commit_orderer.wakeup_blocked= true;
|
||||
}
|
||||
else
|
||||
rgi->mark_start_commit();
|
||||
DEBUG_SYNC(thd, "rpl_parallel_after_mark_start_commit");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user