InnoDB Plugin  1.0
srv0srv.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
4 Copyright (c) 2008, 2009, Google Inc.
5 Copyright (c) 2009, Percona Inc.
6 
7 Portions of this file contain modifications contributed and copyrighted by
8 Google, Inc. Those modifications are gratefully acknowledged and are described
9 briefly in the InnoDB documentation. The contributions by Google are
10 incorporated with their permission, and subject to the conditions contained in
11 the file COPYING.Google.
12 
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
18 COPYING.Percona.
19 
20 This program is free software; you can redistribute it and/or modify it under
21 the terms of the GNU General Public License as published by the Free Software
22 Foundation; version 2 of the License.
23 
24 This program is distributed in the hope that it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
26 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
27 
28 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.,
30 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
31 
32 *****************************************************************************/
33 
34 /**************************************************/
41 #ifndef srv0srv_h
42 #define srv0srv_h
43 
44 #include "univ.i"
45 #ifndef UNIV_HOTBACKUP
46 #include "log0log.h"
47 #include "sync0sync.h"
48 #include "os0sync.h"
49 #include "que0types.h"
50 #include "trx0types.h"
51 #include "srv0conc.h"
52 #include "buf0checksum.h"
53 #include "ut0counter.h"
54 
55 /* Global counters used inside InnoDB. */
56 struct srv_stats_t {
62 
65 
68 
71 
74 
77 
81 
84 
88 
91 
96 
100 
104 
107 
110 
113 
116 
119 
122 
125 
128 };
129 
130 extern const char* srv_main_thread_op_info;
131 
133 extern const char srv_mysql50_table_name_prefix[10];
134 
135 /* The monitor thread waits on this event. */
136 extern os_event_t srv_monitor_event;
137 
138 /* The error monitor thread waits on this event. */
139 extern os_event_t srv_error_event;
140 
143 
145 #define SRV_BUF_DUMP_FILENAME_DEFAULT "ib_buffer_pool"
146 extern char* srv_buf_dump_filename;
147 
151 extern char srv_buffer_pool_load_at_startup;
152 
153 /* Whether to disable file system cache if it is defined */
154 extern char srv_disable_sort_file_cache;
155 
156 /* If the last data file is auto-extended, we add this many pages to it
157 at a time */
158 #define SRV_AUTO_EXTEND_INCREMENT \
159  (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
160 
161 /* Mutex for locking srv_monitor_file. Not created if srv_read_only_mode */
162 extern ib_mutex_t srv_monitor_file_mutex;
163 /* Temporary file for innodb monitor output */
164 extern FILE* srv_monitor_file;
165 /* Mutex for locking srv_dict_tmpfile. Only created if !srv_read_only_mode.
166 This mutex has a very high rank; threads reserving it should not
167 be holding any InnoDB latches. */
168 extern ib_mutex_t srv_dict_tmpfile_mutex;
169 /* Temporary file for output from the data dictionary */
170 extern FILE* srv_dict_tmpfile;
171 /* Mutex for locking srv_misc_tmpfile. Only created if !srv_read_only_mode.
172 This mutex has a very low rank; threads reserving it should not
173 acquire any further latches or sleep before releasing this one. */
174 extern ib_mutex_t srv_misc_tmpfile_mutex;
175 /* Temporary file for miscellanous diagnostic output */
176 extern FILE* srv_misc_tmpfile;
177 
178 /* Server parameters which are read from the initfile */
179 
180 extern char* srv_data_home;
181 
182 #ifdef UNIV_LOG_ARCHIVE
183 extern char* srv_arch_dir;
184 #endif /* UNIV_LOG_ARCHIVE */
185 
189 extern my_bool srv_read_only_mode;
192 extern my_bool srv_file_per_table;
194 extern ulong srv_thread_sleep_delay;
195 #if defined(HAVE_ATOMIC_BUILTINS)
196 
197 extern ulong srv_adaptive_max_sleep_delay;
198 #endif /* HAVE_ATOMIC_BUILTINS */
199 
201 extern ulint srv_file_format;
205 extern ulint srv_max_file_format_at_startup;
209 
211 extern ulong srv_sort_buf_size;
213 extern unsigned long long srv_online_max_size;
214 
215 /* If this flag is TRUE, then we will use the native aio of the
216 OS (provided we compiled Innobase with it in), otherwise we will
217 use simulated aio we build below with threads.
218 Currently we support native aio on windows and linux */
219 extern my_bool srv_use_native_aio;
220 #ifdef __WIN__
221 extern ibool srv_use_native_conditions;
222 #endif /* __WIN__ */
223 #endif /* !UNIV_HOTBACKUP */
224 
226 extern char* srv_undo_dir;
227 
229 extern ulong srv_undo_tablespaces;
230 
232 extern ulint srv_undo_tablespaces_open;
233 
234 /* The number of undo segments to use */
235 extern ulong srv_undo_logs;
236 
237 extern ulint srv_n_data_files;
238 extern char** srv_data_file_names;
239 extern ulint* srv_data_file_sizes;
240 extern ulint* srv_data_file_is_raw_partition;
241 
242 extern ibool srv_auto_extend_last_data_file;
243 extern ulint srv_last_file_size_max;
244 extern char* srv_log_group_home_dir;
245 #ifndef UNIV_HOTBACKUP
246 extern ulong srv_auto_extend_increment;
247 
248 extern ibool srv_created_new_raw;
249 
251 #define SRV_N_LOG_FILES_MAX 100
252 extern ulong srv_n_log_files;
253 extern ib_uint64_t srv_log_file_size;
254 extern ib_uint64_t srv_log_file_size_requested;
255 extern ulint srv_log_buffer_size;
256 extern ulong srv_flush_log_at_trx_commit;
257 extern uint srv_flush_log_at_timeout;
258 extern char srv_adaptive_flushing;
259 
260 /* If this flag is TRUE, then we will load the indexes' (and tables') metadata
261 even if they are marked as "corrupted". Mostly it is for DBA to process
262 corrupted index and table */
263 extern my_bool srv_load_corrupted;
264 
265 /* The sort order table of the MySQL latin1_swedish_ci character set
266 collation */
267 extern const byte* srv_latin1_ordering;
268 #ifndef UNIV_HOTBACKUP
269 extern my_bool srv_use_sys_malloc;
270 #else
271 extern ibool srv_use_sys_malloc;
272 #endif /* UNIV_HOTBACKUP */
273 extern ulint srv_buf_pool_size;
274 extern ulint srv_buf_pool_instances;
275 extern ulong srv_n_page_hash_locks;
277 extern ulong srv_LRU_scan_depth;
279 extern ulong srv_flush_neighbors;
281 extern ulint srv_buf_pool_old_size;
282 extern ulint srv_buf_pool_curr_size;
283 extern ulint srv_mem_pool_size;
284 extern ulint srv_lock_table_size;
285 
286 extern ulint srv_n_file_io_threads;
287 extern my_bool srv_random_read_ahead;
288 extern ulong srv_read_ahead_threshold;
289 extern ulint srv_n_read_io_threads;
290 extern ulint srv_n_write_io_threads;
291 
292 /* Number of IO operations per second the server can do */
293 extern ulong srv_io_capacity;
294 
295 /* We use this dummy default value at startup for max_io_capacity.
296 The real value is set based on the value of io_capacity. */
297 #define SRV_MAX_IO_CAPACITY_DUMMY_DEFAULT (~0UL)
298 #define SRV_MAX_IO_CAPACITY_LIMIT (~0UL)
299 extern ulong srv_max_io_capacity;
300 /* Returns the number of IO operations that is X percent of the
301 capacity. PCT_IO(5) -> returns the number of IO operations that
302 is 5% of the max where max is srv_io_capacity. */
303 #define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) (p) / 100.0)))
304 
305 /* The "innodb_stats_method" setting, decides how InnoDB is going
306 to treat NULL value when collecting statistics. It is not defined
307 as enum type because the configure option takes unsigned integer type. */
308 extern ulong srv_innodb_stats_method;
309 
310 #ifdef UNIV_LOG_ARCHIVE
311 extern ibool srv_log_archive_on;
312 extern ibool srv_archive_recovery;
313 extern ib_uint64_t srv_archive_recovery_limit_lsn;
314 #endif /* UNIV_LOG_ARCHIVE */
315 
316 extern char* srv_file_flush_method_str;
317 extern ulint srv_unix_file_flush_method;
318 extern ulint srv_win_file_flush_method;
319 
320 extern ulint srv_max_n_open_files;
321 
322 extern ulong srv_max_dirty_pages_pct;
323 extern ulong srv_max_dirty_pages_pct_lwm;
324 
325 extern ulong srv_adaptive_flushing_lwm;
326 extern ulong srv_flushing_avg_loops;
327 
328 extern ulong srv_force_recovery;
329 #ifndef DBUG_OFF
330 extern ulong srv_force_recovery_crash;
331 #endif /* !DBUG_OFF */
332 
333 extern ulint srv_fast_shutdown;
340 extern ibool srv_innodb_status;
341 
342 extern unsigned long long srv_stats_transient_sample_pages;
343 extern my_bool srv_stats_persistent;
344 extern unsigned long long srv_stats_persistent_sample_pages;
345 extern my_bool srv_stats_auto_recalc;
346 
347 extern ibool srv_use_doublewrite_buf;
348 extern ulong srv_doublewrite_batch_size;
349 extern ulong srv_checksum_algorithm;
350 
351 extern ulong srv_max_buf_pool_modified_pct;
352 extern ulong srv_max_purge_lag;
353 extern ulong srv_max_purge_lag_delay;
354 
355 extern ulong srv_replication_delay;
356 /*-------------------------------------------*/
357 
358 extern my_bool srv_print_innodb_monitor;
359 extern my_bool srv_print_innodb_lock_monitor;
360 extern ibool srv_print_innodb_tablespace_monitor;
361 extern ibool srv_print_verbose_log;
362 #define DEPRECATED_MSG_INNODB_TABLE_MONITOR \
363  "Using innodb_table_monitor is deprecated and it may be removed " \
364  "in future releases. Please use the InnoDB INFORMATION_SCHEMA " \
365  "tables instead, see " REFMAN "innodb-i_s-tables.html"
366 extern ibool srv_print_innodb_table_monitor;
367 
368 extern ibool srv_monitor_active;
369 extern ibool srv_error_monitor_active;
370 
371 /* TRUE during the lifetime of the buffer pool dump/load thread */
372 extern ibool srv_buf_dump_thread_active;
373 
374 /* TRUE during the lifetime of the stats thread */
375 extern ibool srv_dict_stats_thread_active;
376 
377 extern ulong srv_n_spin_wait_rounds;
378 extern ulong srv_n_free_tickets_to_enter;
380 extern ulong srv_spin_wait_delay;
381 extern ibool srv_priority_boost;
382 
383 extern ulint srv_truncated_status_writes;
384 extern ulint srv_available_undo_logs;
385 
386 extern ulint srv_mem_pool_size;
387 extern ulint srv_lock_table_size;
388 
389 #ifdef UNIV_DEBUG
390 extern ibool srv_print_thread_releases;
391 extern ibool srv_print_lock_waits;
392 extern ibool srv_print_buf_io;
393 extern ibool srv_print_log_io;
394 extern ibool srv_print_latch_waits;
395 #else /* UNIV_DEBUG */
396 # define srv_print_thread_releases FALSE
397 # define srv_print_lock_waits FALSE
398 # define srv_print_buf_io FALSE
399 # define srv_print_log_io FALSE
400 # define srv_print_latch_waits FALSE
401 #endif /* UNIV_DEBUG */
402 
403 #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
404 extern my_bool srv_ibuf_disable_background_merge;
405 #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
406 
407 #ifdef UNIV_DEBUG
408 extern my_bool srv_purge_view_update_only_debug;
409 #endif /* UNIV_DEBUG */
410 
411 extern ulint srv_fatal_semaphore_wait_threshold;
412 #define SRV_SEMAPHORE_WAIT_EXTENSION 7200
413 extern ulint srv_dml_needed_delay;
414 
415 #ifndef HAVE_ATOMIC_BUILTINS
416 
417 extern ib_mutex_t server_mutex;
418 #endif /* !HAVE_ATOMIC_BUILTINS */
419 
420 #define SRV_MAX_N_IO_THREADS 130
421 
422 /* Array of English strings describing the current state of an
423 i/o handler thread */
424 extern const char* srv_io_thread_op_info[];
425 extern const char* srv_io_thread_function[];
426 
427 /* the number of purge threads to use from the worker pool (currently 0 or 1) */
428 extern ulong srv_n_purge_threads;
429 
430 /* the number of pages to purge in one batch */
431 extern ulong srv_purge_batch_size;
432 
433 /* the number of sync wait arrays */
434 extern ulong srv_sync_array_size;
435 
436 /* print all user-level transactions deadlocks to mysqld stderr */
437 extern my_bool srv_print_all_deadlocks;
438 
439 extern my_bool srv_cmp_per_index_enabled;
440 
442 extern struct export_var_t export_vars;
443 
445 extern srv_stats_t srv_stats;
446 
447 # ifdef UNIV_PFS_THREAD
448 /* Keys to register InnoDB threads with performance schema */
449 extern mysql_pfs_key_t buf_page_cleaner_thread_key;
450 extern mysql_pfs_key_t trx_rollback_clean_thread_key;
451 extern mysql_pfs_key_t io_handler_thread_key;
452 extern mysql_pfs_key_t srv_lock_timeout_thread_key;
453 extern mysql_pfs_key_t srv_error_monitor_thread_key;
454 extern mysql_pfs_key_t srv_monitor_thread_key;
455 extern mysql_pfs_key_t srv_master_thread_key;
456 extern mysql_pfs_key_t srv_purge_thread_key;
457 extern mysql_pfs_key_t recv_writer_thread_key;
458 
459 /* This macro register the current thread and its key with performance
460 schema */
461 # define pfs_register_thread(key) \
462 do { \
463  struct PSI_thread* psi = PSI_THREAD_CALL(new_thread)(key, NULL, 0);\
464  PSI_THREAD_CALL(set_thread)(psi); \
465 } while (0)
466 
467 /* This macro delist the current thread from performance schema */
468 # define pfs_delete_thread() \
469 do { \
470  PSI_THREAD_CALL(delete_current_thread)(); \
471 } while (0)
472 # endif /* UNIV_PFS_THREAD */
473 
474 #endif /* !UNIV_HOTBACKUP */
475 
477 enum {
482 };
483 
486 enum {
506 };
507 
509 enum {
512 };
513 
519 enum {
536 };
537 
538 /* Alternatives for srv_innodb_stats_method, which could be changed by
539 setting innodb_stats_method */
540 enum srv_stats_method_name_enum {
541  SRV_STATS_NULLS_EQUAL, /* All NULL values are treated as
542  equal. This is the default setting
543  for innodb_stats_method */
544  SRV_STATS_NULLS_UNEQUAL, /* All NULL values are treated as
545  NOT equal. */
546  SRV_STATS_NULLS_IGNORED /* NULL values are ignored */
547 };
548 
549 typedef enum srv_stats_method_name_enum srv_stats_method_name_t;
550 
551 #ifndef UNIV_HOTBACKUP
552 
561 };
562 
563 /*********************************************************************/
565 UNIV_INTERN
566 void
567 srv_boot(void);
568 /*==========*/
569 /*********************************************************************/
571 UNIV_INTERN
572 void
573 srv_init(void);
574 /*==========*/
575 /*********************************************************************/
577 UNIV_INTERN
578 void
579 srv_free(void);
580 /*==========*/
581 /*********************************************************************/
584 UNIV_INTERN
585 void
586 srv_general_init(void);
587 /*==================*/
588 /*********************************************************************/
590 UNIV_INTERN
591 void
593 /*======================*/
594  ulint i,
595  const char* str);
597 /*********************************************************************/
599 UNIV_INTERN
600 void
602 /*=========================*/
603 /*******************************************************************/
609 UNIV_INTERN
610 void
612 /*=====================================*/
613 /*******************************************************************/
619 UNIV_INTERN
620 void
622 /*===============================*/
623 /*******************************************************************/
625 UNIV_INTERN
626 void
628 /*========================*/
629 /******************************************************************/
633 UNIV_INTERN
634 ibool
636 /*======================*/
637  FILE* file,
638  ibool nowait,
640  ulint* trx_start,
642  ulint* trx_end);
645 /******************************************************************/
647 UNIV_INTERN
648 void
650 /*==========================*/
651 /*******************************************************************/
655 UNIV_INTERN
656 ulint
658 /*========================*/
659 /*******************************************************************/
662 UNIV_INTERN
663 ibool
665 /*===============*/
666  ulint old_activity_count);
667 /******************************************************************/
669 UNIV_INTERN
670 void
672 /*=========================*/
673 
674 /**********************************************************************/
677 UNIV_INTERN
678 void
680 /*=====================*/
681  que_thr_t* thr);
683 /**********************************************************************/
688 UNIV_INTERN
689 enum srv_thread_type
691 /*============================*/
692 
693 extern "C" {
694 
695 /*********************************************************************/
698 UNIV_INTERN
699 os_thread_ret_t
701 /*===============================*/
702  void* arg);
705 /*********************************************************************/
708 UNIV_INTERN
709 os_thread_ret_t
711 /*==============================*/
712  void* arg);
715 /*************************************************************************
716 A thread which prints warnings about semaphore waits which have lasted
717 too long. These can be used to track bugs which cause hangs.
718 @return a dummy parameter */
719 UNIV_INTERN
720 os_thread_ret_t
722 /*=====================================*/
723  void* arg);
726 /*********************************************************************/
729 UNIV_INTERN
730 os_thread_ret_t
732 /*=========================================*/
733  void* arg __attribute__((unused)));
736 /*********************************************************************/
739 UNIV_INTERN
740 os_thread_ret_t
742 /*==============================*/
743  void* arg __attribute__((unused)));
745 } /* extern "C" */
746 
747 /**********************************************************************/
750 UNIV_INTERN
751 ulint
753 /*===========================*/
754 
755 /*********************************************************************/
760 UNIV_INTERN
761 ulint
763 /*================*/
764  enum srv_thread_type type,
765  ulint n);
767 /**********************************************************************/
771 UNIV_INTERN
772 const char*
774 /*=======================================*/
775 
776 /**********************************************************************/
778 UNIV_INTERN
779 void
780 srv_purge_wakeup(void);
781 /*==================*/
782 
802 #ifdef UNIV_DEBUG
804 #endif /* UNIV_DEBUG */
829  ib_int64_t innodb_row_lock_time;
843 #ifdef UNIV_DEBUG
847 #endif /* UNIV_DEBUG */
848 };
849 
851 struct srv_slot_t{
863  ulong wait_timeout;
873 };
874 
875 #else /* !UNIV_HOTBACKUP */
876 # define srv_use_adaptive_hash_indexes FALSE
877 # define srv_use_native_aio FALSE
878 # define srv_force_recovery 0UL
879 # define srv_set_io_thread_op_info(t,info) ((void) 0)
880 # define srv_reset_io_thread_op_info() ((void) 0)
881 # define srv_is_being_started 0
882 # define srv_win_file_flush_method SRV_WIN_IO_UNBUFFERED
883 # define srv_unix_file_flush_method SRV_UNIX_O_DSYNC
884 # define srv_start_raw_disk_in_use 0
885 # define srv_file_per_table 1
886 #endif /* !UNIV_HOTBACKUP */
887 
888 #endif