InnoDB Plugin  1.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
srv0srv.h File Reference
#include "univ.i"
#include "log0log.h"
#include "sync0sync.h"
#include "os0sync.h"
#include "que0types.h"
#include "trx0types.h"
#include "srv0conc.h"
#include "buf0checksum.h"
#include "ut0counter.h"
Include dependency graph for srv0srv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  srv_stats_t
struct  export_var_t
struct  srv_slot_t

Macros

#define SRV_BUF_DUMP_FILENAME_DEFAULT   "ib_buffer_pool"
#define SRV_AUTO_EXTEND_INCREMENT   (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
#define SRV_N_LOG_FILES_MAX   100
#define SRV_MAX_IO_CAPACITY_DUMMY_DEFAULT   (~0UL)
#define SRV_MAX_IO_CAPACITY_LIMIT   (~0UL)
#define PCT_IO(p)   ((ulong) (srv_io_capacity * ((double) (p) / 100.0)))
#define DEPRECATED_MSG_INNODB_TABLE_MONITOR
#define SRV_SEMAPHORE_WAIT_EXTENSION   7200
#define SRV_MAX_N_IO_THREADS   130

Typedefs

typedef enum
srv_stats_method_name_enum 
srv_stats_method_name_t

Enumerations

enum  { SRV_NOT_RAW = 0, SRV_NEW_RAW, SRV_OLD_RAW }
enum  {
  SRV_UNIX_FSYNC = 1, SRV_UNIX_O_DSYNC, SRV_UNIX_LITTLESYNC, SRV_UNIX_NOSYNC,
  SRV_UNIX_O_DIRECT, SRV_UNIX_O_DIRECT_NO_FSYNC
}
enum  { SRV_WIN_IO_NORMAL = 1, SRV_WIN_IO_UNBUFFERED }
enum  {
  SRV_FORCE_IGNORE_CORRUPT = 1, SRV_FORCE_NO_BACKGROUND = 2, SRV_FORCE_NO_TRX_UNDO = 3, SRV_FORCE_NO_IBUF_MERGE = 4,
  SRV_FORCE_NO_UNDO_LOG_SCAN = 5, SRV_FORCE_NO_LOG_REDO = 6
}
enum  srv_stats_method_name_enum { SRV_STATS_NULLS_EQUAL, SRV_STATS_NULLS_UNEQUAL, SRV_STATS_NULLS_IGNORED }
enum  srv_thread_type { SRV_NONE, SRV_WORKER, SRV_PURGE, SRV_MASTER }

Functions

UNIV_INTERN void srv_boot (void)
UNIV_INTERN void srv_init (void)
UNIV_INTERN void srv_free (void)
UNIV_INTERN void srv_general_init (void)
UNIV_INTERN void srv_set_io_thread_op_info (ulint i, const char *str)
UNIV_INTERN void srv_reset_io_thread_op_info ()
UNIV_INTERN void srv_wake_purge_thread_if_not_active (void)
UNIV_INTERN void srv_active_wake_master_thread (void)
UNIV_INTERN void srv_wake_master_thread (void)
UNIV_INTERN ibool srv_printf_innodb_monitor (FILE *file, ibool nowait, ulint *trx_start, ulint *trx_end)
UNIV_INTERN void srv_export_innodb_status (void)
UNIV_INTERN ulint srv_get_activity_count (void)
UNIV_INTERN ibool srv_check_activity (ulint old_activity_count)
UNIV_INTERN void srv_inc_activity_count (void)
UNIV_INTERN void srv_que_task_enqueue_low (que_thr_t *thr)
UNIV_INTERN enum srv_thread_type srv_get_active_thread_type (void)
UNIV_INTERN os_thread_ret_t
DECLARE_THREAD() 
srv_monitor_thread (void *arg)
UNIV_INTERN os_thread_ret_t
DECLARE_THREAD() 
srv_master_thread (void *arg)
UNIV_INTERN os_thread_ret_t
DECLARE_THREAD() 
srv_error_monitor_thread (void *arg)
UNIV_INTERN os_thread_ret_t
DECLARE_THREAD() 
srv_purge_coordinator_thread (void *arg))
UNIV_INTERN os_thread_ret_t
DECLARE_THREAD() 
srv_worker_thread (void *arg))
UNIV_INTERN ulint srv_get_task_queue_length (void)
UNIV_INTERN ulint srv_release_threads (enum srv_thread_type type, ulint n)
UNIV_INTERN const char * srv_any_background_threads_are_active (void)
UNIV_INTERN void srv_purge_wakeup (void)

Variables

const char * srv_main_thread_op_info
const char srv_mysql50_table_name_prefix [10]
os_event_t srv_monitor_event
os_event_t srv_error_event
os_event_t srv_buf_dump_event
char * srv_buf_dump_filename
char srv_buffer_pool_dump_at_shutdown
char srv_buffer_pool_load_at_startup
char srv_disable_sort_file_cache
ib_mutex_t srv_monitor_file_mutex
FILE * srv_monitor_file
ib_mutex_t srv_dict_tmpfile_mutex
FILE * srv_dict_tmpfile
ib_mutex_t srv_misc_tmpfile_mutex
FILE * srv_misc_tmpfile
char * srv_data_home
my_bool srv_read_only_mode
my_bool srv_file_per_table
ulong srv_thread_sleep_delay
ulint srv_file_format
ulint srv_max_file_format_at_startup
ibool srv_locks_unsafe_for_binlog
ulong srv_sort_buf_size
unsigned long long srv_online_max_size
my_bool srv_use_native_aio
char * srv_undo_dir
ulong srv_undo_tablespaces
ulint srv_undo_tablespaces_open
ulong srv_undo_logs
ulint srv_n_data_files
char ** srv_data_file_names
ulint * srv_data_file_sizes
ulint * srv_data_file_is_raw_partition
ibool srv_auto_extend_last_data_file
ulint srv_last_file_size_max
char * srv_log_group_home_dir
ulong srv_auto_extend_increment
ibool srv_created_new_raw
ulong srv_n_log_files
ib_uint64_t srv_log_file_size
ib_uint64_t srv_log_file_size_requested
ulint srv_log_buffer_size
ulong srv_flush_log_at_trx_commit
uint srv_flush_log_at_timeout
char srv_adaptive_flushing
my_bool srv_load_corrupted
const byte * srv_latin1_ordering
my_bool srv_use_sys_malloc
ulint srv_buf_pool_size
ulint srv_buf_pool_instances
ulong srv_n_page_hash_locks
ulong srv_LRU_scan_depth
ulong srv_flush_neighbors
ulint srv_buf_pool_old_size
ulint srv_buf_pool_curr_size
ulint srv_mem_pool_size
ulint srv_lock_table_size
ulint srv_n_file_io_threads
my_bool srv_random_read_ahead
ulong srv_read_ahead_threshold
ulint srv_n_read_io_threads
ulint srv_n_write_io_threads
ulong srv_io_capacity
ulong srv_max_io_capacity
ulong srv_innodb_stats_method
char * srv_file_flush_method_str
ulint srv_unix_file_flush_method
ulint srv_win_file_flush_method
ulint srv_max_n_open_files
ulong srv_max_dirty_pages_pct
ulong srv_max_dirty_pages_pct_lwm
ulong srv_adaptive_flushing_lwm
ulong srv_flushing_avg_loops
ulong srv_force_recovery
ulong srv_force_recovery_crash
ulint srv_fast_shutdown
ibool srv_innodb_status
unsigned long long srv_stats_transient_sample_pages
my_bool srv_stats_persistent
unsigned long long srv_stats_persistent_sample_pages
my_bool srv_stats_auto_recalc
ibool srv_use_doublewrite_buf
ulong srv_doublewrite_batch_size
ulong srv_checksum_algorithm
ulong srv_max_buf_pool_modified_pct
ulong srv_max_purge_lag
ulong srv_max_purge_lag_delay
ulong srv_replication_delay
my_bool srv_print_innodb_monitor
my_bool srv_print_innodb_lock_monitor
ibool srv_print_innodb_tablespace_monitor
ibool srv_print_verbose_log
ibool srv_print_innodb_table_monitor
ibool srv_monitor_active
ibool srv_error_monitor_active
ibool srv_buf_dump_thread_active
ibool srv_dict_stats_thread_active
ulong srv_n_spin_wait_rounds
ulong srv_n_free_tickets_to_enter
ulong srv_spin_wait_delay
ibool srv_priority_boost
ulint srv_truncated_status_writes
ulint srv_available_undo_logs
ibool srv_print_thread_releases
ibool srv_print_lock_waits
ibool srv_print_buf_io
ibool srv_print_log_io
ibool srv_print_latch_waits
my_bool srv_ibuf_disable_background_merge
my_bool srv_purge_view_update_only_debug
ulint srv_fatal_semaphore_wait_threshold
ulint srv_dml_needed_delay
ib_mutex_t server_mutex
const char * srv_io_thread_op_info []
const char * srv_io_thread_function []
ulong srv_n_purge_threads
ulong srv_purge_batch_size
ulong srv_sync_array_size
my_bool srv_print_all_deadlocks
my_bool srv_cmp_per_index_enabled
struct export_var_t export_vars
srv_stats_t srv_stats

Detailed Description

The server main program

Created 10/10/1995 Heikki Tuuri

Macro Definition Documentation

#define DEPRECATED_MSG_INNODB_TABLE_MONITOR
Value:
"Using innodb_table_monitor is deprecated and it may be removed " \
"in future releases. Please use the InnoDB INFORMATION_SCHEMA " \
"tables instead, see " REFMAN "innodb-i_s-tables.html"
#define SRV_BUF_DUMP_FILENAME_DEFAULT   "ib_buffer_pool"

The buffer pool dump/load file name

#define SRV_N_LOG_FILES_MAX   100

Maximum number of srv_n_log_files, or innodb_log_files_in_group

Enumeration Type Documentation

anonymous enum

Types of raw partitions in innodb_data_file_path

Enumerator:
SRV_NOT_RAW 

Not a raw partition

SRV_NEW_RAW 

A 'newraw' partition, only to be initialized

SRV_OLD_RAW 

An initialized raw partition

anonymous enum
Alternatives for the file flush option in Unix; see the InnoDB manual

about what these mean

Enumerator:
SRV_UNIX_FSYNC 

fsync, the default

SRV_UNIX_O_DSYNC 

open log files in O_SYNC mode

SRV_UNIX_LITTLESYNC 

do not call os_file_flush() when writing data files, but do flush after writing to log files

SRV_UNIX_NOSYNC 

do not flush after writing

SRV_UNIX_O_DIRECT 

invoke os_file_set_nocache() on data files. This implies using non-buffered IO but still using fsync, the reason for which is that some FS do not flush meta-data when unbuffered IO happens

SRV_UNIX_O_DIRECT_NO_FSYNC 

do not use fsync() when using direct IO i.e.: it can be set to avoid the fsync() call that we make when using SRV_UNIX_O_DIRECT. However, in this case user/DBA should be sure about the integrity of the meta-data

anonymous enum

Alternatives for file i/o in Windows

Enumerator:
SRV_WIN_IO_NORMAL 

buffered I/O

SRV_WIN_IO_UNBUFFERED 

unbuffered I/O; this is the default

anonymous enum
Alternatives for srv_force_recovery. Non-zero values are intended

to help the user get a damaged database up so that he can dump intact tables and rows with SELECT INTO OUTFILE. The database must not otherwise be used with these options! A bigger number below means that all precautions of lower numbers are included.

Enumerator:
SRV_FORCE_IGNORE_CORRUPT 

let the server run even if it detects a corrupt page

SRV_FORCE_NO_BACKGROUND 

prevent the main thread from running: if a crash would occur in purge, this prevents it

SRV_FORCE_NO_TRX_UNDO 

do not run trx rollback after recovery

SRV_FORCE_NO_IBUF_MERGE 

prevent also ibuf operations: if they would cause a crash, better not do them

SRV_FORCE_NO_UNDO_LOG_SCAN 

do not look at undo logs when starting the database: InnoDB will treat even incomplete transactions as committed

SRV_FORCE_NO_LOG_REDO 

do not do the log roll-forward in connection with recovery

Types of threads existing in the system.

Enumerator:
SRV_NONE 

None

SRV_WORKER 

threads serving parallelized queries and queries released from lock wait

SRV_PURGE 

Purge coordinator thread

SRV_MASTER 

the master thread, (whose type number must be biggest)

Function Documentation

UNIV_INTERN void srv_active_wake_master_thread ( void  )

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 kernel mutex, for performace reasons).

UNIV_INTERN const char* srv_any_background_threads_are_active ( void  )

Check whether any background thread are active. If so print which thread is active. Send the threads wakeup signal.

Returns
name of thread that is active or NULL
UNIV_INTERN void srv_boot ( void  )

Boots Innobase server.

UNIV_INTERN ibool srv_check_activity ( ulint  old_activity_count)

Check if there has been any activity.

Returns
FALSE if no change in activity counter. old activity count
UNIV_INTERN os_thread_ret_t DECLARE_THREAD() srv_error_monitor_thread ( void *  arg)

in: a dummy parameter required by os_thread_create

UNIV_INTERN void srv_export_innodb_status ( void  )

Function to pass InnoDB status variables to MySQL

UNIV_INTERN void srv_free ( void  )

Frees the data structures created in srv_init().

UNIV_INTERN void srv_general_init ( void  )

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

UNIV_INTERN enum srv_thread_type srv_get_active_thread_type ( void  )

Check whether any background thread is active. If so, return the thread type.

Returns
SRV_NONE if all are are suspended or have exited, thread type if any are still active.
UNIV_INTERN 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.
UNIV_INTERN ulint srv_get_task_queue_length ( void  )

Get count of tasks in the queue.

Returns
number of tasks in queue
UNIV_INTERN void srv_inc_activity_count ( void  )

Increment the server activity counter.

UNIV_INTERN void srv_init ( void  )

Initializes the server.

UNIV_INTERN os_thread_ret_t DECLARE_THREAD() srv_master_thread ( void *  arg)

The master thread controlling the server.

Returns
a dummy parameter in: a dummy parameter required by os_thread_create
UNIV_INTERN os_thread_ret_t DECLARE_THREAD() srv_monitor_thread ( void *  arg)

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

Returns
a dummy parameter in: a dummy parameter required by os_thread_create
UNIV_INTERN ibool srv_printf_innodb_monitor ( FILE *  file,
ibool  nowait,
ulint *  trx_start,
ulint *  trx_end 
)

Outputs to a file the output of the InnoDB Monitor.

Returns
FALSE if not all information printed due to failure to obtain necessary mutex out: file position of the end of the list of active transactions
Parameters
filein: output stream
nowaitin: whether to wait for the lock_sys_t::mutex
trx_startout: file position of the start of the list of active transactions
UNIV_INTERN os_thread_ret_t DECLARE_THREAD() srv_purge_coordinator_thread ( void *  arg)

Purge coordinator thread that schedules the purge tasks.

Returns
a dummy parameter in: a dummy parameter required by os_thread_create
UNIV_INTERN void srv_purge_wakeup ( void  )

Wakeup the purge threads.

UNIV_INTERN 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

UNIV_INTERN ulint srv_release_threads ( enum 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 in: number of threads to release
Parameters
typein: thread type
UNIV_INTERN void srv_reset_io_thread_op_info ( )

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

UNIV_INTERN void srv_set_io_thread_op_info ( ulint  i,
const char *  str 
)

Sets the info describing an i/o thread current state. in: constant char string describing the state

Parameters
iin: the 'segment' of the i/o thread
UNIV_INTERN void srv_wake_master_thread ( void  )

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

UNIV_INTERN 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 operation with the srv_sys_t:mutex, for performance reasons).

UNIV_INTERN os_thread_ret_t DECLARE_THREAD() srv_worker_thread ( void *  arg)

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

Returns
a dummy parameter in: a dummy parameter required by os_thread_create

Variable Documentation

struct export_var_t export_vars

Status variables to be passed to MySQL

ib_mutex_t server_mutex

Mutex protecting some server global variables.

os_event_t srv_buf_dump_event

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

ulint srv_buf_pool_curr_size

current size in bytes

ulint srv_buf_pool_instances

requested number of buffer pool instances

ulint srv_buf_pool_old_size

previously requested size

ulint srv_buf_pool_size

requested size in bytes

char srv_buffer_pool_dump_at_shutdown
Boolean config knobs that tell InnoDB to dump the buffer pool at shutdown

and/or load it during startup.

ulint srv_fast_shutdown

If this is 1, do not do a purge and index buffer merge. If this 2, do not even flush the buffer pool to data files at the shutdown: we effectively 'crash' InnoDB (but lose no committed transactions).

ulint srv_file_format

The file format to use on new *.ibd files.

my_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

ulong srv_flush_neighbors

whether or not to flush neighbors of a block

ibool srv_locks_unsafe_for_binlog
Place locks to records only i.e. do not use next-key locking except

on duplicate key checking and foreign key checking

ulong srv_LRU_scan_depth

Scan depth for LRU flush batch

ulint srv_max_file_format_at_startup
Whether to check file format during startup.  A value of

UNIV_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to set it to the highest format we support.

const char srv_mysql50_table_name_prefix[10]

Prefix used by MySQL to indicate pre-5.1 table name encoding

ulong srv_n_page_hash_locks

number of locks to protect buf_pool->page_hash

unsigned long long srv_online_max_size

Maximum modification log file size for online index creation

my_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.

ulong srv_sort_buf_size

Sort buffer size in index creation

srv_stats_t srv_stats

Global counters

ulong srv_thread_sleep_delay

Sleep delay for threads waiting to enter InnoDB. In micro-seconds.

char* srv_undo_dir

Server undo tablespaces directory, can be absolute path.

ulong srv_undo_tablespaces

Number of undo tablespaces to use.

ulint srv_undo_tablespaces_open

The number of UNDO tablespaces that are open and ready to use.