MySQL  8.0.21
Source Code Documentation
dict0stats_bg.h File Reference

Code used for background table and index stats gathering. More...

#include "univ.i"
#include "dict0types.h"
#include "os0event.h"
#include "os0thread.h"
#include "dict0stats_bg.ic"

Go to the source code of this file.

Macros

#define DICT_STATS_BG_YIELD(trx)
 Yield the data dictionary latch when waiting for the background thread to stop accessing a table. More...
 

Functions

void dict_stats_recalc_pool_add (const dict_table_t *table)
 Add a table to the recalc pool, which is processed by the background stats gathering thread. More...
 
void dict_stats_recalc_pool_del (const dict_table_t *table)
 Delete a given table from the auto recalc pool. More...
 
UNIV_INLINE bool dict_stats_stop_bg (dict_table_t *table)
 Request the background collection of statistics to stop for a table. More...
 
void dict_stats_wait_bg_to_stop_using_table (dict_table_t *table, trx_t *trx)
 Wait until background stats thread has stopped using the specified table. More...
 
void dict_stats_thread_init ()
 Initialize global variables needed for the operation of dict_stats_thread(). More...
 
void dict_stats_thread_deinit ()
 Free resources allocated by dict_stats_thread_init(), must be called after dict_stats_thread() has exited. More...
 
void dict_stats_disabled_debug_update (THD *thd, SYS_VAR *var, void *var_ptr, const void *save)
 Disables dict stats thread. More...
 
void dict_stats_thread ()
 This is the thread for background stats gathering. More...
 
void dict_stats_shutdown ()
 Shutdown the dict stats thread. More...
 

Variables

os_event_t dict_stats_event
 Event to wake up the stats thread. More...
 
mysql_pfs_key_t dict_stats_recalc_pool_mutex_key
 
bool innodb_dict_stats_disabled_debug
 Value of MySQL global used to disable dict_stats thread. More...
 

Detailed Description

Code used for background table and index stats gathering.

Created Apr 26, 2012 Vasil Dimov

Macro Definition Documentation

◆ DICT_STATS_BG_YIELD

#define DICT_STATS_BG_YIELD (   trx)
Value:
do { \
row_mysql_unlock_data_dictionary(trx); \
os_thread_sleep(250000); \
row_mysql_lock_data_dictionary(trx); \
} while (0)

Yield the data dictionary latch when waiting for the background thread to stop accessing a table.

Parameters
trxtransaction holding the data dictionary locks

Function Documentation

◆ dict_stats_disabled_debug_update()

void dict_stats_disabled_debug_update ( THD thd,
SYS_VAR var,
void *  var_ptr,
const void *  save 
)

Disables dict stats thread.

It's used by: SET GLOBAL innodb_dict_stats_disabled_debug = 1 (0).

Parameters
[in]thdthread handle
[in]varpointer to system variable
[out]var_ptrwhere the formal string goes
[in]saveimmediate result from check function

◆ dict_stats_recalc_pool_add()

void dict_stats_recalc_pool_add ( const dict_table_t table)

Add a table to the recalc pool, which is processed by the background stats gathering thread.

Only the table id is added to the list, so the table can be closed after being enqueued and it will be opened when needed. If the table does not exist later (has been DROPped), then it will be removed from the pool and skipped. in: table to add

Only the table id is added to the list, so the table can be closed after being enqueued and it will be opened when needed. If the table does not exist later (has been DROPped), then it will be removed from the pool and skipped.

Parameters
tablein: table to add

◆ dict_stats_recalc_pool_del()

void dict_stats_recalc_pool_del ( const dict_table_t table)

Delete a given table from the auto recalc pool.

dict_stats_recalc_pool_del() in: table to remove

dict_stats_recalc_pool_del()

Parameters
tablein: table to remove

◆ dict_stats_shutdown()

void dict_stats_shutdown ( )

Shutdown the dict stats thread.

◆ dict_stats_stop_bg()

UNIV_INLINE bool dict_stats_stop_bg ( dict_table_t table)

Request the background collection of statistics to stop for a table.

Return values
truewhen no background process is active
falsewhen it is not safe to modify the table definition
Parameters
tablein/out: table

◆ dict_stats_thread()

void dict_stats_thread ( )

This is the thread for background stats gathering.

It pops tables, from the auto recalc list and proceeds them, eventually recalculating their statistics.

◆ dict_stats_thread_deinit()

void dict_stats_thread_deinit ( )

Free resources allocated by dict_stats_thread_init(), must be called after dict_stats_thread() has exited.

◆ dict_stats_thread_init()

void dict_stats_thread_init ( )

Initialize global variables needed for the operation of dict_stats_thread().

Must be called before dict_stats_thread() is started.

Initialize global variables needed for the operation of dict_stats_thread().

◆ dict_stats_wait_bg_to_stop_using_table()

void dict_stats_wait_bg_to_stop_using_table ( dict_table_t table,
trx_t trx 
)

Wait until background stats thread has stopped using the specified table.

The caller must have locked the data dictionary using row_mysql_lock_data_dictionary() and this function may unlock it temporarily and restore the lock before it exits. The background stats thread is guaranteed not to start using the specified table after this function returns and before the caller unlocks the data dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag under dict_sys->mutex. in/out: transaction to use for unlocking/locking the data dict

The caller must have locked the data dictionary using row_mysql_lock_data_dictionary() and this function may unlock it temporarily and restore the lock before it exits. The background stats thread is guaranteed not to start using the specified table after this function returns and before the caller unlocks the data dictionary because it sets the BG_STAT_IN_PROGRESS bit in table->stats_bg_flag under dict_sys->mutex.

Parameters
tablein/out: table
trxin/out: transaction to use for unlocking/locking the data dict

Variable Documentation

◆ dict_stats_event

os_event_t dict_stats_event

Event to wake up the stats thread.

◆ dict_stats_recalc_pool_mutex_key

mysql_pfs_key_t dict_stats_recalc_pool_mutex_key

◆ innodb_dict_stats_disabled_debug

bool innodb_dict_stats_disabled_debug

Value of MySQL global used to disable dict_stats thread.

Value of MySQL global used to disable dict_stats thread.