1
1
/*****************************************************************************
3
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
4
4
Copyright (c) 2008, 2009, Google Inc.
5
Copyright (c) 2009, Percona Inc.
7
6
Portions of this file contain modifications contributed and copyrighted by
8
7
Google, Inc. Those modifications are gratefully acknowledged and are described
10
9
incorporated with their permission, and subject to the conditions contained in
11
10
the file COPYING.Google.
13
Portions of this file contain modifications contributed and copyrighted
14
by Percona Inc.. Those modifications are
15
gratefully acknowledged and are described briefly in the InnoDB
16
documentation. The contributions by Percona Inc. are incorporated with
17
their permission, and subject to the conditions contained in the file
20
12
This program is free software; you can redistribute it and/or modify it under
21
13
the terms of the GNU General Public License as published by the Free Software
22
14
Foundation; version 2 of the License.
26
18
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
28
20
You should have received a copy of the GNU General Public License along with
29
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
30
St, Fifth Floor, Boston, MA 02110-1301 USA
21
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
Place, Suite 330, Boston, MA 02111-1307 USA
32
24
*****************************************************************************/
25
/***********************************************************************
27
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
28
Copyright (c) 2009, Percona Inc.
30
Portions of this file contain modifications contributed and copyrighted
31
by Percona Inc.. Those modifications are
32
gratefully acknowledged and are described briefly in the InnoDB
33
documentation. The contributions by Percona Inc. are incorporated with
34
their permission, and subject to the conditions contained in the file
37
This program is free software; you can redistribute it and/or modify it
38
under the terms of the GNU General Public License as published by the
39
Free Software Foundation; version 2 of the License.
41
This program is distributed in the hope that it will be useful, but
42
WITHOUT ANY WARRANTY; without even the implied warranty of
43
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
44
Public License for more details.
46
You should have received a copy of the GNU General Public License along
47
with this program; if not, write to the Free Software Foundation, Inc.,
48
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50
***********************************************************************/
34
52
/**************************************************//**
35
53
@file include/srv0srv.h
101
119
/** Whether to check file format during startup. A value of
102
120
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to
103
121
set it to the highest format we support. */
104
extern ulint srv_max_file_format_at_startup;
122
extern ulint srv_check_file_format_at_startup;
105
123
/** Place locks to records only i.e. do not use next-key locking except
106
124
on duplicate key checking and foreign key checking */
107
125
extern ibool srv_locks_unsafe_for_binlog;
108
126
#endif /* !UNIV_HOTBACKUP */
110
/* If this flag is TRUE, then we will use the native aio of the
111
OS (provided we compiled Innobase with it in), otherwise we will
112
use simulated aio we build below with threads.
113
Currently we support native aio on windows and linux */
114
extern my_bool srv_use_native_aio;
116
extern ibool srv_use_native_conditions;
118
128
extern ulint srv_n_data_files;
119
129
extern char** srv_data_file_names;
120
130
extern ulint* srv_data_file_sizes;
150
160
# endif /* UNIV_HOTBACKUP */
151
161
#endif /* BUILD_DRIZZLE */
152
162
extern ulint srv_buf_pool_size; /*!< requested size in bytes */
153
extern ulint srv_buf_pool_instances; /*!< requested number of buffer pool instances */
154
163
extern ulint srv_buf_pool_old_size; /*!< previously requested size */
155
164
extern ulint srv_buf_pool_curr_size; /*!< current size in bytes */
156
165
extern ulint srv_mem_pool_size;
169
178
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
171
180
#ifdef UNIV_LOG_ARCHIVE
172
extern ibool srv_log_archive_on;
173
extern ibool srv_archive_recovery;
174
extern ib_uint64_t srv_archive_recovery_limit_lsn;
181
extern ibool srv_log_archive_on;
182
extern ibool srv_archive_recovery;
183
extern dulint srv_archive_recovery_limit_lsn;
175
184
#endif /* UNIV_LOG_ARCHIVE */
177
186
extern char* srv_file_flush_method_str;
220
229
extern ibool srv_print_verbose_log;
221
230
extern ibool srv_print_innodb_table_monitor;
223
extern ibool srv_lock_timeout_active;
224
extern ibool srv_monitor_active;
232
extern ibool srv_lock_timeout_and_monitor_active;
225
233
extern ibool srv_error_monitor_active;
227
235
extern ulong srv_n_spin_wait_rounds;
279
286
log buffer and have to flush it */
280
287
extern ulint srv_log_waits;
282
/* the number of purge threads to use from the worker pool (currently 0 or 1) */
283
extern ulong srv_n_purge_threads;
285
/* the number of records to purge in one batch */
286
extern ulong srv_purge_batch_size;
288
289
/* variable that counts amount of data read in total (in bytes) */
289
290
extern ulint srv_data_read;
314
315
/** Number of buffer pool reads that led to the
315
316
reading of a disk page */
316
317
extern ulint srv_buf_pool_reads;
318
/** Number of sequential read-aheads */
319
extern ulint srv_read_ahead_seq;
320
/** Number of random read-aheads */
321
extern ulint srv_read_ahead_rnd;
318
323
/** Status variables to be passed to MySQL */
319
324
typedef struct export_var_struct export_struc;
327
332
/** The server system */
328
333
extern srv_sys_t* srv_sys;
330
# ifdef UNIV_PFS_THREAD
331
/* Keys to register InnoDB threads with performance schema */
332
extern mysql_pfs_key_t trx_rollback_clean_thread_key;
333
extern mysql_pfs_key_t io_handler_thread_key;
334
extern mysql_pfs_key_t srv_lock_timeout_thread_key;
335
extern mysql_pfs_key_t srv_error_monitor_thread_key;
336
extern mysql_pfs_key_t srv_monitor_thread_key;
337
extern mysql_pfs_key_t srv_master_thread_key;
339
/* This macro register the current thread and its key with performance
341
# define pfs_register_thread(key) \
344
struct PSI_thread* psi = PSI_server->new_thread(key, NULL, 0);\
346
PSI_server->set_thread(psi); \
351
/* This macro delist the current thread from performance schema */
352
# define pfs_delete_thread() \
355
PSI_server->delete_current_thread(); \
358
# endif /* UNIV_PFS_THREAD */
360
334
#endif /* !UNIV_HOTBACKUP */
362
336
/** Types of raw partitions in innodb_data_file_path */
497
471
void* arg); /*!< in: a dummy parameter required by
498
472
os_thread_create */
499
473
/*******************************************************************//**
500
Wakes up the purge thread if it's not already awake. */
503
srv_wake_purge_thread(void);
504
/*=======================*/
505
/*******************************************************************//**
506
474
Tells the Innobase server that there has been activity in the database
507
475
and wakes up the master thread if it is suspended (not sleeping). Used
508
476
in the MySQL interface. Note that there is a small chance that the master
519
487
srv_wake_master_thread(void);
520
488
/*========================*/
521
/*******************************************************************//**
522
Tells the purge thread that there has been activity in the database
523
and wakes up the purge thread if it is suspended (not sleeping). Note
524
that there is a small chance that the purge thread stays suspended
525
(we do not protect our operation with the kernel mutex, for
526
performace reasons). */
529
srv_wake_purge_thread_if_not_active(void);
530
/*=====================================*/
531
489
/*********************************************************************//**
532
490
Puts an OS thread to wait if there are too many concurrent threads
533
491
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
586
544
MySQL OS thread */
587
545
/*********************************************************************//**
588
546
A thread which wakes up threads whose lock wait may have lasted too long.
547
This also prints the info output by various InnoDB monitors.
589
548
@return a dummy parameter */
592
srv_lock_timeout_thread(
593
/*====================*/
551
srv_lock_timeout_and_monitor_thread(
552
/*================================*/
594
553
void* arg); /*!< in: a dummy parameter required by
595
554
os_thread_create */
596
555
/*********************************************************************//**
597
A thread which prints the info output by various InnoDB monitors.
598
@return a dummy parameter */
603
void* arg); /*!< in: a dummy parameter required by
605
/*************************************************************************
606
556
A thread which prints warnings about semaphore waits which have lasted
607
557
too long. These can be used to track bugs which cause hangs.
608
558
@return a dummy parameter */
613
563
void* arg); /*!< in: a dummy parameter required by
614
564
os_thread_create */
615
565
/******************************************************************//**
616
Outputs to a file the output of the InnoDB Monitor.
617
@return FALSE if not all information printed
618
due to failure to obtain necessary mutex */
566
Outputs to a file the output of the InnoDB Monitor. */
621
569
srv_printf_innodb_monitor(
622
570
/*======================*/
623
571
FILE* file, /*!< in: output stream */
624
ibool nowait, /*!< in: whether to wait for kernel mutex */
625
572
ulint* trx_start, /*!< out: file position of the start of
626
573
the list of active transactions */
627
574
ulint* trx_end); /*!< out: file position of the end of
634
581
srv_export_innodb_status(void);
635
582
/*==========================*/
637
/******************************************************************//**
638
Increment the server activity counter. */
641
srv_inc_activity_count(void);
642
/*=========================*/
644
/*********************************************************************//**
645
Asynchronous purge thread.
646
@return a dummy parameter */
651
void* arg __attribute__((unused))); /*!< in: a dummy parameter
652
required by os_thread_create */
654
/**********************************************************************//**
655
Enqueues a task to server task queue and releases a worker thread, if there
656
is a suspended one. */
659
srv_que_task_enqueue_low(
660
/*=====================*/
661
que_thr_t* thr); /*!< in: query thread */
663
/**********************************************************************//**
664
Check whether any background thread is active.
665
@return FALSE if all are are suspended or have exited. */
668
srv_is_any_background_thread_active(void);
669
/*======================================*/
584
/** Thread slot in the thread table */
585
typedef struct srv_slot_struct srv_slot_t;
587
/** Thread table is an array of slots */
588
typedef srv_slot_t srv_table_t;
671
590
/** Status variables to be passed to MySQL */
672
591
struct export_var_struct{
686
605
#ifdef UNIV_DEBUG
687
606
ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
688
607
#endif /* UNIV_DEBUG */
689
ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */
608
ulint innodb_buffer_pool_read_requests; /*!< buf_pool->n_page_gets */
690
609
ulint innodb_buffer_pool_reads; /*!< srv_buf_pool_reads */
691
610
ulint innodb_buffer_pool_wait_free; /*!< srv_buf_pool_wait_free */
692
611
ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
693
612
ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
694
ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */
695
ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
613
ulint innodb_buffer_pool_read_ahead_seq;/*!< srv_read_ahead_seq */
614
ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */
696
615
ulint innodb_dblwr_pages_written; /*!< srv_dblwr_pages_written */
697
616
ulint innodb_dblwr_writes; /*!< srv_dblwr_writes */
698
617
ibool innodb_have_atomic_builtins; /*!< HAVE_ATOMIC_BUILTINS */
704
623
ulint innodb_os_log_pending_writes; /*!< srv_os_log_pending_writes */
705
624
ulint innodb_os_log_pending_fsyncs; /*!< fil_n_pending_log_flushes */
706
625
ulint innodb_page_size; /*!< UNIV_PAGE_SIZE */
707
ulint innodb_pages_created; /*!< buf_pool->stat.n_pages_created */
708
ulint innodb_pages_read; /*!< buf_pool->stat.n_pages_read */
709
ulint innodb_pages_written; /*!< buf_pool->stat.n_pages_written */
626
ulint innodb_pages_created; /*!< buf_pool->n_pages_created */
627
ulint innodb_pages_read; /*!< buf_pool->n_pages_read */
628
ulint innodb_pages_written; /*!< buf_pool->n_pages_written */
710
629
ulint innodb_row_lock_waits; /*!< srv_n_lock_wait_count */
711
630
ulint innodb_row_lock_current_waits; /*!< srv_n_lock_wait_current_count */
712
631
ib_int64_t innodb_row_lock_time; /*!< srv_n_lock_wait_time
720
639
ulint innodb_rows_inserted; /*!< srv_n_rows_inserted */
721
640
ulint innodb_rows_updated; /*!< srv_n_rows_updated */
722
641
ulint innodb_rows_deleted; /*!< srv_n_rows_deleted */
723
ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */
726
/** Thread slot in the thread table */
727
typedef struct srv_slot_struct srv_slot_t;
729
/** Thread table is an array of slots */
730
typedef srv_slot_t srv_table_t;
732
644
/** The server system struct */
733
645
struct srv_sys_struct{
734
646
srv_table_t* threads; /*!< server thread table */
739
651
extern ulint srv_n_threads_active[];
740
653
#else /* !UNIV_HOTBACKUP */
654
# define srv_use_checksums TRUE
741
655
# define srv_use_adaptive_hash_indexes FALSE
742
# define srv_use_checksums TRUE
743
# define srv_use_native_aio FALSE
744
656
# define srv_force_recovery 0UL
745
657
# define srv_set_io_thread_op_info(t,info) ((void) 0)
746
658
# define srv_is_being_started 0