2009-02-17 07:56:33 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
|
|
|
|
Copyright (c) 2008, Google Inc.
|
|
|
|
|
|
|
|
Portions of this file contain modifications contributed and copyrighted by
|
|
|
|
Google, Inc. Those modifications are gratefully acknowledged and are described
|
|
|
|
briefly in the InnoDB documentation. The contributions by Google are
|
|
|
|
incorporated with their permission, and subject to the conditions contained in
|
|
|
|
the file COPYING.Google.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/******************************************************
|
|
|
|
The server main program
|
|
|
|
|
|
|
|
Created 10/10/1995 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#ifndef srv0srv_h
|
|
|
|
#define srv0srv_h
|
|
|
|
|
|
|
|
#include "univ.i"
|
|
|
|
#include "sync0sync.h"
|
|
|
|
#include "os0sync.h"
|
|
|
|
#include "que0types.h"
|
|
|
|
#include "trx0types.h"
|
|
|
|
|
|
|
|
extern const char* srv_main_thread_op_info;
|
|
|
|
|
2006-06-13 20:23:26 +00:00
|
|
|
/* Prefix used by MySQL to indicate pre-5.1 table name encoding */
|
|
|
|
extern const char srv_mysql50_table_name_prefix[9];
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* When this event is set the lock timeout and InnoDB monitor
|
|
|
|
thread starts running */
|
|
|
|
extern os_event_t srv_lock_timeout_thread_event;
|
|
|
|
|
|
|
|
/* If the last data file is auto-extended, we add this many pages to it
|
|
|
|
at a time */
|
|
|
|
#define SRV_AUTO_EXTEND_INCREMENT \
|
|
|
|
(srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
|
|
|
|
|
|
|
|
/* This is set to TRUE if the MySQL user has set it in MySQL */
|
|
|
|
extern ibool srv_lower_case_table_names;
|
|
|
|
|
|
|
|
/* Mutex for locking srv_monitor_file */
|
|
|
|
extern mutex_t srv_monitor_file_mutex;
|
|
|
|
/* Temporary file for innodb monitor output */
|
|
|
|
extern FILE* srv_monitor_file;
|
2006-02-17 14:19:39 +00:00
|
|
|
/* Mutex for locking srv_dict_tmpfile.
|
|
|
|
This mutex has a very high rank; threads reserving it should not
|
|
|
|
be holding any InnoDB latches. */
|
|
|
|
extern mutex_t srv_dict_tmpfile_mutex;
|
|
|
|
/* Temporary file for output from the data dictionary */
|
|
|
|
extern FILE* srv_dict_tmpfile;
|
|
|
|
/* Mutex for locking srv_misc_tmpfile.
|
|
|
|
This mutex has a very low rank; threads reserving it should not
|
|
|
|
acquire any further latches or sleep before releasing this one. */
|
|
|
|
extern mutex_t srv_misc_tmpfile_mutex;
|
|
|
|
/* Temporary file for miscellanous diagnostic output */
|
|
|
|
extern FILE* srv_misc_tmpfile;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Server parameters which are read from the initfile */
|
|
|
|
|
|
|
|
extern char* srv_data_home;
|
|
|
|
#ifdef UNIV_LOG_ARCHIVE
|
|
|
|
extern char* srv_arch_dir;
|
|
|
|
#endif /* UNIV_LOG_ARCHIVE */
|
|
|
|
|
2008-03-07 12:56:52 +00:00
|
|
|
/* store to its own file each table created by an user; data
|
|
|
|
dictionary tables are in the system tablespace 0 */
|
|
|
|
extern my_bool srv_file_per_table;
|
branches/zip: Implement the configuration parameter and settable global
variable innodb_file_format. Implement file format version stamping of
*.ibd files and SYS_TABLES.TYPE.
This change breaks introduces an incompatible change for for
compressed tables. We can do this, as we have not released yet.
innodb-zip.test: Add tests for stricter KEY_BLOCK_SIZE and ROW_FORMAT
checks.
DICT_TF_COMPRESSED_MASK, DICT_TF_COMPRESSED_SHIFT: Replace with
DICT_TF_ZSSIZE_MASK, DICT_TF_ZSSIZE_SHIFT.
DICT_TF_FORMAT_MASK, DICT_TF_FORMAT_SHIFT, DICT_TF_FORMAT_51,
DICT_TF_FORMAT_ZIP: File format version, stored in table->flags,
in the .ibd file header, and in SYS_TABLES.TYPE.
dict_create_sys_tables_tuple(): Write the table flags to SYS_TABLES.TYPE
if the format is at least DICT_TF_FORMAT_ZIP. For old formats
(DICT_TF_FORMAT_51), write DICT_TABLE_ORDINARY as the table type.
DB_TABLE_ZIP_NO_IBD: Remove the error code. The error handling is done
in ha_innodb.cc; as a failsafe measure, dict_build_table_def_step() will
silently clear the compression and format flags instead of returning this
error.
dict_mem_table_create(): Assert that no extra bits are set in the flags.
dict_sys_tables_get_zip_size(): Rename to dict_sys_tables_get_flags().
Check all flag bits, and return ULINT_UNDEFINED if the combination is
unsupported.
dict_boot(): Document the SYS_TABLES columns N_COLS and TYPE.
dict_table_get_format(), dict_table_set_format(),
dict_table_flags_to_zip_size(): New accessors to table->flags.
dtuple_convert_big_rec(): Introduce the auxiliary variables
local_len, local_prefix_len. Store a 768-byte prefix locally
if the file format is less than DICT_TF_FORMAT_ZIP.
dtuple_convert_back_big_rec(): Restore the columns.
srv_file_format: New variable: innodb_file_format.
fil_create_new_single_table_tablespace(): Replace the parameter zip_size
with table->flags.
fil_open_single_table_tablespace(): Replace the parameter zip_size_in_k
with table->flags. Check the flags.
fil_space_struct, fil_space_create(), fil_op_write_log():
Replace zip_size with flags.
fil_node_open_file(): Note a TODO item for InnoDB Hot Backup.
Check that the tablespace flags match.
fil_space_get_zip_size(): Rename to fil_space_get_flags(). Add a
wrapper for fil_space_get_zip_size().
fsp_header_get_flags(): New function.
fsp_header_init_fields(): Replace zip_size with flags.
FSP_SPACE_FLAGS: New name for the tablespace flags. This field used
to be called FSP_PAGE_ZIP_SIZE, or FSP_LOWEST_NO_WRITE. It has always
been written as 0 in MySQL/InnoDB versions 4.1 to 5.1.
MLOG_ZIP_FILE_CREATE: Rename to MLOG_FILE_CREATE2. Add a 32-bit
parameter for the tablespace flags.
ha_innobase::create(): Check the table attributes ROW_FORMAT and
KEY_BLOCK_SIZE. Issue errors if they are inappropriate, or warnings
if the inherited attributes (in ALTER TABLE) will be ignored.
PAGE_ZIP_MIN_SIZE_SHIFT: New constant: the 2-logarithm of PAGE_ZIP_MIN_SIZE.
2008-03-10 11:05:32 +00:00
|
|
|
/* The file format to use on new *.ibd files. */
|
2008-05-06 15:00:25 +00:00
|
|
|
extern ulint srv_file_format;
|
|
|
|
/* Whether to check file format during startup.*/
|
|
|
|
extern ulint srv_check_file_format_at_startup;
|
2008-03-07 12:56:52 +00:00
|
|
|
/* Place locks to records only i.e. do not use next-key locking except
|
|
|
|
on duplicate key checking and foreign key checking */
|
2006-02-23 19:25:29 +00:00
|
|
|
extern ibool srv_locks_unsafe_for_binlog;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern ulint srv_n_data_files;
|
|
|
|
extern char** srv_data_file_names;
|
|
|
|
extern ulint* srv_data_file_sizes;
|
2006-02-23 19:25:29 +00:00
|
|
|
extern ulint* srv_data_file_is_raw_partition;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern ibool srv_auto_extend_last_data_file;
|
|
|
|
extern ulint srv_last_file_size_max;
|
|
|
|
extern ulong srv_auto_extend_increment;
|
|
|
|
|
|
|
|
extern ibool srv_created_new_raw;
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
#define SRV_NEW_RAW 1
|
|
|
|
#define SRV_OLD_RAW 2
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern char** srv_log_group_home_dirs;
|
|
|
|
|
|
|
|
extern ulint srv_n_log_groups;
|
|
|
|
extern ulint srv_n_log_files;
|
|
|
|
extern ulint srv_log_file_size;
|
|
|
|
extern ulint srv_log_buffer_size;
|
2006-08-11 11:49:38 +00:00
|
|
|
extern ulong srv_flush_log_at_trx_commit;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
2008-02-06 14:17:36 +00:00
|
|
|
/* The sort order table of the MySQL latin1_swedish_ci character set
|
|
|
|
collation */
|
|
|
|
extern const byte* srv_latin1_ordering;
|
2009-01-02 13:10:50 +00:00
|
|
|
extern my_bool srv_use_sys_malloc;
|
2008-12-10 22:19:07 +00:00
|
|
|
extern ulint srv_buf_pool_size; /* requested size in bytes */
|
|
|
|
extern ulint srv_buf_pool_old_size; /* previously requested size */
|
|
|
|
extern ulint srv_buf_pool_curr_size; /* current size in bytes */
|
2005-10-27 07:29:40 +00:00
|
|
|
extern ulint srv_mem_pool_size;
|
|
|
|
extern ulint srv_lock_table_size;
|
|
|
|
|
|
|
|
extern ulint srv_n_file_io_threads;
|
|
|
|
|
|
|
|
#ifdef UNIV_LOG_ARCHIVE
|
|
|
|
extern ibool srv_log_archive_on;
|
|
|
|
extern ibool srv_archive_recovery;
|
|
|
|
extern dulint srv_archive_recovery_limit_lsn;
|
|
|
|
#endif /* UNIV_LOG_ARCHIVE */
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
extern char* srv_file_flush_method_str;
|
|
|
|
extern ulint srv_unix_file_flush_method;
|
|
|
|
extern ulint srv_win_file_flush_method;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern ulint srv_max_n_open_files;
|
|
|
|
|
|
|
|
extern ulint srv_max_dirty_pages_pct;
|
|
|
|
|
|
|
|
extern ulint srv_force_recovery;
|
|
|
|
extern ulong srv_thread_concurrency;
|
|
|
|
extern ulong srv_commit_concurrency;
|
|
|
|
|
|
|
|
extern ulint srv_max_n_threads;
|
|
|
|
|
|
|
|
extern lint srv_conc_n_threads;
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
extern ulint srv_fast_shutdown; /* If this is 1, do not do a
|
2005-10-27 07:29:40 +00:00
|
|
|
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). */
|
|
|
|
extern ibool srv_innodb_status;
|
|
|
|
|
2008-08-07 13:47:44 +00:00
|
|
|
extern unsigned long long srv_stats_sample_pages;
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
extern ibool srv_use_doublewrite_buf;
|
|
|
|
extern ibool srv_use_checksums;
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
extern ibool srv_set_thread_priorities;
|
|
|
|
extern int srv_query_thread_priority;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern ulong srv_max_buf_pool_modified_pct;
|
|
|
|
extern ulong srv_max_purge_lag;
|
2007-09-20 08:36:22 +00:00
|
|
|
|
2008-10-14 15:14:47 +00:00
|
|
|
extern ulong srv_replication_delay;
|
2005-10-27 07:29:40 +00:00
|
|
|
/*-------------------------------------------*/
|
|
|
|
|
|
|
|
extern ulint srv_n_rows_inserted;
|
|
|
|
extern ulint srv_n_rows_updated;
|
|
|
|
extern ulint srv_n_rows_deleted;
|
|
|
|
extern ulint srv_n_rows_read;
|
|
|
|
|
|
|
|
extern ibool srv_print_innodb_monitor;
|
2006-02-23 19:25:29 +00:00
|
|
|
extern ibool srv_print_innodb_lock_monitor;
|
|
|
|
extern ibool srv_print_innodb_tablespace_monitor;
|
|
|
|
extern ibool srv_print_verbose_log;
|
|
|
|
extern ibool srv_print_innodb_table_monitor;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern ibool srv_lock_timeout_and_monitor_active;
|
2006-02-23 19:25:29 +00:00
|
|
|
extern ibool srv_error_monitor_active;
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern ulong srv_n_spin_wait_rounds;
|
|
|
|
extern ulong srv_n_free_tickets_to_enter;
|
|
|
|
extern ulong srv_thread_sleep_delay;
|
|
|
|
extern ulint srv_spin_wait_delay;
|
|
|
|
extern ibool srv_priority_boost;
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
extern ulint srv_mem_pool_size;
|
|
|
|
extern ulint srv_lock_table_size;
|
|
|
|
|
branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
2007-10-24 07:12:11 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2005-10-27 07:29:40 +00:00
|
|
|
extern ibool srv_print_thread_releases;
|
|
|
|
extern ibool srv_print_lock_waits;
|
|
|
|
extern ibool srv_print_buf_io;
|
|
|
|
extern ibool srv_print_log_io;
|
|
|
|
extern ibool srv_print_latch_waits;
|
branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
2007-10-24 07:12:11 +00:00
|
|
|
#else /* UNIV_DEBUG */
|
|
|
|
# define srv_print_thread_releases FALSE
|
|
|
|
# define srv_print_lock_waits FALSE
|
|
|
|
# define srv_print_buf_io FALSE
|
|
|
|
# define srv_print_log_io FALSE
|
|
|
|
# define srv_print_latch_waits FALSE
|
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
extern ulint srv_activity_count;
|
|
|
|
extern ulint srv_fatal_semaphore_wait_threshold;
|
|
|
|
extern ulint srv_dml_needed_delay;
|
|
|
|
|
|
|
|
extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs,
|
|
|
|
query threads, and lock table: we allocate
|
|
|
|
it from dynamic memory to get it to the
|
|
|
|
same DRAM page as other hotspot semaphores */
|
|
|
|
#define kernel_mutex (*kernel_mutex_temp)
|
|
|
|
|
|
|
|
#define SRV_MAX_N_IO_THREADS 100
|
2006-02-23 19:25:29 +00:00
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/* Array of English strings describing the current state of an
|
|
|
|
i/o handler thread */
|
|
|
|
extern const char* srv_io_thread_op_info[];
|
|
|
|
extern const char* srv_io_thread_function[];
|
|
|
|
|
|
|
|
/* the number of the log write requests done */
|
|
|
|
extern ulint srv_log_write_requests;
|
|
|
|
|
|
|
|
/* the number of physical writes to the log performed */
|
|
|
|
extern ulint srv_log_writes;
|
|
|
|
|
|
|
|
/* amount of data written to the log files in bytes */
|
|
|
|
extern ulint srv_os_log_written;
|
|
|
|
|
|
|
|
/* amount of writes being done to the log files */
|
|
|
|
extern ulint srv_os_log_pending_writes;
|
|
|
|
|
|
|
|
/* we increase this counter, when there we don't have enough space in the
|
|
|
|
log buffer and have to flush it */
|
|
|
|
extern ulint srv_log_waits;
|
|
|
|
|
|
|
|
/* variable that counts amount of data read in total (in bytes) */
|
|
|
|
extern ulint srv_data_read;
|
|
|
|
|
|
|
|
/* here we count the amount of data written in total (in bytes) */
|
|
|
|
extern ulint srv_data_written;
|
|
|
|
|
|
|
|
/* this variable counts the amount of times, when the doublewrite buffer
|
|
|
|
was flushed */
|
|
|
|
extern ulint srv_dblwr_writes;
|
|
|
|
|
|
|
|
/* here we store the number of pages that have been flushed to the
|
|
|
|
doublewrite buffer */
|
|
|
|
extern ulint srv_dblwr_pages_written;
|
|
|
|
|
|
|
|
/* in this variable we store the number of write requests issued */
|
|
|
|
extern ulint srv_buf_pool_write_requests;
|
|
|
|
|
|
|
|
/* here we store the number of times when we had to wait for a free page
|
|
|
|
in the buffer pool. It happens when the buffer pool is full and we need
|
|
|
|
to make a flush, in order to be able to read or create a page. */
|
|
|
|
extern ulint srv_buf_pool_wait_free;
|
|
|
|
|
|
|
|
/* variable to count the number of pages that were written from the
|
|
|
|
buffer pool to disk */
|
|
|
|
extern ulint srv_buf_pool_flushed;
|
|
|
|
|
|
|
|
/* variable to count the number of buffer pool reads that led to the
|
|
|
|
reading of a disk page */
|
|
|
|
extern ulint srv_buf_pool_reads;
|
|
|
|
|
|
|
|
/* variable to count the number of sequential read-aheads were done */
|
|
|
|
extern ulint srv_read_ahead_seq;
|
|
|
|
|
|
|
|
/* variable to count the number of random read-aheads were done */
|
|
|
|
extern ulint srv_read_ahead_rnd;
|
|
|
|
|
|
|
|
/* In this structure we store status variables to be passed to MySQL */
|
|
|
|
typedef struct export_var_struct export_struc;
|
|
|
|
|
|
|
|
extern export_struc export_vars;
|
|
|
|
|
|
|
|
typedef struct srv_sys_struct srv_sys_t;
|
|
|
|
|
|
|
|
/* The server system */
|
|
|
|
extern srv_sys_t* srv_sys;
|
|
|
|
|
2006-02-23 19:25:29 +00:00
|
|
|
/* Alternatives for the file flush option in Unix; see the InnoDB manual
|
|
|
|
about what these mean */
|
2008-03-17 14:09:44 +00:00
|
|
|
#define SRV_UNIX_FSYNC 1 /* This is the default */
|
2006-02-23 19:25:29 +00:00
|
|
|
#define SRV_UNIX_O_DSYNC 2
|
|
|
|
#define SRV_UNIX_LITTLESYNC 3
|
|
|
|
#define SRV_UNIX_NOSYNC 4
|
|
|
|
#define SRV_UNIX_O_DIRECT 5
|
2005-10-27 07:29:40 +00:00
|
|
|
|
|
|
|
/* Alternatives for file i/o in Windows */
|
|
|
|
#define SRV_WIN_IO_NORMAL 1
|
|
|
|
#define SRV_WIN_IO_UNBUFFERED 2 /* This is the default */
|
|
|
|
|
|
|
|
/* 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. */
|
|
|
|
|
|
|
|
#define SRV_FORCE_IGNORE_CORRUPT 1 /* let the server run even if it
|
|
|
|
detects a corrupt page */
|
2006-02-23 19:25:29 +00:00
|
|
|
#define SRV_FORCE_NO_BACKGROUND 2 /* prevent the main thread from
|
2005-10-27 07:29:40 +00:00
|
|
|
running: if a crash would occur
|
|
|
|
in purge, this prevents it */
|
|
|
|
#define SRV_FORCE_NO_TRX_UNDO 3 /* do not run trx rollback after
|
|
|
|
recovery */
|
|
|
|
#define SRV_FORCE_NO_IBUF_MERGE 4 /* prevent also ibuf operations:
|
|
|
|
if they would cause a crash, better
|
|
|
|
not do them */
|
|
|
|
#define SRV_FORCE_NO_UNDO_LOG_SCAN 5 /* do not look at undo logs when
|
|
|
|
starting the database: InnoDB will
|
|
|
|
treat even incomplete transactions
|
|
|
|
as committed */
|
|
|
|
#define SRV_FORCE_NO_LOG_REDO 6 /* do not do the log roll-forward
|
|
|
|
in connection with recovery */
|
2006-02-23 19:25:29 +00:00
|
|
|
|
branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
2007-10-24 07:12:11 +00:00
|
|
|
/** Types of threads existing in the system. */
|
|
|
|
enum srv_thread_type {
|
|
|
|
SRV_COM = 1, /**< threads serving communication and queries */
|
|
|
|
SRV_CONSOLE, /**< thread serving console */
|
|
|
|
SRV_WORKER, /**< threads serving parallelized queries and
|
|
|
|
queries released from lock wait */
|
|
|
|
#if 0
|
|
|
|
/* Utility threads */
|
|
|
|
SRV_BUFFER, /**< thread flushing dirty buffer blocks */
|
|
|
|
SRV_RECOVERY, /**< threads finishing a recovery */
|
|
|
|
SRV_INSERT, /**< thread flushing the insert buffer to disk */
|
|
|
|
#endif
|
|
|
|
SRV_MASTER /**< the master thread, (whose type number must
|
|
|
|
be biggest) */
|
|
|
|
};
|
|
|
|
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
Boots Innobase server. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
srv_boot(void);
|
|
|
|
/*==========*/
|
|
|
|
/* out: DB_SUCCESS or error code */
|
|
|
|
/*************************************************************************
|
|
|
|
Initializes the server. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_init(void);
|
|
|
|
/*==========*/
|
|
|
|
/*************************************************************************
|
|
|
|
Frees the OS fast mutex created in srv_boot(). */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_free(void);
|
|
|
|
/*==========*/
|
|
|
|
/*************************************************************************
|
|
|
|
Initializes the synchronization primitives, memory system, and the thread
|
|
|
|
local storage. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_general_init(void);
|
|
|
|
/*==================*/
|
|
|
|
/*************************************************************************
|
|
|
|
Gets the number of threads in the system. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
srv_get_n_threads(void);
|
|
|
|
/*===================*/
|
|
|
|
/*************************************************************************
|
|
|
|
Returns the calling thread type. */
|
|
|
|
|
branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
2007-10-24 07:12:11 +00:00
|
|
|
enum srv_thread_type
|
2005-10-27 07:29:40 +00:00
|
|
|
srv_get_thread_type(void);
|
|
|
|
/*=====================*/
|
|
|
|
/* out: SRV_COM, ... */
|
|
|
|
/*************************************************************************
|
|
|
|
Sets the info describing an i/o thread current state. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_set_io_thread_op_info(
|
|
|
|
/*======================*/
|
|
|
|
ulint i, /* in: the 'segment' of the i/o thread */
|
|
|
|
const char* str); /* in: constant char string describing the
|
|
|
|
state */
|
|
|
|
/*************************************************************************
|
|
|
|
Releases threads of the type given from suspension in the thread table.
|
|
|
|
NOTE! The server mutex has to be reserved by the caller! */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
ulint
|
|
|
|
srv_release_threads(
|
|
|
|
/*================*/
|
branches/zip: Remove some unnecessary memory references in the master thread.
srv_print_thread_releases, srv_print_lock_waits, srv_print_buf_io,
srv_print_log_io, srv_print_latch_waits: Define these variables as
constants (FALSE), unless UNIV_DEBUG is defined. These variables
are never assigned to, and they are initialized to FALSE. It could
be useful to set them when debugging InnoDB.
srv_slot_t: Fuse the fields type, in_use, suspended to a single machine word.
srv_meter[], srv_meter_low_water[], srv_meter_high_water[],
srv_meter_high_water2[], srv_meter_foreground[]: Enclose these arrays
inside #if 0. The arrays are essentially constants that do not affect
the control flow.
enum srv_thread_type: New enum, to replace the #defines SRV_COM, ...
Enclose the unused values SRV_BUFFER, SRV_RECOVERY, SRV_INSERT
inside #if 0, so that some arrays and loops can be reduced.
2007-10-24 07:12:11 +00:00
|
|
|
/* out: number of threads
|
|
|
|
released: this may be < n if
|
|
|
|
not enough threads were
|
|
|
|
suspended at the moment */
|
|
|
|
enum srv_thread_type type, /* in: thread type */
|
|
|
|
ulint n); /* in: number of threads to release */
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
The master thread controlling the server. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-05-08 06:18:59 +00:00
|
|
|
os_thread_ret_t
|
2005-10-27 07:29:40 +00:00
|
|
|
srv_master_thread(
|
|
|
|
/*==============*/
|
|
|
|
/* out: a dummy parameter */
|
|
|
|
void* arg); /* in: a dummy parameter required by
|
|
|
|
os_thread_create */
|
|
|
|
/***********************************************************************
|
|
|
|
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). */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_active_wake_master_thread(void);
|
|
|
|
/*===============================*/
|
|
|
|
/***********************************************************************
|
|
|
|
Wakes up the master thread if it is suspended or being suspended. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_wake_master_thread(void);
|
|
|
|
/*========================*/
|
|
|
|
/*************************************************************************
|
|
|
|
Puts an OS thread to wait if there are too many concurrent threads
|
|
|
|
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_conc_enter_innodb(
|
|
|
|
/*==================*/
|
|
|
|
trx_t* trx); /* in: transaction object associated with the
|
|
|
|
thread */
|
|
|
|
/*************************************************************************
|
|
|
|
This lets a thread enter InnoDB regardless of the number of threads inside
|
|
|
|
InnoDB. This must be called when a thread ends a lock wait. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_conc_force_enter_innodb(
|
|
|
|
/*========================*/
|
|
|
|
trx_t* trx); /* in: transaction object associated with the
|
|
|
|
thread */
|
|
|
|
/*************************************************************************
|
|
|
|
This must be called when a thread exits InnoDB in a lock wait or at the
|
|
|
|
end of an SQL statement. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_conc_force_exit_innodb(
|
|
|
|
/*=======================*/
|
|
|
|
trx_t* trx); /* in: transaction object associated with the
|
|
|
|
thread */
|
|
|
|
/*************************************************************************
|
|
|
|
This must be called when a thread exits InnoDB. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_conc_exit_innodb(
|
|
|
|
/*=================*/
|
|
|
|
trx_t* trx); /* in: transaction object associated with the
|
|
|
|
thread */
|
|
|
|
/*******************************************************************
|
|
|
|
Puts a MySQL OS thread to wait for a lock to be released. If an error
|
|
|
|
occurs during the wait trx->error_state associated with thr is
|
|
|
|
!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
|
|
|
|
are possible errors. DB_DEADLOCK is returned if selective deadlock
|
|
|
|
resolution chose this transaction as a victim. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_suspend_mysql_thread(
|
|
|
|
/*=====================*/
|
|
|
|
que_thr_t* thr); /* in: query thread associated with the MySQL
|
|
|
|
OS thread */
|
|
|
|
/************************************************************************
|
|
|
|
Releases a MySQL OS thread waiting for a lock to be released, if the
|
|
|
|
thread is already suspended. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_release_mysql_thread_if_suspended(
|
|
|
|
/*==================================*/
|
|
|
|
que_thr_t* thr); /* in: query thread associated with the
|
2006-02-23 19:25:29 +00:00
|
|
|
MySQL OS thread */
|
2005-10-27 07:29:40 +00:00
|
|
|
/*************************************************************************
|
|
|
|
A thread which wakes up threads whose lock wait may have lasted too long.
|
|
|
|
This also prints the info output by various InnoDB monitors. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-05-08 06:18:59 +00:00
|
|
|
os_thread_ret_t
|
2005-10-27 07:29:40 +00:00
|
|
|
srv_lock_timeout_and_monitor_thread(
|
|
|
|
/*================================*/
|
|
|
|
/* out: a dummy parameter */
|
|
|
|
void* arg); /* in: a dummy parameter required by
|
|
|
|
os_thread_create */
|
|
|
|
/*************************************************************************
|
|
|
|
A thread which prints warnings about semaphore waits which have lasted
|
|
|
|
too long. These can be used to track bugs which cause hangs. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-05-08 06:18:59 +00:00
|
|
|
os_thread_ret_t
|
2005-10-27 07:29:40 +00:00
|
|
|
srv_error_monitor_thread(
|
|
|
|
/*=====================*/
|
|
|
|
/* out: a dummy parameter */
|
|
|
|
void* arg); /* in: a dummy parameter required by
|
|
|
|
os_thread_create */
|
|
|
|
/**********************************************************************
|
|
|
|
Outputs to a file the output of the InnoDB Monitor. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_printf_innodb_monitor(
|
|
|
|
/*======================*/
|
|
|
|
FILE* file, /* in: output stream */
|
|
|
|
ulint* trx_start, /* out: file position of the start of
|
|
|
|
the list of active transactions */
|
|
|
|
ulint* trx_end); /* out: file position of the end of
|
|
|
|
the list of active transactions */
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
Function to pass InnoDB status variables to MySQL */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 07:29:40 +00:00
|
|
|
void
|
|
|
|
srv_export_innodb_status(void);
|
|
|
|
/*=====================*/
|
|
|
|
|
|
|
|
/* Thread slot in the thread table */
|
|
|
|
typedef struct srv_slot_struct srv_slot_t;
|
|
|
|
|
|
|
|
/* Thread table is an array of slots */
|
|
|
|
typedef srv_slot_t srv_table_t;
|
|
|
|
|
|
|
|
/* In this structure we store status variables to be passed to MySQL */
|
|
|
|
struct export_var_struct{
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint innodb_data_pending_reads;
|
|
|
|
ulint innodb_data_pending_writes;
|
|
|
|
ulint innodb_data_pending_fsyncs;
|
|
|
|
ulint innodb_data_fsyncs;
|
|
|
|
ulint innodb_data_read;
|
|
|
|
ulint innodb_data_writes;
|
|
|
|
ulint innodb_data_written;
|
|
|
|
ulint innodb_data_reads;
|
|
|
|
ulint innodb_buffer_pool_pages_total;
|
|
|
|
ulint innodb_buffer_pool_pages_data;
|
|
|
|
ulint innodb_buffer_pool_pages_dirty;
|
|
|
|
ulint innodb_buffer_pool_pages_misc;
|
|
|
|
ulint innodb_buffer_pool_pages_free;
|
branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
2008-06-06 15:24:58 +00:00
|
|
|
#ifdef UNIV_DEBUG
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint innodb_buffer_pool_pages_latched;
|
branches/zip: Merge 2437:2485 from branches/5.1:
(r2478 was skipped for the obvious reason)
------------------------------------------------------------------------
r2464 | vasil | 2008-05-19 17:59:42 +0300 (Mon, 19 May 2008) | 9 lines
branches/5.1:
Fix Bug#36600 SHOW STATUS takes a lot of CPU in buf_get_latched_pages_number
by removing the Innodb_buffer_pool_pages_latched variable from
SHOW STATUS output in non-UNIV_DEBUG compilation.
Approved by: Heikki
------------------------------------------------------------------------
r2466 | calvin | 2008-05-20 01:37:14 +0300 (Tue, 20 May 2008) | 12 lines
branches/5.1:
Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic
link hack
The crash was due to un-handled error 3 (path not found). In the case
of file per table, change the call to os_file_handle_error_no_exit()
from os_file_handle_error(). Also, checks for full path pattern during
table create (Windows only), which is used in symbolic link and temp
table creation.
Approved by: Heikki
------------------------------------------------------------------------
r2478 | sunny | 2008-05-23 08:29:08 +0300 (Fri, 23 May 2008) | 3 lines
branches/5.1: Fix for bug# 36793. This is a back port from branches/zip. This
code has been tested on a big-endian machine too.
------------------------------------------------------------------------
r2480 | vasil | 2008-05-27 11:40:07 +0300 (Tue, 27 May 2008) | 11 lines
branches/5.1:
Fix Bug#36819 ut_usectime does not handle errors from gettimeofday
by retrying gettimeofday() several times if it fails in ut_usectime().
If it fails on all calls then return error to the caller to be handled
at higher level.
Update the variable innodb_row_lock_time_max in SHOW STATUS output only
if ut_usectime() was successful.
------------------------------------------------------------------------
r2482 | sunny | 2008-05-28 12:18:35 +0300 (Wed, 28 May 2008) | 5 lines
branches/5.1: Fix for Bug#35602, "Failed to read auto-increment value from
storage engine". The test for REPLACE was an error of ommission since it's
classified as a simple INSERT. For REPLACE statements we don't acquire
the special AUTOINC lock for AUTOINC_NEW_STYLE_LOCKING with this fix.
------------------------------------------------------------------------
r2485 | vasil | 2008-05-28 16:01:14 +0300 (Wed, 28 May 2008) | 9 lines
branches/5.1:
Fix Bug#36149 Read buffer overflow in srv0start.c found during "make test"
Use strncmp(3) instead of memcmp(3) to avoid reading past end of the string
if it is empty (*str == '\0'). This bug is _not_ a buffer overflow.
Discussed with: Sunny (via IM)
------------------------------------------------------------------------
2008-06-06 15:24:58 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint innodb_buffer_pool_read_requests;
|
|
|
|
ulint innodb_buffer_pool_reads;
|
|
|
|
ulint innodb_buffer_pool_wait_free;
|
|
|
|
ulint innodb_buffer_pool_pages_flushed;
|
|
|
|
ulint innodb_buffer_pool_write_requests;
|
|
|
|
ulint innodb_buffer_pool_read_ahead_seq;
|
|
|
|
ulint innodb_buffer_pool_read_ahead_rnd;
|
|
|
|
ulint innodb_dblwr_pages_written;
|
|
|
|
ulint innodb_dblwr_writes;
|
2009-02-09 23:36:25 +00:00
|
|
|
ibool innodb_have_atomic_builtins;
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint innodb_log_waits;
|
|
|
|
ulint innodb_log_write_requests;
|
|
|
|
ulint innodb_log_writes;
|
|
|
|
ulint innodb_os_log_written;
|
|
|
|
ulint innodb_os_log_fsyncs;
|
|
|
|
ulint innodb_os_log_pending_writes;
|
|
|
|
ulint innodb_os_log_pending_fsyncs;
|
|
|
|
ulint innodb_page_size;
|
|
|
|
ulint innodb_pages_created;
|
|
|
|
ulint innodb_pages_read;
|
|
|
|
ulint innodb_pages_written;
|
|
|
|
ulint innodb_row_lock_waits;
|
|
|
|
ulint innodb_row_lock_current_waits;
|
2008-03-17 14:19:04 +00:00
|
|
|
ib_int64_t innodb_row_lock_time;
|
2006-02-23 19:25:29 +00:00
|
|
|
ulint innodb_row_lock_time_avg;
|
|
|
|
ulint innodb_row_lock_time_max;
|
|
|
|
ulint innodb_rows_read;
|
|
|
|
ulint innodb_rows_inserted;
|
|
|
|
ulint innodb_rows_updated;
|
|
|
|
ulint innodb_rows_deleted;
|
2005-10-27 07:29:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The server system struct */
|
|
|
|
struct srv_sys_struct{
|
|
|
|
srv_table_t* threads; /* server thread table */
|
|
|
|
UT_LIST_BASE_NODE_T(que_thr_t)
|
|
|
|
tasks; /* task queue */
|
|
|
|
dict_index_t* dummy_ind1; /* dummy index for old-style
|
|
|
|
supremum and infimum records */
|
|
|
|
dict_index_t* dummy_ind2; /* dummy index for new-style
|
|
|
|
supremum and infimum records */
|
|
|
|
};
|
|
|
|
|
|
|
|
extern ulint srv_n_threads_active[];
|
|
|
|
|
|
|
|
#endif
|