@@ -361,17 +361,23 @@ static bool dict_stats_process_entry_from_recalc_pool(THD *thd)
361
361
{
362
362
ut_ad (i->state == recalc::IN_PROGRESS);
363
363
recalc_pool.erase (i);
364
- const bool reschedule= !update_now && recalc_pool.empty ();
365
364
if (err == DB_SUCCESS_LOCKED_REC)
366
365
recalc_pool.emplace_back (recalc{table_id, recalc::IDLE});
367
366
mysql_mutex_unlock (&recalc_pool_mutex);
368
- if (reschedule)
369
- dict_stats_schedule (MIN_RECALC_INTERVAL * 1000 );
370
367
}
371
368
372
369
return update_now;
373
370
}
374
371
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
+
375
381
static tpool::timer* dict_stats_timer;
376
382
static THD *dict_stats_thd;
377
383
static void dict_stats_func (void *)
@@ -385,6 +391,8 @@ static void dict_stats_func(void*)
385
391
386
392
innobase_reset_background_thd (dict_stats_thd);
387
393
set_current_thd (nullptr );
394
+ if (!is_recalc_pool_empty ())
395
+ dict_stats_schedule (MIN_RECALC_INTERVAL * 1000 );
388
396
}
389
397
390
398
@@ -403,7 +411,7 @@ static void dict_stats_schedule(int ms)
403
411
404
412
void dict_stats_schedule_now ()
405
413
{
406
- dict_stats_schedule (10 );
414
+ dict_stats_schedule (0 );
407
415
}
408
416
409
417
/* * Shut down the dict_stats_thread. */
0 commit comments