From fc5e03f093b80aab41e00cba9b6dd1554a15df6d Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 15 Feb 2021 20:21:12 +0200 Subject: [PATCH] Ignore reporting in thd_progress_report() if we cannot lock LOCK_thd_data The reason for this is that Galera can lock LOCK_thd_data for a long time. Instead of stalling any long running process, like alter or repair table, because of progress reporting, ignore the progress reporting for this call. Progress reporting will continue on the next call after the lock has been released. --- sql/sql_class.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 69e60109d42..500bf50bf9d 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -4641,7 +4641,13 @@ extern "C" void thd_progress_report(MYSQL_THD thd, return; if (thd->progress.max_counter != max_progress) // Simple optimization { - mysql_mutex_lock(&thd->LOCK_thd_data); + /* + Better to not wait in the unlikely event that LOCK_thd_data is locked + as Galera can potentially have this locked for a long time. + Progress counters will fix themselves after the next call. + */ + if (mysql_mutex_trylock(&thd->LOCK_thd_data)) + return; thd->progress.counter= progress; thd->progress.max_counter= max_progress; mysql_mutex_unlock(&thd->LOCK_thd_data);