1
1
/*****************************************************************************
3
Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
4
Copyright (C) 2008, 2009, Google Inc.
5
Copyright (C) 2009, Percona Inc.
3
Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
4
Copyright (c) 2008, 2009, Google Inc.
5
Copyright (c) 2009, Percona Inc.
7
7
Portions of this file contain modifications contributed and copyrighted by
8
8
Google, Inc. Those modifications are gratefully acknowledged and are described
48
48
#include "que0types.h"
49
49
#include "trx0types.h"
53
51
extern const char* srv_main_thread_op_info;
55
53
/** Prefix used by MySQL to indicate pre-5.1 table name encoding */
56
/** LOOKIE HERE!!!! This used to be srv_mysql50_table_name_prefix[10]
57
which was a buffer overrun, because it didn't allow for the trailing
59
static const std::string srv_mysql50_table_name_prefix("#mysql50#");
54
extern const char srv_mysql50_table_name_prefix[9];
61
56
/* When this event is set the lock timeout and InnoDB monitor
62
57
thread starts running */
63
58
extern os_event_t srv_lock_timeout_thread_event;
65
/* The monitor thread waits on this event. */
66
extern os_event_t srv_monitor_event;
68
/* The lock timeout thread waits on this event. */
69
extern os_event_t srv_timeout_event;
71
/* The error monitor thread waits on this event. */
72
extern os_event_t srv_error_event;
74
60
/* If the last data file is auto-extended, we add this many pages to it
76
62
#define SRV_AUTO_EXTEND_INCREMENT \
115
101
/** Whether to check file format during startup. A value of
116
102
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE. The default is to
117
103
set it to the highest format we support. */
118
extern ulint srv_max_file_format_at_startup;
104
extern ulint srv_check_file_format_at_startup;
119
105
/** Place locks to records only i.e. do not use next-key locking except
120
106
on duplicate key checking and foreign key checking */
121
107
extern ibool srv_locks_unsafe_for_binlog;
122
108
#endif /* !UNIV_HOTBACKUP */
124
/* If this flag is TRUE, then we will use the native aio of the
125
OS (provided we compiled Innobase with it in), otherwise we will
126
use simulated aio we build below with threads.
127
Currently we support native aio on windows and linux */
128
extern my_bool srv_use_native_aio;
130
extern ibool srv_use_native_conditions;
132
110
extern ulint srv_n_data_files;
133
111
extern char** srv_data_file_names;
134
112
extern ulint* srv_data_file_sizes;
164
142
# endif /* UNIV_HOTBACKUP */
165
143
#endif /* BUILD_DRIZZLE */
166
144
extern ulint srv_buf_pool_size; /*!< requested size in bytes */
167
extern ulint srv_buf_pool_instances; /*!< requested number of buffer pool instances */
168
145
extern ulint srv_buf_pool_old_size; /*!< previously requested size */
169
146
extern ulint srv_buf_pool_curr_size; /*!< current size in bytes */
170
147
extern ulint srv_mem_pool_size;
183
160
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
185
162
#ifdef UNIV_LOG_ARCHIVE
186
extern ibool srv_log_archive_on;
187
extern ibool srv_archive_recovery;
188
extern ib_uint64_t srv_archive_recovery_limit_lsn;
163
extern ibool srv_log_archive_on;
164
extern ibool srv_archive_recovery;
165
extern dulint srv_archive_recovery_limit_lsn;
189
166
#endif /* UNIV_LOG_ARCHIVE */
191
168
extern char* srv_file_flush_method_str;
268
244
query threads, and lock table: we allocate
269
245
it from dynamic memory to get it to the
270
246
same DRAM page as other hotspot semaphores */
271
extern mutex_t* commit_id_mutex_temp;
273
247
#define kernel_mutex (*kernel_mutex_temp)
274
#define commit_id_mutex (*commit_id_mutex_temp)
276
249
#define SRV_MAX_N_IO_THREADS 130
296
269
log buffer and have to flush it */
297
270
extern ulint srv_log_waits;
299
/* the number of purge threads to use from the worker pool (currently 0 or 1) */
300
extern ulong srv_n_purge_threads;
302
/* the number of records to purge in one batch */
303
extern ulong srv_purge_batch_size;
305
272
/* variable that counts amount of data read in total (in bytes) */
306
273
extern ulint srv_data_read;
344
311
/** The server system */
345
312
extern srv_sys_t* srv_sys;
347
# ifdef UNIV_PFS_THREAD
348
/* Keys to register InnoDB threads with performance schema */
349
extern mysql_pfs_key_t trx_rollback_clean_thread_key;
350
extern mysql_pfs_key_t io_handler_thread_key;
351
extern mysql_pfs_key_t srv_lock_timeout_thread_key;
352
extern mysql_pfs_key_t srv_error_monitor_thread_key;
353
extern mysql_pfs_key_t srv_monitor_thread_key;
354
extern mysql_pfs_key_t srv_master_thread_key;
356
/* This macro register the current thread and its key with performance
358
# define pfs_register_thread(key) \
361
struct PSI_thread* psi = PSI_server->new_thread(key, NULL, 0);\
363
PSI_server->set_thread(psi); \
368
/* This macro delist the current thread from performance schema */
369
# define pfs_delete_thread() \
372
PSI_server->delete_current_thread(); \
375
# endif /* UNIV_PFS_THREAD */
377
313
#endif /* !UNIV_HOTBACKUP */
379
315
/** Types of raw partitions in innodb_data_file_path */
514
450
void* arg); /*!< in: a dummy parameter required by
515
451
os_thread_create */
516
452
/*******************************************************************//**
517
Wakes up the purge thread if it's not already awake. */
520
srv_wake_purge_thread(void);
521
/*=======================*/
522
/*******************************************************************//**
523
453
Tells the Innobase server that there has been activity in the database
524
454
and wakes up the master thread if it is suspended (not sleeping). Used
525
455
in the MySQL interface. Note that there is a small chance that the master
536
466
srv_wake_master_thread(void);
537
467
/*========================*/
538
/*******************************************************************//**
539
Tells the purge thread that there has been activity in the database
540
and wakes up the purge thread if it is suspended (not sleeping). Note
541
that there is a small chance that the purge thread stays suspended
542
(we do not protect our operation with the kernel mutex, for
543
performace reasons). */
546
srv_wake_purge_thread_if_not_active(void);
547
/*=====================================*/
548
468
/*********************************************************************//**
549
469
Puts an OS thread to wait if there are too many concurrent threads
550
470
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
651
571
srv_export_innodb_status(void);
652
572
/*==========================*/
654
/******************************************************************//**
655
Increment the server activity counter. */
658
srv_inc_activity_count(void);
659
/*=========================*/
661
/*********************************************************************//**
662
Asynchronous purge thread.
663
@return a dummy parameter */
668
void* /*arg __attribute__((unused))*/); /*!< in: a dummy parameter
669
required by os_thread_create */
671
/**********************************************************************//**
672
Enqueues a task to server task queue and releases a worker thread, if there
673
is a suspended one. */
676
srv_que_task_enqueue_low(
677
/*=====================*/
678
que_thr_t* thr); /*!< in: query thread */
680
/**********************************************************************//**
681
Check whether any background thread is active.
682
@return FALSE if all are are suspended or have exited. */
685
srv_is_any_background_thread_active(void);
686
/*======================================*/
574
/** Thread slot in the thread table */
575
typedef struct srv_slot_struct srv_slot_t;
577
/** Thread table is an array of slots */
578
typedef srv_slot_t srv_table_t;
688
580
/** Status variables to be passed to MySQL */
689
581
struct export_var_struct{
737
629
ulint innodb_rows_inserted; /*!< srv_n_rows_inserted */
738
630
ulint innodb_rows_updated; /*!< srv_n_rows_updated */
739
631
ulint innodb_rows_deleted; /*!< srv_n_rows_deleted */
740
ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */
743
/** Thread slot in the thread table */
744
typedef struct srv_slot_struct srv_slot_t;
746
/** Thread table is an array of slots */
747
typedef srv_slot_t srv_table_t;
749
634
/** The server system struct */
750
635
struct srv_sys_struct{
751
636
srv_table_t* threads; /*!< server thread table */
756
641
extern ulint srv_n_threads_active[];
757
643
#else /* !UNIV_HOTBACKUP */
644
# define srv_use_checksums TRUE
758
645
# define srv_use_adaptive_hash_indexes FALSE
759
# define srv_use_checksums TRUE
760
# define srv_use_native_aio FALSE
761
646
# define srv_force_recovery 0UL
762
647
# define srv_set_io_thread_op_info(t,info) ((void) 0)
763
648
# define srv_is_being_started 0