Drizzled Public API Documentation

srv0srv.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1995, 2010, Innobase Oy. 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., 51 Franklin
30 St, Fifth Floor, Boston, MA 02110-1301 USA
31 
32 *****************************************************************************/
33 
34 /**************************************************/
41 #pragma once
42 #ifndef srv0srv_h
43 #define srv0srv_h
44 
45 #include "univ.i"
46 #ifndef UNIV_HOTBACKUP
47 #include "sync0sync.h"
48 #include "os0sync.h"
49 #include "que0types.h"
50 #include "trx0types.h"
51 
52 #include <string>
53 
54 extern const char* srv_main_thread_op_info;
55 
60 static const std::string srv_mysql50_table_name_prefix("#mysql50#");
61 
62 /* When this event is set the lock timeout and InnoDB monitor
63 thread starts running */
64 extern os_event_t srv_lock_timeout_thread_event;
65 
66 /* The monitor thread waits on this event. */
67 extern os_event_t srv_monitor_event;
68 
69 /* The lock timeout thread waits on this event. */
70 extern os_event_t srv_timeout_event;
71 
72 /* The error monitor thread waits on this event. */
73 extern os_event_t srv_error_event;
74 
75 /* If the last data file is auto-extended, we add this many pages to it
76 at a time */
77 #define SRV_AUTO_EXTEND_INCREMENT \
78  (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
79 
80 /* This is set to TRUE if the MySQL user has set it in MySQL */
81 extern ibool srv_lower_case_table_names;
82 
83 /* Mutex for locking srv_monitor_file */
84 extern mutex_t srv_monitor_file_mutex;
85 /* Temporary file for innodb monitor output */
86 extern FILE* srv_monitor_file;
87 /* Mutex for locking srv_dict_tmpfile.
88 This mutex has a very high rank; threads reserving it should not
89 be holding any InnoDB latches. */
90 extern mutex_t srv_dict_tmpfile_mutex;
91 /* Temporary file for output from the data dictionary */
92 extern FILE* srv_dict_tmpfile;
93 /* Mutex for locking srv_misc_tmpfile.
94 This mutex has a very low rank; threads reserving it should not
95 acquire any further latches or sleep before releasing this one. */
96 extern mutex_t srv_misc_tmpfile_mutex;
97 /* Temporary file for miscellanous diagnostic output */
98 extern FILE* srv_misc_tmpfile;
99 
100 /* Server parameters which are read from the initfile */
101 
102 extern char* srv_data_home;
103 #ifdef UNIV_LOG_ARCHIVE
104 extern char* srv_arch_dir;
105 #endif /* UNIV_LOG_ARCHIVE */
106 
109 #ifndef UNIV_HOTBACKUP
110 extern my_bool srv_file_per_table;
111 #else
112 extern ibool srv_file_per_table;
113 #endif /* UNIV_HOTBACKUP */
114 
115 extern ulint srv_file_format;
119 extern ulint srv_max_file_format_at_startup;
122 extern ibool srv_locks_unsafe_for_binlog;
123 #endif /* !UNIV_HOTBACKUP */
124 
125 /* If this flag is TRUE, then we will use the native aio of the
126 OS (provided we compiled Innobase with it in), otherwise we will
127 use simulated aio we build below with threads.
128 Currently we support native aio on windows and linux */
129 extern my_bool srv_use_native_aio;
130 #ifdef __WIN__
131 extern ibool srv_use_native_conditions;
132 #endif
133 extern ulint srv_n_data_files;
134 extern char** srv_data_file_names;
135 extern ulint* srv_data_file_sizes;
136 extern ulint* srv_data_file_is_raw_partition;
137 
138 extern ibool srv_auto_extend_last_data_file;
139 extern ulint srv_last_file_size_max;
140 extern char** srv_log_group_home_dirs;
141 #ifndef UNIV_HOTBACKUP
142 extern unsigned int srv_auto_extend_increment;
143 
144 extern ibool srv_created_new_raw;
145 
146 extern ulint srv_n_log_groups;
147 extern ulint srv_n_log_files;
148 extern ulint srv_log_file_size;
149 extern ulint srv_log_buffer_size;
150 extern ulong srv_flush_log_at_trx_commit;
151 extern bool srv_adaptive_flushing;
152 
153 
154 /* The sort order table of the MySQL latin1_swedish_ci character set
155 collation */
156 #if defined(BUILD_DRIZZLE)
157 extern const byte srv_latin1_ordering[256];
158 extern bool srv_use_sys_malloc;
159 #else
160 extern const byte* srv_latin1_ordering;
161 # ifndef UNIV_HOTBACKUP
162 extern my_bool srv_use_sys_malloc;
163 # else
164 extern ibool srv_use_sys_malloc;
165 # endif /* UNIV_HOTBACKUP */
166 #endif /* BUILD_DRIZZLE */
167 extern ulint srv_buf_pool_size;
168 extern ulint srv_buf_pool_instances;
169 extern ulint srv_buf_pool_old_size;
170 extern ulint srv_buf_pool_curr_size;
171 extern ulint srv_mem_pool_size;
172 extern ulint srv_lock_table_size;
173 
174 extern ulint srv_n_file_io_threads;
175 extern ulong srv_read_ahead_threshold;
176 extern ulint srv_n_read_io_threads;
177 extern ulint srv_n_write_io_threads;
178 
179 /* Number of IO operations per second the server can do */
180 extern ulong srv_io_capacity;
181 /* Returns the number of IO operations that is X percent of the
182 capacity. PCT_IO(5) -> returns the number of IO operations that
183 is 5% of the max where max is srv_io_capacity. */
184 #define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
185 
186 #ifdef UNIV_LOG_ARCHIVE
187 extern ibool srv_log_archive_on;
188 extern ibool srv_archive_recovery;
189 extern ib_uint64_t srv_archive_recovery_limit_lsn;
190 #endif /* UNIV_LOG_ARCHIVE */
191 
192 extern char* srv_file_flush_method_str;
193 extern ulint srv_unix_file_flush_method;
194 extern ulint srv_win_file_flush_method;
195 
196 extern ulint srv_max_n_open_files;
197 
198 extern ulint srv_max_dirty_pages_pct;
199 
200 extern ulint srv_force_recovery;
201 extern ulong srv_thread_concurrency;
202 
203 extern ulint srv_max_n_threads;
204 
205 extern lint srv_conc_n_threads;
206 
207 extern ulint srv_fast_shutdown; /* If this is 1, do not do a
208  purge and index buffer merge.
209  If this 2, do not even flush the
210  buffer pool to data files at the
211  shutdown: we effectively 'crash'
212  InnoDB (but lose no committed
213  transactions). */
214 extern ibool srv_innodb_status;
215 
216 extern ib_uint64_t srv_stats_sample_pages;
217 
218 extern ibool srv_use_doublewrite_buf;
219 extern ibool srv_use_checksums;
220 
221 extern ulong srv_max_buf_pool_modified_pct;
222 extern ulong srv_max_purge_lag;
223 
224 extern ulong srv_replication_delay;
225 
226 extern uint64_t srv_ibuf_max_size;
227 extern uint32_t srv_ibuf_active_contract;
228 extern uint32_t srv_ibuf_accel_rate;
229 extern uint32_t srv_checkpoint_age_target;
230 extern uint32_t srv_flush_neighbor_pages;
231 extern uint32_t srv_read_ahead;
232 extern uint32_t srv_adaptive_flushing_method;
233 
234 extern ibool srv_read_only;
235 extern ibool srv_fake_write;
236 extern ibool srv_apply_log_only;
237 
238 /*-------------------------------------------*/
239 
240 extern ulint srv_n_rows_inserted;
241 extern ulint srv_n_rows_updated;
242 extern ulint srv_n_rows_deleted;
243 extern ulint srv_n_rows_read;
244 
245 extern ibool srv_print_innodb_monitor;
246 extern ibool srv_print_innodb_lock_monitor;
247 extern ibool srv_print_innodb_tablespace_monitor;
248 extern ibool srv_print_verbose_log;
249 extern ibool srv_print_innodb_table_monitor;
250 
251 extern ibool srv_lock_timeout_active;
252 extern ibool srv_monitor_active;
253 extern ibool srv_error_monitor_active;
254 
255 extern ulong srv_n_spin_wait_rounds;
256 extern ulong srv_n_free_tickets_to_enter;
257 extern ulong srv_thread_sleep_delay;
258 extern ulong srv_spin_wait_delay;
259 extern ibool srv_priority_boost;
260 
261 extern ulint srv_truncated_status_writes;
262 
263 #ifdef UNIV_DEBUG
264 extern ibool srv_print_thread_releases;
265 extern ibool srv_print_lock_waits;
266 extern ibool srv_print_buf_io;
267 extern ibool srv_print_log_io;
268 extern ibool srv_print_latch_waits;
269 #else /* UNIV_DEBUG */
270 # define srv_print_thread_releases FALSE
271 # define srv_print_lock_waits FALSE
272 # define srv_print_buf_io FALSE
273 # define srv_print_log_io FALSE
274 # define srv_print_latch_waits FALSE
275 #endif /* UNIV_DEBUG */
276 
277 extern ulint srv_activity_count;
278 extern ulint srv_fatal_semaphore_wait_threshold;
279 extern ulint srv_dml_needed_delay;
280 
281 extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs,
282  query threads, and lock table: we allocate
283  it from dynamic memory to get it to the
284  same DRAM page as other hotspot semaphores */
285 extern mutex_t* commit_id_mutex_temp;
286 
287 #define kernel_mutex (*kernel_mutex_temp)
288 #define commit_id_mutex (*commit_id_mutex_temp)
289 
290 #define SRV_MAX_N_IO_THREADS 130
291 
292 /* Array of English strings describing the current state of an
293 i/o handler thread */
294 extern const char* srv_io_thread_op_info[];
295 extern const char* srv_io_thread_function[];
296 
297 /* the number of the log write requests done */
298 extern ulint srv_log_write_requests;
299 
300 /* the number of physical writes to the log performed */
301 extern ulint srv_log_writes;
302 
303 /* amount of data written to the log files in bytes */
304 extern ulint srv_os_log_written;
305 
306 /* amount of writes being done to the log files */
307 extern ulint srv_os_log_pending_writes;
308 
309 /* we increase this counter, when there we don't have enough space in the
310 log buffer and have to flush it */
311 extern ulint srv_log_waits;
312 
313 /* the number of purge threads to use from the worker pool (currently 0 or 1) */
314 extern ulong srv_n_purge_threads;
315 
316 /* the number of records to purge in one batch */
317 extern ulong srv_purge_batch_size;
318 
319 /* variable that counts amount of data read in total (in bytes) */
320 extern ulint srv_data_read;
321 
322 /* here we count the amount of data written in total (in bytes) */
323 extern ulint srv_data_written;
324 
325 /* this variable counts the amount of times, when the doublewrite buffer
326 was flushed */
327 extern ulint srv_dblwr_writes;
328 
329 /* here we store the number of pages that have been flushed to the
330 doublewrite buffer */
331 extern ulint srv_dblwr_pages_written;
332 
333 /* in this variable we store the number of write requests issued */
334 extern ulint srv_buf_pool_write_requests;
335 
336 /* here we store the number of times when we had to wait for a free page
337 in the buffer pool. It happens when the buffer pool is full and we need
338 to make a flush, in order to be able to read or create a page. */
339 extern ulint srv_buf_pool_wait_free;
340 
341 /* variable to count the number of pages that were written from the
342 buffer pool to disk */
343 extern ulint srv_buf_pool_flushed;
344 
347 extern ulint srv_buf_pool_reads;
348 
350 extern uint32_t srv_auto_lru_dump;
351 
354 
357 
359 typedef struct srv_sys_struct srv_sys_t;
360 
362 extern srv_sys_t* srv_sys;
363 
364 # ifdef UNIV_PFS_THREAD
365 /* Keys to register InnoDB threads with performance schema */
366 extern mysql_pfs_key_t trx_rollback_clean_thread_key;
367 extern mysql_pfs_key_t io_handler_thread_key;
368 extern mysql_pfs_key_t srv_lock_timeout_thread_key;
369 extern mysql_pfs_key_t srv_error_monitor_thread_key;
370 extern mysql_pfs_key_t srv_monitor_thread_key;
371 extern mysql_pfs_key_t srv_master_thread_key;
372 
373 /* This macro register the current thread and its key with performance
374 schema */
375 # define pfs_register_thread(key) \
376 do { \
377  if (PSI_server) { \
378  struct PSI_thread* psi = PSI_server->new_thread(key, NULL, 0);\
379  if (psi) { \
380  PSI_server->set_thread(psi); \
381  } \
382  } \
383 } while (0)
384 
385 /* This macro delist the current thread from performance schema */
386 # define pfs_delete_thread() \
387 do { \
388  if (PSI_server) { \
389  PSI_server->delete_current_thread(); \
390  } \
391 } while (0)
392 # endif /* UNIV_PFS_THREAD */
393 
394 #endif /* !UNIV_HOTBACKUP */
395 
397 enum {
402 };
403 
406 enum {
416 };
417 
419 enum {
422 };
423 
429 enum {
446 };
447 
448 #ifndef UNIV_HOTBACKUP
449 
451  SRV_COM = 1,
455 #if 0
456  /* Utility threads */
457  SRV_BUFFER,
458  SRV_RECOVERY,
459  SRV_INSERT,
460 #endif
463 };
464 
465 /*********************************************************************/
468 UNIV_INTERN
469 ulint
470 srv_boot(void);
471 /*==========*/
472 /*********************************************************************/
474 UNIV_INTERN
475 void
476 srv_init(void);
477 /*==========*/
478 /*********************************************************************/
480 UNIV_INTERN
481 void
482 srv_free(void);
483 /*==========*/
484 /*********************************************************************/
487 UNIV_INTERN
488 void
489 srv_general_init(void);
490 /*==================*/
491 /*********************************************************************/
494 UNIV_INTERN
495 ulint
496 srv_get_n_threads(void);
497 /*===================*/
498 /*********************************************************************/
502 enum srv_thread_type
503 srv_get_thread_type(void);
504 /*=====================*/
505 /*********************************************************************/
507 UNIV_INTERN
508 void
510 /*======================*/
511  ulint i,
512  const char* str);
514 /*********************************************************************/
519 UNIV_INTERN
520 ulint
522 /*================*/
523  enum srv_thread_type type,
524  ulint n);
525 /*********************************************************************/
528 UNIV_INTERN
529 os_thread_ret_t
531 /*==============*/
532  void* arg);
534 /*******************************************************************/
536 UNIV_INTERN
537 void
539 /*=======================*/
540 /*******************************************************************/
546 UNIV_INTERN
547 void
549 /*===============================*/
550 /*******************************************************************/
552 UNIV_INTERN
553 void
555 /*========================*/
556 /*******************************************************************/
562 UNIV_INTERN
563 void
565 /*=====================================*/
566 /*********************************************************************/
569 UNIV_INTERN
570 void
572 /*==================*/
573  trx_t* trx);
575 /*********************************************************************/
578 UNIV_INTERN
579 void
581 /*========================*/
582  trx_t* trx);
584 /*********************************************************************/
587 UNIV_INTERN
588 void
590 /*=======================*/
591  trx_t* trx);
593 /*********************************************************************/
595 UNIV_INTERN
596 void
598 /*=================*/
599  trx_t* trx);
601 /***************************************************************/
607 UNIV_INTERN
608 void
610 /*=====================*/
611  que_thr_t* thr);
613 /********************************************************************/
616 UNIV_INTERN
617 void
619 /*==================================*/
620  que_thr_t* thr);
622 /*********************************************************************/
625 UNIV_INTERN
626 os_thread_ret_t
628 /*====================*/
629  void* arg);
631 /*********************************************************************/
634 UNIV_INTERN
635 os_thread_ret_t
637 /*===============*/
638  void* arg);
640 /*************************************************************************
641 A thread which prints warnings about semaphore waits which have lasted
642 too long. These can be used to track bugs which cause hangs.
643 @return a dummy parameter */
644 UNIV_INTERN
645 os_thread_ret_t
647 /*=====================*/
648  void* arg);
650 /*********************************************************************/
654 UNIV_INTERN
655 os_thread_ret_t
657 /*====================*/
658  void* arg);
660 /******************************************************************/
664 UNIV_INTERN
665 ibool
667 /*======================*/
668  FILE* file,
669  ibool nowait,
670  ulint* trx_start,
672  ulint* trx_end);
675 /******************************************************************/
677 UNIV_INTERN
678 void
680 /*==========================*/
681 
682 /******************************************************************/
684 UNIV_INTERN
685 void
687 /*=========================*/
688 
689 /*********************************************************************/
692 UNIV_INTERN
693 os_thread_ret_t
695 /*=============*/
696  void* /*arg __attribute__((unused))*/);
699 /**********************************************************************/
702 UNIV_INTERN
703 void
705 /*=====================*/
706  que_thr_t* thr);
708 /**********************************************************************/
711 UNIV_INTERN
712 ibool
714 /*======================================*/
715 
731 #ifdef UNIV_DEBUG
732  ulint innodb_buffer_pool_pages_latched;
733 #endif /* UNIV_DEBUG */
757  ib_int64_t innodb_row_lock_time;
769 };
770 
773 
776 
782 };
783 
784 extern ulint srv_n_threads_active[];
785 #else /* !UNIV_HOTBACKUP */
786 # define srv_use_adaptive_hash_indexes FALSE
787 # define srv_use_checksums TRUE
788 # define srv_use_native_aio FALSE
789 # define srv_force_recovery 0UL
790 # define srv_set_io_thread_op_info(t,info) ((void) 0)
791 # define srv_is_being_started 0
792 # define srv_win_file_flush_method SRV_WIN_IO_UNBUFFERED
793 # define srv_unix_file_flush_method SRV_UNIX_O_DSYNC
794 # define srv_start_raw_disk_in_use 0
795 # define srv_file_per_table 1
796 #endif /* !UNIV_HOTBACKUP */
797 
798 
799 #endif