Skip to content

Commit a31598b

Browse files
committed
MDEV-33046 - reschedule dict_stats_func() if there work left to do.
If recalc_pool is not empty, dict_stats needs to be rescheduled. Also revert aff5ed3
1 parent 91a118d commit a31598b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

storage/innobase/dict/dict0stats_bg.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,23 @@ static bool dict_stats_process_entry_from_recalc_pool(THD *thd)
361361
{
362362
ut_ad(i->state == recalc::IN_PROGRESS);
363363
recalc_pool.erase(i);
364-
const bool reschedule= !update_now && recalc_pool.empty();
365364
if (err == DB_SUCCESS_LOCKED_REC)
366365
recalc_pool.emplace_back(recalc{table_id, recalc::IDLE});
367366
mysql_mutex_unlock(&recalc_pool_mutex);
368-
if (reschedule)
369-
dict_stats_schedule(MIN_RECALC_INTERVAL * 1000);
370367
}
371368

372369
return update_now;
373370
}
374371

372+
/** Check if the recalc pool is empty. */
373+
static bool is_recalc_pool_empty()
374+
{
375+
mysql_mutex_lock(&recalc_pool_mutex);
376+
bool empty= recalc_pool.empty();
377+
mysql_mutex_unlock(&recalc_pool_mutex);
378+
return empty;
379+
}
380+
375381
static tpool::timer* dict_stats_timer;
376382
static THD *dict_stats_thd;
377383
static void dict_stats_func(void*)
@@ -385,6 +391,8 @@ static void dict_stats_func(void*)
385391

386392
innobase_reset_background_thd(dict_stats_thd);
387393
set_current_thd(nullptr);
394+
if (!is_recalc_pool_empty())
395+
dict_stats_schedule(MIN_RECALC_INTERVAL * 1000);
388396
}
389397

390398

@@ -403,7 +411,7 @@ static void dict_stats_schedule(int ms)
403411

404412
void dict_stats_schedule_now()
405413
{
406-
dict_stats_schedule(10);
414+
dict_stats_schedule(0);
407415
}
408416

409417
/** Shut down the dict_stats_thread. */

0 commit comments

Comments
 (0)