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.
This commit is contained in:
Monty 2021-02-15 20:21:12 +02:00
parent 8eaf4bc5ec
commit fc5e03f093

View File

@ -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);