MySQL 9.1.0
Source Code Documentation
srv0srv.cc File Reference

The database server main program. More...

#include <mysqld.h>
#include <sys/types.h>
#include <time.h>
#include <chrono>
#include <limits>
#include "btr0sea.h"
#include "buf0flu.h"
#include "buf0lru.h"
#include "clone0api.h"
#include "dict0boot.h"
#include "dict0load.h"
#include "dict0stats_bg.h"
#include "fsp0sysspace.h"
#include "ha_prototypes.h"
#include "ibuf0ibuf.h"
#include "lock0lock.h"
#include "log0buf.h"
#include "log0chkp.h"
#include "log0encryption.h"
#include "log0recv.h"
#include "log0write.h"
#include "mem0mem.h"
#include "os0proc.h"
#include "os0thread-create.h"
#include "pars0pars.h"
#include "que0que.h"
#include "row0mysql.h"
#include "sql/sql_class.h"
#include "sql_thd_internal_api.h"
#include "srv0mon.h"
#include "my_dbug.h"
#include "my_psi_config.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "sync0sync.h"
#include "trx0i_s.h"
#include "trx0purge.h"
#include "usr0sess.h"
#include "ut0crc32.h"
#include "ut0mem.h"

Classes

struct  srv_sys_t
 The server system struct. More...
 

Macros

#define MAX_MUTEX_NOWAIT   20
 Maximum number of times allowed to conditionally acquire mutex before switching to blocking wait on the mutex. More...
 
#define MUTEX_NOWAIT(mutex_skipped)   ((mutex_skipped) < MAX_MUTEX_NOWAIT)
 Check whether the number of failed nonblocking mutex acquisition attempts exceeds maximum allowed value. More...
 
#define srv_sys_mutex_enter()
 Acquire the system_mutex. More...
 
#define srv_sys_mutex_own()   (mutex_own(&srv_sys->mutex) && !srv_read_only_mode)
 Test if the system mutex is owned. More...
 
#define srv_sys_mutex_exit()
 Release the system mutex. More...
 

Functions

std::chrono::seconds get_srv_fatal_semaphore_wait_threshold ()
 
std::chrono::microseconds get_srv_log_wait_for_write_timeout ()
 Timeout used when waiting for redo write. More...
 
std::chrono::microseconds get_srv_log_wait_for_flush_timeout ()
 Timeout used when waiting for redo flush. More...
 
std::chrono::microseconds get_srv_log_writer_timeout ()
 Initial timeout used to wait on writer_event. More...
 
std::chrono::milliseconds get_srv_log_checkpoint_every ()
 Period every which a periodical checkpoint is written by the log checkpointer thread (unless periodical checkpoints are disabled, which is a case during initial phase of startup). More...
 
std::chrono::microseconds get_srv_log_flusher_timeout ()
 Initial timeout used to wait on flusher_event. More...
 
std::chrono::microseconds get_srv_log_write_notifier_timeout ()
 Initial timeout used to wait on write_notifier_event. More...
 
std::chrono::microseconds get_srv_log_flush_notifier_timeout ()
 Initial timeout used to wait on flush_notifier_event. More...
 
std::chrono::seconds get_srv_flush_log_at_timeout ()
 
std::chrono::milliseconds get_srv_replication_delay ()
 
static void srv_print_master_thread_info (FILE *file)
 Prints counters for work done by srv_master_thread. More...
 
void srv_set_io_thread_op_info (ulint i, const char *str)
 Sets the info describing an i/o thread current state. More...
 
void srv_reset_io_thread_op_info ()
 Resets the info describing an i/o thread current state. More...
 
static bool srv_thread_type_validate (srv_thread_type type)
 Validates the type of a thread table slot. More...
 
static srv_thread_type srv_slot_get_type (const srv_slot_t *slot)
 Gets the type of a thread table slot. More...
 
static srv_slot_tsrv_reserve_slot (srv_thread_type type)
 Reserves a slot in the thread table for the current thread. More...
 
static int64_t srv_suspend_thread_low (srv_slot_t *slot)
 Suspends the calling thread to wait for the event in its thread slot. More...
 
static int64_t srv_suspend_thread (srv_slot_t *slot)
 Suspends the calling thread to wait for the event in its thread slot. More...
 
ulint srv_release_threads (srv_thread_type type, ulint n)
 Releases threads of the type given from suspension in the thread table. More...
 
static void srv_free_slot (srv_slot_t *slot)
 Release a thread's slot. More...
 
static void srv_init (void)
 Initializes the server. More...
 
void srv_free (void)
 Frees the data structures created in srv_init(). More...
 
static void srv_general_init ()
 Initializes the synchronization primitives, memory system, and the thread local storage. More...
 
void srv_boot (void)
 Boots the InnoDB server. More...
 
static void srv_refresh_innodb_monitor_stats (void)
 Refreshes the values used to calculate per-second averages. More...
 
static void srv_printf_locks_and_transactions (FILE *file, ulint *trx_start_pos)
 Prints info summary and info about all transactions to the file, recording the position where the part about transactions starts. More...
 
bool srv_printf_innodb_monitor (FILE *file, bool nowait, ulint *trx_start_pos, ulint *trx_end)
 Outputs to a file the output of the InnoDB Monitor. More...
 
void srv_export_innodb_status (void)
 Function to pass InnoDB status variables to MySQL. More...
 
void srv_monitor_thread ()
 A thread which prints the info output by various InnoDB monitors. More...
 
void srv_error_monitor_thread ()
 A thread which prints warnings about semaphore waits which have lasted too long. More...
 
void srv_inc_activity_count (void)
 Increment the server activity count. More...
 
bool srv_master_thread_is_active ()
 Check whether the master thread is active. More...
 
void srv_active_wake_master_thread_low ()
 Tells the InnoDB server that there has been activity in the database and wakes up the master thread if it is suspended (not sleeping). More...
 
void srv_wake_purge_thread_if_not_active (void)
 Tells the purge thread that there has been activity in the database and wakes up the purge thread if it is suspended (not sleeping). More...
 
void srv_wake_master_thread (void)
 Wakes up the master thread if it is suspended or being suspended. More...
 
ulint srv_get_activity_count (void)
 Get current server activity count. More...
 
bool srv_check_activity (ulint old_activity_count)
 Check if there has been any activity. More...
 
static ulint srv_master_evict_from_table_cache (ulint pct_check)
 Make room in the table cache by evicting an unused table. More...
 
static void srv_shutdown_print_master_pending (std::chrono::steady_clock::time_point *last_print_time, ulint n_tables_to_drop, ulint n_bytes_merged)
 This function prints progress message every 60 seconds during server shutdown, for any activities that master thread is pending on. More...
 
static void srv_master_do_disabled_loop (void)
 Waits in loop as long as master thread is disabled (debug) More...
 
void srv_master_thread_disabled_debug_update (THD *, SYS_VAR *, void *, const void *save)
 Disables master thread. More...
 
static void srv_update_cpu_usage ()
 
static void srv_master_do_active_tasks (void)
 Perform the tasks that the master thread is supposed to do when the server is active. More...
 
static void srv_master_do_idle_tasks (void)
 Perform the tasks that the master thread is supposed to do whenever the server is idle. More...
 
static bool srv_master_do_pre_dd_shutdown_tasks (std::chrono::steady_clock::time_point *last_print_time)
 Perform the tasks during pre_dd_shutdown phase. More...
 
static bool srv_master_do_shutdown_tasks (std::chrono::steady_clock::time_point *last_print_time)
 Perform the tasks during shutdown. More...
 
bool srv_enable_redo_encryption ()
 Enable REDO log encryption. More...
 
bool set_undo_tablespace_encryption (space_id_t space_id, mtr_t *mtr)
 Set encryption for UNDO tablespace with given space id. More...
 
bool srv_enable_undo_encryption ()
 Enable UNDO tablespaces encryption. More...
 
static void srv_master_sleep (void)
 Puts master thread to sleep. More...
 
static void srv_master_wait (srv_slot_t *slot)
 Waits on event in provided slot. More...
 
static void srv_master_main_loop (srv_slot_t *slot)
 Executes the main loop of the master thread. More...
 
static void srv_master_pre_dd_shutdown_loop ()
 Executes pre_dd_shutdown tasks in the master thread. More...
 
static void srv_master_shutdown_loop ()
 Executes shutdown tasks in the master thread. More...
 
void srv_master_thread ()
 The master thread controlling the server. More...
 
static bool srv_purge_should_exit (ulint n_purged)
 Check if purge should stop. More...
 
static bool srv_task_execute (void)
 Fetch and execute a task from the work queue. More...
 
void srv_worker_thread ()
 Worker thread that reads tasks from the work queue and executes them. More...
 
static ulint srv_do_purge (ulint *n_total_purged)
 Do the actual purge operation. More...
 
static void srv_purge_coordinator_suspend (srv_slot_t *slot, ulint rseg_history_len)
 Suspend the purge coordinator thread. More...
 
void srv_purge_coordinator_thread ()
 Purge coordinator thread that schedules the purge tasks. More...
 
void srv_que_task_enqueue_low (que_thr_t *thr)
 Enqueues a task to server task queue and releases a worker thread, if there is a suspended one. More...
 
ulint srv_get_task_queue_length (void)
 Get count of tasks in the queue. More...
 
void srv_purge_wakeup (void)
 Wakeup the purge threads. More...
 
bool srv_purge_threads_active ()
 Check if the purge threads are active, both coordinator and worker threads. More...
 
bool srv_thread_is_active (const IB_thread &thread)
 Check if given thread is still active. More...
 
bool srv_thread_is_stopped (const IB_thread &thread)
 Check if given thread is cleaned-up and stopped. More...
 
const char * srv_get_server_errmsgs (int errcode)
 Get the format string for the logger. More...
 
void set_srv_redo_log (bool enable)
 Set redo log variable for performance schema global status. More...
 

Variables

Srv_threads srv_threads
 Structure with state of srv background threads. More...
 
Srv_cpu_usage srv_cpu_usage
 Structure with cpu usage information. More...
 
bool srv_downgrade_partition_files = false
 
ulong srv_fatal_semaphore_wait_threshold = 600
 
std::atomic< int > srv_fatal_semaphore_wait_extend {0}
 
ulint srv_dml_needed_delay = 0
 
const char * srv_main_thread_op_info = ""
 
char * srv_data_home = nullptr
 
char * srv_doublewrite_dir = nullptr
 Separate directory for doublewrite files, if it is not NULL. More...
 
char * srv_innodb_directories = nullptr
 The innodb_directories variable value. More...
 
uint32_t srv_rseg_init_threads = 1
 Number of threads spawned for initializing rollback segments in parallel. More...
 
char * srv_undo_dir = nullptr
 Undo tablespace directories. More...
 
ulong srv_undo_tablespaces = FSP_IMPLICIT_UNDO_TABLESPACES
 The number of implicit undo tablespaces to use for rollback segments. More...
 
ulong srv_rollback_segments = TRX_SYS_N_RSEGS
 The number of rollback segments per tablespace. More...
 
ulong srv_undo_logs = 0
 
const char * deprecated_undo_logs
 
ulong srv_purge_rseg_truncate_frequency
 Rate at which UNDO records should be purged. More...
 
bool srv_undo_log_truncate = false
 Enable or Disable Truncate of UNDO tablespace. More...
 
bool srv_undo_log_encrypt = false
 Enable or disable Encrypt of UNDO tablespace. More...
 
unsigned long long srv_max_undo_tablespace_size
 Maximum size of undo tablespace. More...
 
const size_t CONCURRENT_UNDO_TRUNCATE_LIMIT
 Maximum number of recently truncated undo tablespace IDs for the same undo number. More...
 
bool srv_read_only_mode
 Set if InnoDB must operate in read-only mode. More...
 
bool srv_file_per_table
 store to its own file each table created by an user; data dictionary tables are in the system tablespace 0 More...
 
ulong srv_sort_buf_size = 1048576
 Sort buffer size in index creation. More...
 
unsigned long long srv_online_max_size
 Maximum modification log file size for online index creation. More...
 
bool high_level_read_only
 Set if InnoDB operates in read-only mode or innodb-force-recovery is greater than SRV_FORCE_NO_TRX_UNDO. More...
 
ulong srv_parallel_read_threads
 Number of threads to use for parallel reads. More...
 
bool srv_use_native_aio = false
 If this flag is true, then we will use the native aio of the OS (provided we compiled Innobase with it in), otherwise we will use simulated aio we build below with threads. More...
 
bool srv_numa_interleave = false
 
ulong srv_debug_compress
 Force all user tables to use page compression. More...
 
bool innodb_calling_exit
 Set when InnoDB has invoked exit(). More...
 
bool srv_master_thread_disabled_debug
 Used by SET GLOBAL innodb_master_thread_disabled_debug = X. More...
 
static os_event_t srv_master_thread_disabled_event
 Event used to inform that master thread is disabled. More...
 
char * srv_log_group_home_dir = nullptr
 
bool srv_redo_log_encrypt = false
 Enable or disable Encrypt of REDO tablespace. More...
 
ulong srv_log_n_files = 100
 Value of innodb_log_files_in_group. More...
 
ulonglong srv_log_file_size
 Value of innodb_log_file_size. More...
 
ulonglong srv_redo_log_capacity
 Value of innodb_redo_log_capacity. More...
 
ulonglong srv_redo_log_capacity_used
 Assumed value of innodb_redo_log_capacity's - value which is used. More...
 
ulong srv_log_buffer_size
 Space for log buffer, expressed in bytes. More...
 
ulong srv_log_write_ahead_size
 Size of block, used for writing ahead to avoid read-on-write. More...
 
bool srv_log_writer_threads
 Whether to activate/pause the log writer threads. More...
 
uint srv_log_spin_cpu_abs_lwm
 Minimum absolute value of cpu time for which spin-delay is used. More...
 
uint srv_log_spin_cpu_pct_hwm
 Maximum percentage of cpu time for which spin-delay is used. More...
 
ulong srv_log_wait_for_flush_spin_hwm
 Maximum value of average log flush time for which spin-delay is used. More...
 
ulong srv_log_write_max_size = INNODB_LOG_WRITE_MAX_SIZE_DEFAULT
 When log writer follows links in the log recent written buffer, it stops when it has reached at least that many bytes to write, limiting how many bytes can be written in single call. More...
 
ulong srv_log_write_events = INNODB_LOG_EVENTS_DEFAULT
 Number of events used for notifications about redo write. More...
 
ulong srv_log_flush_events = INNODB_LOG_EVENTS_DEFAULT
 Number of events used for notifications about redo flush. More...
 
ulong srv_log_recent_written_size = INNODB_LOG_RECENT_WRITTEN_SIZE_DEFAULT
 Number of slots in a small buffer, which is used to allow concurrent writes to log buffer. More...
 
ulong srv_buf_flush_list_added_size = INNODB_BUF_FLUSH_LIST_ADDED_SIZE_DEFAULT
 Number of slots in a small buffer, which is used to break requirement for total order of dirty pages, when they are added to flush lists. More...
 
ulong srv_log_wait_for_write_spin_delay
 Number of spin iterations, when spinning and waiting for log buffer written up to given LSN, before we fallback to loop with sleeps. More...
 
ulong srv_log_wait_for_write_timeout
 Timeout used when waiting for redo write (microseconds). More...
 
ulong srv_log_wait_for_flush_spin_delay
 Number of spin iterations, when spinning and waiting for log flushed. More...
 
ulong srv_log_wait_for_flush_timeout
 Timeout used when waiting for redo flush (microseconds). More...
 
ulong srv_log_writer_spin_delay = INNODB_LOG_WRITER_SPIN_DELAY_DEFAULT
 Number of spin iterations, for which log writer thread is waiting for new data to write or flush without sleeping. More...
 
ulong srv_log_writer_timeout = INNODB_LOG_WRITER_TIMEOUT_DEFAULT
 Initial timeout used to wait on writer_event. More...
 
ulong srv_log_checkpoint_every = INNODB_LOG_CHECKPOINT_EVERY_DEFAULT
 Number of milliseconds every which a periodical checkpoint is written by the log checkpointer thread (unless periodical checkpoints are disabled, which is a case during initial phase of startup). More...
 
ulong srv_log_flusher_spin_delay = INNODB_LOG_FLUSHER_SPIN_DELAY_DEFAULT
 Number of spin iterations, for which log flusher thread is waiting for new data to flush, without sleeping. More...
 
ulong srv_log_flusher_timeout = INNODB_LOG_FLUSHER_TIMEOUT_DEFAULT
 Initial timeout used to wait on flusher_event. More...
 
ulong srv_log_write_notifier_spin_delay
 Number of spin iterations, for which log write notifier thread is waiting for advanced flushed_to_disk_lsn without sleeping. More...
 
ulong srv_log_write_notifier_timeout
 Initial timeout used to wait on write_notifier_event. More...
 
ulong srv_log_flush_notifier_spin_delay
 Number of spin iterations, for which log flush notifier thread is waiting for advanced flushed_to_disk_lsn without sleeping. More...
 
ulong srv_log_flush_notifier_timeout
 Initial timeout used to wait on flush_notifier_event. More...
 
bool srv_log_checksums
 Whether to generate and require checksums on the redo log pages. More...
 
bool srv_checkpoint_disabled = false
 If true then disable checkpointing. More...
 
bool srv_inject_too_many_concurrent_trxs = false
 
ulong srv_flush_log_at_trx_commit = 1
 
uint srv_flush_log_at_timeout = 1
 
ulong srv_page_size = UNIV_PAGE_SIZE_DEF
 
ulong srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_DEF
 
page_size_t univ_page_size (0, 0, false)
 
bool srv_adaptive_flushing = true
 
bool srv_flush_sync = true
 
bool srv_dedicated_server = true
 Dedicated server setting. More...
 
ulint srv_buf_pool_size = ULINT_MAX
 Requested size in bytes. More...
 
const ulint srv_buf_pool_min_size = 5 * 1024 * 1024
 Minimum pool size in bytes. More...
 
const ulint srv_buf_pool_def_size = 128 * 1024 * 1024
 Default pool size in bytes. More...
 
const longlong srv_buf_pool_max_size = LLONG_MAX
 Maximum pool size in bytes. More...
 
ulonglong srv_buf_pool_chunk_unit
 Requested buffer pool chunk size. More...
 
const ulonglong srv_buf_pool_chunk_unit_min = (1024 * 1024)
 Minimum buffer pool chunk size. More...
 
const ulonglong srv_buf_pool_chunk_unit_blk_sz = (1024 * 1024)
 The buffer pool chunk size must be a multiple of this number. More...
 
const ulonglong srv_buf_pool_chunk_unit_max
 Maximum buffer pool chunk size. More...
 
ulong srv_buf_pool_instances
 Requested number of buffer pool instances. More...
 
const ulong srv_buf_pool_instances_default = 0
 Default number of buffer pool instances. More...
 
ulong srv_n_page_hash_locks = 16
 Number of locks to protect buf_pool->page_hash. More...
 
bool srv_validate_tablespace_paths = true
 Whether to validate InnoDB tablespace paths on startup. More...
 
bool srv_use_fdatasync = false
 Use fdatasync() instead of fsync(). More...
 
ulong srv_LRU_scan_depth = 1024
 Scan depth for LRU flush batch i.e. More...
 
ulong srv_flush_neighbors = 1
 Whether or not to flush neighbors of a block. More...
 
ulint srv_buf_pool_old_size = 0
 Previously requested size. More...
 
ulint srv_buf_pool_base_size = 0
 Current size as scaling factor for the other components. More...
 
long long srv_buf_pool_curr_size = 0
 Current size in bytes. More...
 
ulong srv_buf_pool_dump_pct
 Dump this % of each buffer pool during BP dump. More...
 
ulint srv_lock_table_size = ULINT_MAX
 Lock table size in bytes. More...
 
const ulong srv_idle_flush_pct_default = 100
 Default value of srv_idle_flush_pct. More...
 
ulong srv_idle_flush_pct = srv_idle_flush_pct_default
 How much flush to be done in case of server is idle. More...
 
ulong srv_n_read_io_threads
 
ulong srv_n_write_io_threads
 
bool srv_random_read_ahead = false
 
ulong srv_read_ahead_threshold = 56
 
uint srv_change_buffer_max_size = CHANGE_BUFFER_DEFAULT_SIZE
 Maximum on-disk size of change buffer in terms of percentage of the buffer pool. More...
 
enum srv_unix_flush_t srv_unix_file_flush_method = SRV_UNIX_FSYNC
 
ulong srv_io_capacity = 200
 
ulong srv_max_io_capacity = 400
 
ulong srv_n_page_cleaners = 4
 
double srv_max_buf_pool_modified_pct = 75.0
 
double srv_max_dirty_pages_pct_lwm = 0.0
 
ulong srv_adaptive_flushing_lwm = 10
 
ulong srv_flushing_avg_loops = 30
 
ulong srv_n_purge_threads = 4
 
ulong srv_purge_batch_size = 20
 
ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL
 
bool tbsp_extend_and_initialize = true
 Enable or disable writing of NULLs while extending a tablespace. More...
 
srv_stats_t srv_stats
 Global counters. More...
 
export_var_t export_vars
 Status variables to be passed to MySQL. More...
 
ulong srv_force_recovery
 Normally 0. More...
 
ulong srv_force_recovery_crash
 Inject a crash at different steps of the recovery process. More...
 
bool srv_print_all_deadlocks = false
 Print all user-level transactions deadlocks to mysqld stderr. More...
 
bool srv_print_ddl_logs = false
 Print all DDL logs to mysqld stderr. More...
 
bool srv_cmp_per_index_enabled = false
 Enable INFORMATION_SCHEMA.innodb_cmp_per_index. More...
 
bool srv_redo_log = true
 If innodb redo logging is enabled. More...
 
ulong srv_fast_shutdown
 The value of the configuration parameter innodb_fast_shutdown, controlling the InnoDB shutdown. More...
 
bool srv_innodb_status = false
 
unsigned long long srv_stats_transient_sample_pages = 8
 
bool srv_stats_persistent = true
 
bool srv_stats_include_delete_marked = false
 
unsigned long long srv_stats_persistent_sample_pages = 20
 
bool srv_stats_auto_recalc = true
 
ulong srv_replication_delay = 0
 
ulong srv_n_spin_wait_rounds = 30
 
ulong srv_spin_wait_delay = 6
 
bool srv_priority_boost = true
 
static ulint srv_n_rows_inserted_old = 0
 
static ulint srv_n_rows_updated_old = 0
 
static ulint srv_n_rows_deleted_old = 0
 
static ulint srv_n_rows_read_old = 0
 
static ulint srv_n_system_rows_inserted_old = 0
 
static ulint srv_n_system_rows_updated_old = 0
 
static ulint srv_n_system_rows_deleted_old = 0
 
static ulint srv_n_system_rows_read_old = 0
 
ulint srv_truncated_status_writes = 0
 
bool srv_print_innodb_monitor = false
 
std::atomic_uint32_t srv_innodb_needs_monitoring {0}
 In contrast to srv_print_innodb_monitor which is controlled by the user, this variable is controlled by InnoDB itself: if some module of InnoDB decides it would be good to print the monitoring information it increments this value, and decrements it when it no longer needs it. More...
 
bool srv_print_innodb_lock_monitor = false
 
const char * srv_io_thread_op_info [SRV_MAX_N_IO_THREADS]
 
const char * srv_io_thread_function [SRV_MAX_N_IO_THREADS]
 
static std::chrono::steady_clock::time_point srv_monitor_stats_refreshed_at
 
static ib_mutex_t srv_innodb_monitor_mutex
 
ib_mutex_t page_zip_stat_per_index_mutex
 Mutex protecting page_zip_stat_per_index. More...
 
ib_mutex_t srv_monitor_file_mutex
 
FILE * srv_monitor_file
 Temporary file for innodb monitor output. More...
 
ib_mutex_t srv_misc_tmpfile_mutex
 Mutex for locking srv_misc_tmpfile. More...
 
FILE * srv_misc_tmpfile
 Temporary file for miscellaneous diagnostic output. More...
 
static ulint srv_main_thread_process_no = 0
 
static std::thread::id srv_main_thread_id {}
 
static ulint srv_main_active_loops = 0
 Iterations of the loop bounded by 'srv_active' label. More...
 
static ulint srv_main_idle_loops = 0
 Iterations of the loop bounded by the 'srv_idle' label. More...
 
static ulint srv_main_shutdown_loops = 0
 Iterations of the loop bounded by the 'srv_shutdown' label. More...
 
static ulint srv_log_writes_and_flush = 0
 Log writes involving flush. More...
 
constexpr std::chrono::seconds SRV_MASTER_DICT_LRU_INTERVAL {47}
 
static srv_sys_tsrv_sys = nullptr
 
os_event_t srv_monitor_event
 Event to signal the monitor thread. More...
 
os_event_t srv_error_event
 Event to signal the error thread. More...
 
os_event_t srv_buf_dump_event
 Event to signal the buffer pool dump/load thread. More...
 
os_event_t srv_buf_resize_event
 Event to signal the buffer pool resize thread. More...
 
char * srv_buf_dump_filename
 The buffer pool dump/load file name. More...
 
bool srv_buffer_pool_dump_at_shutdown = true
 Boolean config knobs that tell InnoDB to dump the buffer pool at shutdown and/or load it during startup. More...
 
bool srv_buffer_pool_load_at_startup = true
 
static const ulint SRV_PURGE_SLOT = 1
 Slot index in the srv_sys->sys_threads array for the purge thread. More...
 
static const ulint SRV_MASTER_SLOT = 0
 Slot index in the srv_sys->sys_threads array for the master thread. More...
 
PSI_stage_info srv_stage_alter_table_end
 Performance schema stage event for monitoring ALTER TABLE progress everything after flush log_make_latest_checkpoint(). More...
 
PSI_stage_info srv_stage_alter_table_flush
 Performance schema stage event for monitoring ALTER TABLE progress log_make_latest_checkpoint(). More...
 
PSI_stage_info srv_stage_alter_table_insert
 Performance schema stage event for monitoring ALTER TABLE progress. More...
 
PSI_stage_info srv_stage_alter_table_log_index
 Performance schema stage event for monitoring ALTER TABLE progress row_log_apply(). More...
 
PSI_stage_info srv_stage_alter_table_log_table
 Performance schema stage event for monitoring ALTER TABLE progress row_log_table_apply(). More...
 
PSI_stage_info srv_stage_alter_table_merge_sort
 Performance schema stage event for monitoring ALTER TABLE progress. More...
 
PSI_stage_info srv_stage_alter_table_read_pk_internal_sort
 Performance schema stage event for monitoring ALTER TABLE progress. More...
 
PSI_stage_info srv_stage_alter_tablespace_encryption
 Performance schema stage event for monitoring ALTER TABLESPACE ENCRYPTION progress. More...
 
PSI_stage_info srv_stage_buffer_pool_load
 Performance schema stage event for monitoring buffer pool load progress. More...
 
PSI_stage_info srv_stage_clone_file_copy
 Performance schema stage event for monitoring clone file copy progress. More...
 
PSI_stage_info srv_stage_clone_redo_copy
 Performance schema stage event for monitoring clone redo copy progress. More...
 
PSI_stage_info srv_stage_clone_page_copy
 Performance schema stage event for monitoring clone page copy progress. More...
 

Detailed Description

The database server main program.

Created 10/8/1995 Heikki Tuuri

Macro Definition Documentation

◆ MAX_MUTEX_NOWAIT

#define MAX_MUTEX_NOWAIT   20

Maximum number of times allowed to conditionally acquire mutex before switching to blocking wait on the mutex.

◆ MUTEX_NOWAIT

#define MUTEX_NOWAIT (   mutex_skipped)    ((mutex_skipped) < MAX_MUTEX_NOWAIT)

Check whether the number of failed nonblocking mutex acquisition attempts exceeds maximum allowed value.

If so, srv_printf_innodb_monitor() will request mutex acquisition with mutex_enter(), which will wait until it gets the mutex.

◆ srv_sys_mutex_enter

#define srv_sys_mutex_enter ( )
Value:
do { \
mutex_enter(&srv_sys->mutex); \
} while (0)
static srv_sys_t * srv_sys
Definition: srv0srv.cc:777
ib_mutex_t mutex
variable protecting the fields below.
Definition: srv0srv.cc:762

Acquire the system_mutex.

◆ srv_sys_mutex_exit

#define srv_sys_mutex_exit ( )
Value:
do { \
mutex_exit(&srv_sys->mutex); \
} while (0)

Release the system mutex.

◆ srv_sys_mutex_own

#define srv_sys_mutex_own ( )    (mutex_own(&srv_sys->mutex) && !srv_read_only_mode)

Test if the system mutex is owned.

Function Documentation

◆ get_srv_fatal_semaphore_wait_threshold()

std::chrono::seconds get_srv_fatal_semaphore_wait_threshold ( )

◆ get_srv_flush_log_at_timeout()

std::chrono::seconds get_srv_flush_log_at_timeout ( )

◆ get_srv_log_checkpoint_every()

std::chrono::milliseconds get_srv_log_checkpoint_every ( )

Period every which a periodical checkpoint is written by the log checkpointer thread (unless periodical checkpoints are disabled, which is a case during initial phase of startup).

◆ get_srv_log_flush_notifier_timeout()

std::chrono::microseconds get_srv_log_flush_notifier_timeout ( )

Initial timeout used to wait on flush_notifier_event.

◆ get_srv_log_flusher_timeout()

std::chrono::microseconds get_srv_log_flusher_timeout ( )

Initial timeout used to wait on flusher_event.

◆ get_srv_log_wait_for_flush_timeout()

std::chrono::microseconds get_srv_log_wait_for_flush_timeout ( )

Timeout used when waiting for redo flush.

◆ get_srv_log_wait_for_write_timeout()

std::chrono::microseconds get_srv_log_wait_for_write_timeout ( )

Timeout used when waiting for redo write.

◆ get_srv_log_write_notifier_timeout()

std::chrono::microseconds get_srv_log_write_notifier_timeout ( )

Initial timeout used to wait on write_notifier_event.

◆ get_srv_log_writer_timeout()

std::chrono::microseconds get_srv_log_writer_timeout ( )

Initial timeout used to wait on writer_event.

◆ get_srv_replication_delay()

std::chrono::milliseconds get_srv_replication_delay ( )

◆ set_srv_redo_log()

void set_srv_redo_log ( bool  enable)

Set redo log variable for performance schema global status.

Parameters
[in]enabletrue => redo log enabled, false => redo log disabled

◆ set_undo_tablespace_encryption()

bool set_undo_tablespace_encryption ( space_id_t  space_id,
mtr_t mtr 
)

Set encryption for UNDO tablespace with given space id.

Parameters
[in]space_idUndo tablespace id
[in]mtrMini-transaction
Returns
false for success, true otherwise

◆ srv_active_wake_master_thread_low()

void srv_active_wake_master_thread_low ( void  )

Tells the InnoDB server that there has been activity in the database and wakes up the master thread if it is suspended (not sleeping).

Tells the Innobase server that there has been activity in the database and wakes up the master thread if it is suspended (not sleeping).

Used in the MySQL interface. Note that there is a small chance that the master thread stays suspended (we do not protect our operation with the srv_sys_t->mutex, for performance reasons).

◆ srv_boot()

void srv_boot ( void  )

Boots the InnoDB server.

Boots Innobase server.

◆ srv_check_activity()

bool srv_check_activity ( ulint  old_activity_count)

Check if there has been any activity.

Returns
false if no change in activity counter.
Parameters
old_activity_countin: old activity count

◆ srv_do_purge()

static ulint srv_do_purge ( ulint n_total_purged)
static

Do the actual purge operation.

Parameters
[in,out]n_total_purgedTotal pages purged in this call
Returns
length of history list before the last purge batch.

◆ srv_enable_redo_encryption()

bool srv_enable_redo_encryption ( )

Enable REDO log encryption.

Returns
false for success, true otherwise.

◆ srv_enable_undo_encryption()

bool srv_enable_undo_encryption ( )

Enable UNDO tablespaces encryption.

Returns
false for success, true otherwise.

◆ srv_error_monitor_thread()

void srv_error_monitor_thread ( )

A thread which prints warnings about semaphore waits which have lasted too long.

These can be used to track bugs which cause hangs.

◆ srv_export_innodb_status()

void srv_export_innodb_status ( void  )

Function to pass InnoDB status variables to MySQL.

◆ srv_free()

void srv_free ( void  )

Frees the data structures created in srv_init().

◆ srv_free_slot()

static void srv_free_slot ( srv_slot_t slot)
static

Release a thread's slot.

Parameters
slotin/out: thread slot

◆ srv_general_init()

static void srv_general_init ( )
static

Initializes the synchronization primitives, memory system, and the thread local storage.

◆ srv_get_activity_count()

ulint srv_get_activity_count ( void  )

Get current server activity count.

We don't hold srv_sys::mutex while reading this value as it is only used in heuristics.

Returns
activity count.

◆ srv_get_server_errmsgs()

const char * srv_get_server_errmsgs ( int  errcode)

Get the format string for the logger.

Parameters
[in]errcodeThe error code from share/errmsg-*.txt
Returns
the message string or nullptr

◆ srv_get_task_queue_length()

ulint srv_get_task_queue_length ( void  )

Get count of tasks in the queue.

Returns
number of tasks in queue

◆ srv_inc_activity_count()

void srv_inc_activity_count ( void  )

Increment the server activity count.

Increment the server activity counter.

◆ srv_init()

static void srv_init ( void  )
static

Initializes the server.

◆ srv_master_do_active_tasks()

static void srv_master_do_active_tasks ( void  )
static

Perform the tasks that the master thread is supposed to do when the server is active.

There are two types of tasks. The first category is of such tasks which are performed at each invocation of this function. We assume that this function is called roughly every second when the server is active. The second category is of such tasks which are performed at some interval e.g.: purge, dict_LRU cleanup etc.

◆ srv_master_do_disabled_loop()

static void srv_master_do_disabled_loop ( void  )
static

Waits in loop as long as master thread is disabled (debug)

◆ srv_master_do_idle_tasks()

static void srv_master_do_idle_tasks ( void  )
static

Perform the tasks that the master thread is supposed to do whenever the server is idle.

We do check for the server state during this function and if the server has entered the shutdown phase we may return from the function without completing the required tasks. Note that the server can move to active state when we are executing this function but we don't check for that as we are suppose to perform more or less same tasks when server is active.

◆ srv_master_do_pre_dd_shutdown_tasks()

static bool srv_master_do_pre_dd_shutdown_tasks ( std::chrono::steady_clock::time_point *  last_print_time)
static

Perform the tasks during pre_dd_shutdown phase.

The tasks that we do depend on srv_fast_shutdown: 2 => very fast shutdown => do no book keeping 0, 1 => normal or slow shutdown => clear drop table queue

Parameters
[in,out]last_print_timelast time log message (about pending operations of shutdown) was printed
Returns
true if there might be some work left to be done, false otherwise
Parameters
last_print_timelast time the function print the message

◆ srv_master_do_shutdown_tasks()

static bool srv_master_do_shutdown_tasks ( std::chrono::steady_clock::time_point *  last_print_time)
static

Perform the tasks during shutdown.

The tasks that we do at shutdown depend on srv_fast_shutdown: 1, 2 => very fast shutdown => do no book keeping 0 => slow shutdown => do ibuf merge

Parameters
[in,out]last_print_timelast time log message (about pending operations of shutdown) was printed
Returns
true if there might be some work left to be done, false otherwise
Parameters
last_print_timelast time the function print the message

◆ srv_master_evict_from_table_cache()

static ulint srv_master_evict_from_table_cache ( ulint  pct_check)
static

Make room in the table cache by evicting an unused table.

Returns
number of tables evicted.
Parameters
pct_checkin: max percent to check

◆ srv_master_main_loop()

static void srv_master_main_loop ( srv_slot_t slot)
static

Executes the main loop of the master thread.

Parameters
[in]slotslot reserved as SRV_MASTER

◆ srv_master_pre_dd_shutdown_loop()

static void srv_master_pre_dd_shutdown_loop ( )
static

Executes pre_dd_shutdown tasks in the master thread.

◆ srv_master_shutdown_loop()

static void srv_master_shutdown_loop ( )
static

Executes shutdown tasks in the master thread.

◆ srv_master_sleep()

static void srv_master_sleep ( void  )
static

Puts master thread to sleep.

At this point we are using polling to service various activities. Master thread sleeps for one second before checking the state of the server again

◆ srv_master_thread()

void srv_master_thread ( )

The master thread controlling the server.

◆ srv_master_thread_disabled_debug_update()

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

Disables master thread.

It's used by: SET GLOBAL innodb_master_thread_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

◆ srv_master_thread_is_active()

bool srv_master_thread_is_active ( )

Check whether the master thread is active.

This is polled during the final phase of shutdown. The first phase of server shutdown must have already been executed (or the server must not have been fully started up).

See also
srv_pre_dd_shutdown()
Return values
trueif any thread is active
falseif no thread is active

◆ srv_master_wait()

static void srv_master_wait ( srv_slot_t slot)
static

Waits on event in provided slot.

Parameters
[in]slotslot reserved as SRV_MASTER

◆ srv_monitor_thread()

void srv_monitor_thread ( )

A thread which prints the info output by various InnoDB monitors.

◆ srv_print_master_thread_info()

static void srv_print_master_thread_info ( FILE *  file)
static

Prints counters for work done by srv_master_thread.

◆ srv_printf_innodb_monitor()

bool srv_printf_innodb_monitor ( FILE *  file,
bool  nowait,
ulint trx_start,
ulint trx_end 
)

Outputs to a file the output of the InnoDB Monitor.

Parameters
[in]fileoutput stream
[in]nowaitwhether to wait for the exclusive global lock_sys latch
[out]trx_startfile position of the start of the list of active transactions
[out]trx_endfile position of the end of the list of active transactions
Returns
false if not all information printed due to failure to obtain necessary mutex

◆ srv_printf_locks_and_transactions()

static void srv_printf_locks_and_transactions ( FILE *  file,
ulint trx_start_pos 
)
static

Prints info summary and info about all transactions to the file, recording the position where the part about transactions starts.

Parameters
[in]fileoutput stream
[out]trx_start_posfile position of the start of the list of active transactions

◆ srv_purge_coordinator_suspend()

static void srv_purge_coordinator_suspend ( srv_slot_t slot,
ulint  rseg_history_len 
)
static

Suspend the purge coordinator thread.

Maximum wait time on the purge event.

Parameters
slotin/out: Purge coordinator thread slot
rseg_history_lenin: history list length before last purge

◆ srv_purge_coordinator_thread()

void srv_purge_coordinator_thread ( )

Purge coordinator thread that schedules the purge tasks.

◆ srv_purge_should_exit()

static bool srv_purge_should_exit ( ulint  n_purged)
static

Check if purge should stop.

Returns
true if it should shutdown.
Parameters
n_purgedin: pages purged in last batch

◆ srv_purge_threads_active()

bool srv_purge_threads_active ( )

Check if the purge threads are active, both coordinator and worker threads.

Returns
true if any thread is active, false if no thread is active

◆ srv_purge_wakeup()

void srv_purge_wakeup ( void  )

Wakeup the purge threads.

◆ srv_que_task_enqueue_low()

void srv_que_task_enqueue_low ( que_thr_t thr)

Enqueues a task to server task queue and releases a worker thread, if there is a suspended one.

in: query thread

Parameters
thrin: query thread

◆ srv_refresh_innodb_monitor_stats()

static void srv_refresh_innodb_monitor_stats ( void  )
static

Refreshes the values used to calculate per-second averages.

◆ srv_release_threads()

ulint srv_release_threads ( srv_thread_type  type,
ulint  n 
)

Releases threads of the type given from suspension in the thread table.

NOTE! The server mutex has to be reserved by the caller!

Returns
number of threads released: this may be less than n if not enough threads were suspended at the moment.
Parameters
typein: thread type
nin: number of threads to release

◆ srv_reserve_slot()

static srv_slot_t * srv_reserve_slot ( srv_thread_type  type)
static

Reserves a slot in the thread table for the current thread.

Returns
reserved slot
Parameters
typein: type of the thread

◆ srv_reset_io_thread_op_info()

void srv_reset_io_thread_op_info ( )

Resets the info describing an i/o thread current state.

◆ srv_set_io_thread_op_info()

void srv_set_io_thread_op_info ( ulint  i,
const char *  str 
)

Sets the info describing an i/o thread current state.

Parameters
[in]iThe 'segment' of the i/o thread
[in]strConstant char string describing the state

◆ srv_shutdown_print_master_pending()

static void srv_shutdown_print_master_pending ( std::chrono::steady_clock::time_point *  last_print_time,
ulint  n_tables_to_drop,
ulint  n_bytes_merged 
)
static

This function prints progress message every 60 seconds during server shutdown, for any activities that master thread is pending on.

Parameters
last_print_timelast time the function print the message
n_tables_to_dropnumber of tables to be dropped
n_bytes_mergednumber of change buffer just merged

◆ srv_slot_get_type()

static srv_thread_type srv_slot_get_type ( const srv_slot_t slot)
static

Gets the type of a thread table slot.

Returns
thread type
Parameters
slotin: thread slot

◆ srv_suspend_thread()

static int64_t srv_suspend_thread ( srv_slot_t slot)
static

Suspends the calling thread to wait for the event in its thread slot.

Returns
the current signal count of the event.
Parameters
slotin/out: thread slot

◆ srv_suspend_thread_low()

static int64_t srv_suspend_thread_low ( srv_slot_t slot)
static

Suspends the calling thread to wait for the event in its thread slot.

Returns
the current signal count of the event.
Parameters
slotin/out: thread slot

◆ srv_task_execute()

static bool srv_task_execute ( void  )
static

Fetch and execute a task from the work queue.

Returns
true if a task was executed

◆ srv_thread_is_active()

bool srv_thread_is_active ( const IB_thread thread)

Check if given thread is still active.

◆ srv_thread_is_stopped()

bool srv_thread_is_stopped ( const IB_thread thread)

Check if given thread is cleaned-up and stopped.

◆ srv_thread_type_validate()

static bool srv_thread_type_validate ( srv_thread_type  type)
static

Validates the type of a thread table slot.

Returns
true if ok
Parameters
typein: thread type

◆ srv_update_cpu_usage()

static void srv_update_cpu_usage ( )
static

◆ srv_wake_master_thread()

void srv_wake_master_thread ( void  )

Wakes up the master thread if it is suspended or being suspended.

◆ srv_wake_purge_thread_if_not_active()

void srv_wake_purge_thread_if_not_active ( void  )

Tells the purge thread that there has been activity in the database and wakes up the purge thread if it is suspended (not sleeping).

Note that there is a small chance that the purge thread stays suspended (we do not protect our check with the srv_sys_t:mutex and the purge_sys->latch, for performance reasons).

◆ srv_worker_thread()

void srv_worker_thread ( )

Worker thread that reads tasks from the work queue and executes them.

Variable Documentation

◆ CONCURRENT_UNDO_TRUNCATE_LIMIT

const size_t CONCURRENT_UNDO_TRUNCATE_LIMIT
Initial value:
=
static constexpr space_id_t s_undo_space_id_range
The number of space IDs dedicated to each undo tablespace.
Definition: dict0dict.h:1108

Maximum number of recently truncated undo tablespace IDs for the same undo number.

◆ deprecated_undo_logs

const char* deprecated_undo_logs
Initial value:
=
"The parameter innodb_undo_logs is deprecated"
" and may be removed in future releases."
" Please use innodb_rollback_segments instead."
" See " REFMAN "innodb-undo-logs.html"
#define REFMAN
Definition: univ.i:70

◆ export_vars

export_var_t export_vars

Status variables to be passed to MySQL.

◆ high_level_read_only

bool high_level_read_only

Set if InnoDB operates in read-only mode or innodb-force-recovery is greater than SRV_FORCE_NO_TRX_UNDO.

◆ innodb_calling_exit

bool innodb_calling_exit

Set when InnoDB has invoked exit().

◆ page_zip_stat_per_index_mutex

ib_mutex_t page_zip_stat_per_index_mutex

Mutex protecting page_zip_stat_per_index.

◆ srv_adaptive_flushing

bool srv_adaptive_flushing = true

◆ srv_adaptive_flushing_lwm

ulong srv_adaptive_flushing_lwm = 10

◆ srv_buf_dump_event

os_event_t srv_buf_dump_event

Event to signal the buffer pool dump/load thread.

The buffer pool dump/load thread waits on this event.

◆ srv_buf_dump_filename

char* srv_buf_dump_filename

The buffer pool dump/load file name.

◆ srv_buf_flush_list_added_size

ulong srv_buf_flush_list_added_size = INNODB_BUF_FLUSH_LIST_ADDED_SIZE_DEFAULT

Number of slots in a small buffer, which is used to break requirement for total order of dirty pages, when they are added to flush lists.

Number of slots in a small link buffer, which is used to break requirement for total order of dirty pages, when they are added to flush lists.

The slots are addressed by LSN values modulo number of the slots.

◆ srv_buf_pool_base_size

ulint srv_buf_pool_base_size = 0

Current size as scaling factor for the other components.

◆ srv_buf_pool_chunk_unit

ulonglong srv_buf_pool_chunk_unit

Requested buffer pool chunk size.

Each buffer pool instance consists of one or more chunks.

◆ srv_buf_pool_chunk_unit_blk_sz

const ulonglong srv_buf_pool_chunk_unit_blk_sz = (1024 * 1024)

The buffer pool chunk size must be a multiple of this number.

◆ srv_buf_pool_chunk_unit_max

const ulonglong srv_buf_pool_chunk_unit_max
Initial value:
=
constexpr ulint MAX_BUFFER_POOLS
The maximum number of buffer pools that can be defined.
Definition: buf0buf.h:109
const longlong srv_buf_pool_max_size
Maximum pool size in bytes.
Definition: srv0srv.cc:430

Maximum buffer pool chunk size.

◆ srv_buf_pool_chunk_unit_min

const ulonglong srv_buf_pool_chunk_unit_min = (1024 * 1024)

Minimum buffer pool chunk size.

◆ srv_buf_pool_curr_size

long long srv_buf_pool_curr_size = 0

Current size in bytes.

◆ srv_buf_pool_def_size

const ulint srv_buf_pool_def_size = 128 * 1024 * 1024

Default pool size in bytes.

◆ srv_buf_pool_dump_pct

ulong srv_buf_pool_dump_pct

Dump this % of each buffer pool during BP dump.

◆ srv_buf_pool_instances

ulong srv_buf_pool_instances

Requested number of buffer pool instances.

◆ srv_buf_pool_instances_default

const ulong srv_buf_pool_instances_default = 0

Default number of buffer pool instances.

◆ srv_buf_pool_max_size

const longlong srv_buf_pool_max_size = LLONG_MAX

Maximum pool size in bytes.

◆ srv_buf_pool_min_size

const ulint srv_buf_pool_min_size = 5 * 1024 * 1024

Minimum pool size in bytes.

◆ srv_buf_pool_old_size

ulint srv_buf_pool_old_size = 0

Previously requested size.

Accesses protected by memory barriers.

◆ srv_buf_pool_size

ulint srv_buf_pool_size = ULINT_MAX

Requested size in bytes.

◆ srv_buf_resize_event

os_event_t srv_buf_resize_event

Event to signal the buffer pool resize thread.

The buffer pool resize thread waits on this event.

◆ srv_buffer_pool_dump_at_shutdown

bool srv_buffer_pool_dump_at_shutdown = true

Boolean config knobs that tell InnoDB to dump the buffer pool at shutdown and/or load it during startup.

◆ srv_buffer_pool_load_at_startup

bool srv_buffer_pool_load_at_startup = true

◆ srv_change_buffer_max_size

uint srv_change_buffer_max_size = CHANGE_BUFFER_DEFAULT_SIZE

Maximum on-disk size of change buffer in terms of percentage of the buffer pool.

◆ srv_checkpoint_disabled

bool srv_checkpoint_disabled = false

If true then disable checkpointing.

◆ srv_cmp_per_index_enabled

bool srv_cmp_per_index_enabled = false

Enable INFORMATION_SCHEMA.innodb_cmp_per_index.

◆ srv_cpu_usage

Srv_cpu_usage srv_cpu_usage

Structure with cpu usage information.

◆ srv_data_home

char* srv_data_home = nullptr

◆ srv_debug_compress

ulong srv_debug_compress

Force all user tables to use page compression.

◆ srv_dedicated_server

bool srv_dedicated_server = true

Dedicated server setting.

◆ srv_dml_needed_delay

ulint srv_dml_needed_delay = 0

◆ srv_doublewrite_dir

char* srv_doublewrite_dir = nullptr

Separate directory for doublewrite files, if it is not NULL.

◆ srv_downgrade_partition_files

bool srv_downgrade_partition_files = false

◆ srv_error_event

os_event_t srv_error_event

Event to signal the error thread.

◆ srv_fast_shutdown

ulong srv_fast_shutdown

The value of the configuration parameter innodb_fast_shutdown, controlling the InnoDB shutdown.

If innodb_fast_shutdown=0, InnoDB shutdown will purge all undo log records (except XA PREPARE transactions) and complete the merge of the entire change buffer, and then shut down the redo log.

If innodb_fast_shutdown=1, InnoDB shutdown will only flush the buffer pool to data files, cleanly shutting down the redo log.

If innodb_fast_shutdown=2, shutdown will effectively 'crash' InnoDB (but lose no committed transactions).

◆ srv_fatal_semaphore_wait_extend

std::atomic<int> srv_fatal_semaphore_wait_extend {0}

◆ srv_fatal_semaphore_wait_threshold

ulong srv_fatal_semaphore_wait_threshold = 600

◆ srv_file_per_table

bool srv_file_per_table

store to its own file each table created by an user; data dictionary tables are in the system tablespace 0

◆ srv_flush_log_at_timeout

uint srv_flush_log_at_timeout = 1

◆ srv_flush_log_at_trx_commit

ulong srv_flush_log_at_trx_commit = 1

◆ srv_flush_neighbors

ulong srv_flush_neighbors = 1

Whether or not to flush neighbors of a block.

◆ srv_flush_sync

bool srv_flush_sync = true

◆ srv_flushing_avg_loops

ulong srv_flushing_avg_loops = 30

◆ srv_force_recovery

ulong srv_force_recovery

Normally 0.

When nonzero, skip some phases of crash recovery, starting from SRV_FORCE_IGNORE_CORRUPT, so that data can be recovered by SELECT or mysqldump. When this is nonzero, we do not allow any user modifications to the data.

◆ srv_force_recovery_crash

ulong srv_force_recovery_crash

Inject a crash at different steps of the recovery process.

This is for testing and debugging only.

◆ srv_idle_flush_pct

ulong srv_idle_flush_pct = srv_idle_flush_pct_default

How much flush to be done in case of server is idle.

◆ srv_idle_flush_pct_default

const ulong srv_idle_flush_pct_default = 100

Default value of srv_idle_flush_pct.

◆ srv_inject_too_many_concurrent_trxs

bool srv_inject_too_many_concurrent_trxs = false

◆ srv_innodb_directories

char* srv_innodb_directories = nullptr

The innodb_directories variable value.

This a list of directories deliminated by ';', i.e the FIL_PATH_SEPARATOR.

◆ srv_innodb_monitor_mutex

ib_mutex_t srv_innodb_monitor_mutex
static

◆ srv_innodb_needs_monitoring

std::atomic_uint32_t srv_innodb_needs_monitoring {0}

In contrast to srv_print_innodb_monitor which is controlled by the user, this variable is controlled by InnoDB itself: if some module of InnoDB decides it would be good to print the monitoring information it increments this value, and decrements it when it no longer needs it.

◆ srv_innodb_stats_method

ulong srv_innodb_stats_method = SRV_STATS_NULLS_EQUAL

◆ srv_innodb_status

bool srv_innodb_status = false

◆ srv_io_capacity

ulong srv_io_capacity = 200

◆ srv_io_thread_function

const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS]

◆ srv_io_thread_op_info

const char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS]

◆ srv_lock_table_size

ulint srv_lock_table_size = ULINT_MAX

Lock table size in bytes.

◆ srv_log_buffer_size

ulong srv_log_buffer_size

Space for log buffer, expressed in bytes.

Note, that log buffer will use only the largest power of two, which is not greater than the assigned space.

◆ srv_log_checkpoint_every

ulong srv_log_checkpoint_every = INNODB_LOG_CHECKPOINT_EVERY_DEFAULT

Number of milliseconds every which a periodical checkpoint is written by the log checkpointer thread (unless periodical checkpoints are disabled, which is a case during initial phase of startup).

◆ srv_log_checksums

bool srv_log_checksums

Whether to generate and require checksums on the redo log pages.

◆ srv_log_file_size

ulonglong srv_log_file_size

Value of innodb_log_file_size.

Expressed in bytes. This is deprecated.

◆ srv_log_flush_events

ulong srv_log_flush_events = INNODB_LOG_EVENTS_DEFAULT

Number of events used for notifications about redo flush.

◆ srv_log_flush_notifier_spin_delay

ulong srv_log_flush_notifier_spin_delay
Initial value:
=
constexpr ulong INNODB_LOG_FLUSH_NOTIFIER_SPIN_DELAY_DEFAULT
Default value of innodb_log_flush_notifier_spin_delay (in spin rounds).
Definition: log0constants.h:479

Number of spin iterations, for which log flush notifier thread is waiting for advanced flushed_to_disk_lsn without sleeping.

◆ srv_log_flush_notifier_timeout

ulong srv_log_flush_notifier_timeout
Initial value:
=
constexpr ulong INNODB_LOG_FLUSH_NOTIFIER_TIMEOUT_DEFAULT
Default value of innodb_log_flush_notifier_timeout (in microseconds).
Definition: log0constants.h:482

Initial timeout used to wait on flush_notifier_event.

◆ srv_log_flusher_spin_delay

ulong srv_log_flusher_spin_delay = INNODB_LOG_FLUSHER_SPIN_DELAY_DEFAULT

Number of spin iterations, for which log flusher thread is waiting for new data to flush, without sleeping.

◆ srv_log_flusher_timeout

ulong srv_log_flusher_timeout = INNODB_LOG_FLUSHER_TIMEOUT_DEFAULT

Initial timeout used to wait on flusher_event.

◆ srv_log_group_home_dir

char* srv_log_group_home_dir = nullptr

◆ srv_log_n_files

ulong srv_log_n_files = 100

Value of innodb_log_files_in_group.

This is deprecated.

◆ srv_log_recent_written_size

ulong srv_log_recent_written_size = INNODB_LOG_RECENT_WRITTEN_SIZE_DEFAULT

Number of slots in a small buffer, which is used to allow concurrent writes to log buffer.

The slots are addressed by LSN values modulo number of the slots.

◆ srv_log_spin_cpu_abs_lwm

uint srv_log_spin_cpu_abs_lwm

Minimum absolute value of cpu time for which spin-delay is used.

◆ srv_log_spin_cpu_pct_hwm

uint srv_log_spin_cpu_pct_hwm

Maximum percentage of cpu time for which spin-delay is used.

◆ srv_log_wait_for_flush_spin_delay

ulong srv_log_wait_for_flush_spin_delay
Initial value:
=
constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_SPIN_DELAY_DEFAULT
Default value of innodb_log_wait_for_flush_spin_delay (in spin rounds).
Definition: log0constants.h:456

Number of spin iterations, when spinning and waiting for log flushed.

◆ srv_log_wait_for_flush_spin_hwm

ulong srv_log_wait_for_flush_spin_hwm

Maximum value of average log flush time for which spin-delay is used.

When flushing takes longer, user threads no longer spin when waiting for flushed redo. Expressed in microseconds.

◆ srv_log_wait_for_flush_timeout

ulong srv_log_wait_for_flush_timeout
Initial value:
=
constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_TIMEOUT_DEFAULT
Default value of innodb_log_wait_for_flush_timeout (in microseconds).
Definition: log0constants.h:462

Timeout used when waiting for redo flush (microseconds).

◆ srv_log_wait_for_write_spin_delay

ulong srv_log_wait_for_write_spin_delay
Initial value:
=
constexpr ulong INNODB_LOG_WAIT_FOR_WRITE_SPIN_DELAY_DEFAULT
Default value of innodb_log_wait_for_write_spin_delay (in spin rounds).
Definition: log0constants.h:448

Number of spin iterations, when spinning and waiting for log buffer written up to given LSN, before we fallback to loop with sleeps.

This is not used when user thread has to wait for log flushed to disk.

◆ srv_log_wait_for_write_timeout

ulong srv_log_wait_for_write_timeout
Initial value:
=
constexpr ulong INNODB_LOG_WAIT_FOR_WRITE_TIMEOUT_DEFAULT
Default value of innodb_log_wait_for_write_timeout (in microseconds).
Definition: log0constants.h:451

Timeout used when waiting for redo write (microseconds).

◆ srv_log_write_ahead_size

ulong srv_log_write_ahead_size

Size of block, used for writing ahead to avoid read-on-write.

◆ srv_log_write_events

ulong srv_log_write_events = INNODB_LOG_EVENTS_DEFAULT

Number of events used for notifications about redo write.

◆ srv_log_write_max_size

ulong srv_log_write_max_size = INNODB_LOG_WRITE_MAX_SIZE_DEFAULT

When log writer follows links in the log recent written buffer, it stops when it has reached at least that many bytes to write, limiting how many bytes can be written in single call.

◆ srv_log_write_notifier_spin_delay

ulong srv_log_write_notifier_spin_delay
Initial value:
=
constexpr ulong INNODB_LOG_WRITE_NOTIFIER_SPIN_DELAY_DEFAULT
Default value of innodb_log_write_notifier_spin_delay (in spin rounds).
Definition: log0constants.h:473

Number of spin iterations, for which log write notifier thread is waiting for advanced flushed_to_disk_lsn without sleeping.

Number of spin iterations, for which log write notifier thread is waiting for advanced writeed_to_disk_lsn without sleeping.

◆ srv_log_write_notifier_timeout

ulong srv_log_write_notifier_timeout
Initial value:
=
constexpr ulong INNODB_LOG_WRITE_NOTIFIER_TIMEOUT_DEFAULT
Default value of innodb_log_write_notifier_timeout (in microseconds).
Definition: log0constants.h:476

Initial timeout used to wait on write_notifier_event.

◆ srv_log_writer_spin_delay

ulong srv_log_writer_spin_delay = INNODB_LOG_WRITER_SPIN_DELAY_DEFAULT

Number of spin iterations, for which log writer thread is waiting for new data to write or flush without sleeping.

◆ srv_log_writer_threads

bool srv_log_writer_threads

Whether to activate/pause the log writer threads.

◆ srv_log_writer_timeout

ulong srv_log_writer_timeout = INNODB_LOG_WRITER_TIMEOUT_DEFAULT

Initial timeout used to wait on writer_event.

◆ srv_log_writes_and_flush

ulint srv_log_writes_and_flush = 0
static

Log writes involving flush.

◆ srv_LRU_scan_depth

ulong srv_LRU_scan_depth = 1024

Scan depth for LRU flush batch i.e.

: number of blocks scanned

◆ srv_main_active_loops

ulint srv_main_active_loops = 0
static

Iterations of the loop bounded by 'srv_active' label.

◆ srv_main_idle_loops

ulint srv_main_idle_loops = 0
static

Iterations of the loop bounded by the 'srv_idle' label.

◆ srv_main_shutdown_loops

ulint srv_main_shutdown_loops = 0
static

Iterations of the loop bounded by the 'srv_shutdown' label.

◆ srv_main_thread_id

std::thread::id srv_main_thread_id {}
static

◆ srv_main_thread_op_info

const char* srv_main_thread_op_info = ""

◆ srv_main_thread_process_no

ulint srv_main_thread_process_no = 0
static

◆ SRV_MASTER_DICT_LRU_INTERVAL

constexpr std::chrono::seconds SRV_MASTER_DICT_LRU_INTERVAL {47}
constexpr

◆ SRV_MASTER_SLOT

const ulint SRV_MASTER_SLOT = 0
static

Slot index in the srv_sys->sys_threads array for the master thread.

◆ srv_master_thread_disabled_debug

bool srv_master_thread_disabled_debug

Used by SET GLOBAL innodb_master_thread_disabled_debug = X.

Value of MySQL global used to disable master thread.

◆ srv_master_thread_disabled_event

os_event_t srv_master_thread_disabled_event
static

Event used to inform that master thread is disabled.

◆ srv_max_buf_pool_modified_pct

double srv_max_buf_pool_modified_pct = 75.0

◆ srv_max_dirty_pages_pct_lwm

double srv_max_dirty_pages_pct_lwm = 0.0

◆ srv_max_io_capacity

ulong srv_max_io_capacity = 400

◆ srv_max_undo_tablespace_size

unsigned long long srv_max_undo_tablespace_size

Maximum size of undo tablespace.

◆ srv_misc_tmpfile

FILE* srv_misc_tmpfile

Temporary file for miscellaneous diagnostic output.

◆ srv_misc_tmpfile_mutex

ib_mutex_t srv_misc_tmpfile_mutex

Mutex for locking srv_misc_tmpfile.

Not created if srv_read_only_mode. This mutex has a very low rank; threads reserving it should not acquire any further latches or sleep before releasing this one.

◆ srv_monitor_event

os_event_t srv_monitor_event

Event to signal the monitor thread.

◆ srv_monitor_file

FILE* srv_monitor_file

Temporary file for innodb monitor output.

◆ srv_monitor_file_mutex

ib_mutex_t srv_monitor_file_mutex

◆ srv_monitor_stats_refreshed_at

std::chrono::steady_clock::time_point srv_monitor_stats_refreshed_at
static

◆ srv_n_page_cleaners

ulong srv_n_page_cleaners = 4

◆ srv_n_page_hash_locks

ulong srv_n_page_hash_locks = 16

Number of locks to protect buf_pool->page_hash.

◆ srv_n_purge_threads

ulong srv_n_purge_threads = 4

◆ srv_n_read_io_threads

ulong srv_n_read_io_threads

◆ srv_n_rows_deleted_old

ulint srv_n_rows_deleted_old = 0
static

◆ srv_n_rows_inserted_old

ulint srv_n_rows_inserted_old = 0
static

◆ srv_n_rows_read_old

ulint srv_n_rows_read_old = 0
static

◆ srv_n_rows_updated_old

ulint srv_n_rows_updated_old = 0
static

◆ srv_n_spin_wait_rounds

ulong srv_n_spin_wait_rounds = 30

◆ srv_n_system_rows_deleted_old

ulint srv_n_system_rows_deleted_old = 0
static

◆ srv_n_system_rows_inserted_old

ulint srv_n_system_rows_inserted_old = 0
static

◆ srv_n_system_rows_read_old

ulint srv_n_system_rows_read_old = 0
static

◆ srv_n_system_rows_updated_old

ulint srv_n_system_rows_updated_old = 0
static

◆ srv_n_write_io_threads

ulong srv_n_write_io_threads

◆ srv_numa_interleave

bool srv_numa_interleave = false

◆ srv_online_max_size

unsigned long long srv_online_max_size

Maximum modification log file size for online index creation.

◆ srv_page_size

ulong srv_page_size = UNIV_PAGE_SIZE_DEF

◆ srv_page_size_shift

ulong srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_DEF

◆ srv_parallel_read_threads

ulong srv_parallel_read_threads

Number of threads to use for parallel reads.

◆ srv_print_all_deadlocks

bool srv_print_all_deadlocks = false

Print all user-level transactions deadlocks to mysqld stderr.

◆ srv_print_ddl_logs

bool srv_print_ddl_logs = false

Print all DDL logs to mysqld stderr.

◆ srv_print_innodb_lock_monitor

bool srv_print_innodb_lock_monitor = false

◆ srv_print_innodb_monitor

bool srv_print_innodb_monitor = false

◆ srv_priority_boost

bool srv_priority_boost = true

◆ srv_purge_batch_size

ulong srv_purge_batch_size = 20

◆ srv_purge_rseg_truncate_frequency

ulong srv_purge_rseg_truncate_frequency
Initial value:
=
static_cast<ulong>(undo::TRUNCATE_FREQUENCY)
constexpr ulint TRUNCATE_FREQUENCY
Definition: trx0purge.h:888

Rate at which UNDO records should be purged.

◆ SRV_PURGE_SLOT

const ulint SRV_PURGE_SLOT = 1
static

Slot index in the srv_sys->sys_threads array for the purge thread.

◆ srv_random_read_ahead

bool srv_random_read_ahead = false

◆ srv_read_ahead_threshold

ulong srv_read_ahead_threshold = 56

◆ srv_read_only_mode

bool srv_read_only_mode

Set if InnoDB must operate in read-only mode.

We don't do any recovery and open all tables in RO mode instead of RW mode. We don't sync the max trx id to disk either.

◆ srv_redo_log

bool srv_redo_log = true

If innodb redo logging is enabled.

◆ srv_redo_log_capacity

ulonglong srv_redo_log_capacity

Value of innodb_redo_log_capacity.

Expressed in bytes. Might be set during startup automatically when started in "dedicated server mode".

◆ srv_redo_log_capacity_used

ulonglong srv_redo_log_capacity_used

Assumed value of innodb_redo_log_capacity's - value which is used.

Expressed in bytes. Might be set during startup automatically when started in "dedicated server mode". Might also be set during startup when old sysvar (innodb_log_file_size or innodb_log_files_in_group) are configured and the new sysvar (innodb_redo_log_capacity) is not.

◆ srv_redo_log_encrypt

bool srv_redo_log_encrypt = false

Enable or disable Encrypt of REDO tablespace.

Enable or Disable Encrypt of REDO tablespace.

◆ srv_replication_delay

ulong srv_replication_delay = 0

◆ srv_rollback_segments

ulong srv_rollback_segments = TRX_SYS_N_RSEGS

The number of rollback segments per tablespace.

◆ srv_rseg_init_threads

uint32_t srv_rseg_init_threads = 1

Number of threads spawned for initializing rollback segments in parallel.

◆ srv_sort_buf_size

ulong srv_sort_buf_size = 1048576

Sort buffer size in index creation.

◆ srv_spin_wait_delay

ulong srv_spin_wait_delay = 6

◆ srv_stage_alter_table_end

PSI_stage_info srv_stage_alter_table_end
Initial value:
= {
0, "alter table (end)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}
#define PSI_DOCUMENT_ME
Definition: component_common.h:29
#define PSI_FLAG_STAGE_PROGRESS
Stage progress flag.
Definition: psi_bits.h:82

Performance schema stage event for monitoring ALTER TABLE progress everything after flush log_make_latest_checkpoint().

◆ srv_stage_alter_table_flush

PSI_stage_info srv_stage_alter_table_flush
Initial value:
= {
0, "alter table (flush)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}

Performance schema stage event for monitoring ALTER TABLE progress log_make_latest_checkpoint().

◆ srv_stage_alter_table_insert

PSI_stage_info srv_stage_alter_table_insert
Initial value:
= {
0, "alter table (insert)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}

Performance schema stage event for monitoring ALTER TABLE progress.

Performance schema stage event for monitoring ALTER TABLE progress row_merge_insert_index_tuples().

◆ srv_stage_alter_table_log_index

PSI_stage_info srv_stage_alter_table_log_index
Initial value:
= {
0, "alter table (log apply index)", PSI_FLAG_STAGE_PROGRESS,

Performance schema stage event for monitoring ALTER TABLE progress row_log_apply().

◆ srv_stage_alter_table_log_table

PSI_stage_info srv_stage_alter_table_log_table
Initial value:
= {
0, "alter table (log apply table)", PSI_FLAG_STAGE_PROGRESS,

Performance schema stage event for monitoring ALTER TABLE progress row_log_table_apply().

◆ srv_stage_alter_table_merge_sort

PSI_stage_info srv_stage_alter_table_merge_sort
Initial value:
= {
0, "alter table (merge sort)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}

Performance schema stage event for monitoring ALTER TABLE progress.

Performance schema stage event for monitoring ALTER TABLE progress row_merge_sort().

◆ srv_stage_alter_table_read_pk_internal_sort

PSI_stage_info srv_stage_alter_table_read_pk_internal_sort
Initial value:
= {
0, "alter table (read PK and internal sort)", PSI_FLAG_STAGE_PROGRESS,

Performance schema stage event for monitoring ALTER TABLE progress.

Performance schema stage event for monitoring ALTER TABLE progress row_merge_read_clustered_index().

◆ srv_stage_alter_tablespace_encryption

PSI_stage_info srv_stage_alter_tablespace_encryption
Initial value:
= {
0, "alter tablespace (encryption)", PSI_FLAG_STAGE_PROGRESS,

Performance schema stage event for monitoring ALTER TABLESPACE ENCRYPTION progress.

◆ srv_stage_buffer_pool_load

PSI_stage_info srv_stage_buffer_pool_load
Initial value:
= {
0, "buffer pool load", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}

Performance schema stage event for monitoring buffer pool load progress.

◆ srv_stage_clone_file_copy

PSI_stage_info srv_stage_clone_file_copy
Initial value:
= {
0, "clone (file copy)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}

Performance schema stage event for monitoring clone file copy progress.

◆ srv_stage_clone_page_copy

PSI_stage_info srv_stage_clone_page_copy
Initial value:
= {
0, "clone (page copy)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}

Performance schema stage event for monitoring clone page copy progress.

◆ srv_stage_clone_redo_copy

PSI_stage_info srv_stage_clone_redo_copy
Initial value:
= {
0, "clone (redo copy)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}

Performance schema stage event for monitoring clone redo copy progress.

◆ srv_stats

srv_stats_t srv_stats

Global counters.

◆ srv_stats_auto_recalc

bool srv_stats_auto_recalc = true

◆ srv_stats_include_delete_marked

bool srv_stats_include_delete_marked = false

◆ srv_stats_persistent

bool srv_stats_persistent = true

◆ srv_stats_persistent_sample_pages

unsigned long long srv_stats_persistent_sample_pages = 20

◆ srv_stats_transient_sample_pages

unsigned long long srv_stats_transient_sample_pages = 8

◆ srv_sys

srv_sys_t* srv_sys = nullptr
static

◆ srv_threads

Srv_threads srv_threads

Structure with state of srv background threads.

◆ srv_truncated_status_writes

ulint srv_truncated_status_writes = 0

◆ srv_undo_dir

char* srv_undo_dir = nullptr

Undo tablespace directories.

Server undo tablespaces directory, can be absolute path.

This can be multiple paths separated by ';' and can also be absolute paths.

◆ srv_undo_log_encrypt

bool srv_undo_log_encrypt = false

Enable or disable Encrypt of UNDO tablespace.

◆ srv_undo_log_truncate

bool srv_undo_log_truncate = false

Enable or Disable Truncate of UNDO tablespace.

Note: If enabled then UNDO tablespace will be selected for truncate. While Server waits for undo-tablespace to truncate if user disables it, truncate action is completed but no new tablespace is marked for truncate (action is never aborted).

◆ srv_undo_logs

ulong srv_undo_logs = 0

◆ srv_undo_tablespaces

ulong srv_undo_tablespaces = FSP_IMPLICIT_UNDO_TABLESPACES

The number of implicit undo tablespaces to use for rollback segments.

Number of undo tablespaces to use.

◆ srv_unix_file_flush_method

enum srv_unix_flush_t srv_unix_file_flush_method = SRV_UNIX_FSYNC

◆ srv_use_fdatasync

bool srv_use_fdatasync = false

Use fdatasync() instead of fsync().

◆ srv_use_native_aio

bool srv_use_native_aio = false

If this flag is true, then we will use the native aio of the OS (provided we compiled Innobase with it in), otherwise we will use simulated aio we build below with threads.

◆ srv_validate_tablespace_paths

bool srv_validate_tablespace_paths = true

Whether to validate InnoDB tablespace paths on startup.

◆ tbsp_extend_and_initialize

bool tbsp_extend_and_initialize = true

Enable or disable writing of NULLs while extending a tablespace.

If this is false, then the server will just allocate the space without actually initializing it with NULLs. If the variable is true, the server will allocate and initialize the space by writing NULLs in it.

◆ univ_page_size

page_size_t univ_page_size(0, 0, false) ( ,
,
false   
)