mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-36840 Seconds_Behind_Master Spike at Log Rotation on Parallel Replica
`Seconds_Behind_Master` unsets from 0 when a
parallel replica processes an internal event.
Est. 8dad51481b
of MDEV-10653, the idle status of the worker
threads directly checks the emptiness of the workers’ queue.
The problem is that the queue could be entirely
internal events that don’t record replicated content.
In contrast, the (main) SQL thread (in both serial and parallel
replicas) uses a state boolean `sql_thread_caught_up` that is
not unset if the event is internal. Therefore, this patch adds
a workers’ equivalent, `worker_threads_caught_up`, that
matches the behaviour of that for the (main) SQL thread.
Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Acked-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
@@ -3069,13 +3069,21 @@ rpl_parallel::stop_during_until()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
rpl_parallel::workers_idle(Relay_log_info *rli)
|
||||
bool Relay_log_info::are_sql_threads_caught_up()
|
||||
{
|
||||
mysql_mutex_assert_owner(&rli->data_lock);
|
||||
return !rli->last_inuse_relaylog ||
|
||||
rli->last_inuse_relaylog->queued_count ==
|
||||
rli->last_inuse_relaylog->dequeued_count;
|
||||
mysql_mutex_assert_owner(&data_lock);
|
||||
if (!sql_thread_caught_up)
|
||||
return false;
|
||||
/*
|
||||
The SQL thread sets @ref worker_threads_caught_up to `false` but not `true`.
|
||||
Therefore, this place needs to check if it can now be `true`.
|
||||
*/
|
||||
if (!worker_threads_caught_up && ( // No need to re-check if already `true`.
|
||||
!last_inuse_relaylog || // `nullptr` case
|
||||
last_inuse_relaylog->queued_count == last_inuse_relaylog->dequeued_count
|
||||
))
|
||||
worker_threads_caught_up= true; // Refresh
|
||||
return worker_threads_caught_up;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user