~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/srv0srv.h

Does not work (compile issue in plugin).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
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, 2009, Innobase Oy. All Rights Reserved.
 
4
Copyright (c) 2008, 2009, Google Inc.
6
5
 
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.
12
11
 
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
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.
27
19
 
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
31
23
 
32
24
*****************************************************************************/
 
25
/***********************************************************************
 
26
 
 
27
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
28
Copyright (c) 2009, Percona Inc.
 
29
 
 
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
 
35
COPYING.Percona.
 
36
 
 
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.
 
40
 
 
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.
 
45
 
 
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
 
49
 
 
50
***********************************************************************/
33
51
 
34
52
/**************************************************//**
35
53
@file include/srv0srv.h
38
56
Created 10/10/1995 Heikki Tuuri
39
57
*******************************************************/
40
58
 
41
 
#pragma once
42
59
#ifndef srv0srv_h
43
60
#define srv0srv_h
44
61
 
49
66
#include "que0types.h"
50
67
#include "trx0types.h"
51
68
 
52
 
#include <string>
53
 
 
54
69
extern const char*      srv_main_thread_op_info;
55
70
 
56
71
/** Prefix used by MySQL to indicate pre-5.1 table name encoding */
57
 
/** LOOKIE HERE!!!! This used to be srv_mysql50_table_name_prefix[10]
58
 
    which was a buffer overrun, because it didn't allow for the trailing
59
 
    '\0'. Thanks C++! */
60
 
static const std::string srv_mysql50_table_name_prefix("#mysql50#");
 
72
extern const char       srv_mysql50_table_name_prefix[9];
61
73
 
62
74
/* When this event is set the lock timeout and InnoDB monitor
63
75
thread starts running */
64
76
extern os_event_t       srv_lock_timeout_thread_event;
65
77
 
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
78
/* If the last data file is auto-extended, we add this many pages to it
76
79
at a time */
77
80
#define SRV_AUTO_EXTEND_INCREMENT       \
116
119
/** Whether to check file format during startup.  A value of
117
120
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE.  The default is to
118
121
set it to the highest format we support. */
119
 
extern ulint    srv_max_file_format_at_startup;
 
122
extern ulint    srv_check_file_format_at_startup;
120
123
/** Place locks to records only i.e. do not use next-key locking except
121
124
on duplicate key checking and foreign key checking */
122
125
extern ibool    srv_locks_unsafe_for_binlog;
123
126
#endif /* !UNIV_HOTBACKUP */
124
127
 
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
128
extern ulint    srv_n_data_files;
134
129
extern char**   srv_data_file_names;
135
130
extern ulint*   srv_data_file_sizes;
165
160
# endif /* UNIV_HOTBACKUP */
166
161
#endif /* BUILD_DRIZZLE */
167
162
extern ulint    srv_buf_pool_size;      /*!< requested size in bytes */
168
 
extern ulint    srv_buf_pool_instances; /*!< requested number of buffer pool instances */
169
163
extern ulint    srv_buf_pool_old_size;  /*!< previously requested size */
170
164
extern ulint    srv_buf_pool_curr_size; /*!< current size in bytes */
171
165
extern ulint    srv_mem_pool_size;
184
178
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
185
179
 
186
180
#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;
 
181
extern ibool    srv_log_archive_on;
 
182
extern ibool    srv_archive_recovery;
 
183
extern dulint   srv_archive_recovery_limit_lsn;
190
184
#endif /* UNIV_LOG_ARCHIVE */
191
185
 
192
186
extern char*    srv_file_flush_method_str;
218
212
extern ibool    srv_use_doublewrite_buf;
219
213
extern ibool    srv_use_checksums;
220
214
 
 
215
extern ibool    srv_set_thread_priorities;
 
216
extern int      srv_query_thread_priority;
 
217
 
221
218
extern ulong    srv_max_buf_pool_modified_pct;
222
219
extern ulong    srv_max_purge_lag;
223
220
 
224
221
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
222
/*-------------------------------------------*/
239
223
 
240
224
extern ulint    srv_n_rows_inserted;
248
232
extern ibool    srv_print_verbose_log;
249
233
extern ibool    srv_print_innodb_table_monitor;
250
234
 
251
 
extern ibool    srv_lock_timeout_active;
252
 
extern ibool    srv_monitor_active;
 
235
extern ibool    srv_lock_timeout_and_monitor_active;
253
236
extern ibool    srv_error_monitor_active;
254
237
 
255
238
extern ulong    srv_n_spin_wait_rounds;
258
241
extern ulong    srv_spin_wait_delay;
259
242
extern ibool    srv_priority_boost;
260
243
 
261
 
extern ulint    srv_truncated_status_writes;
262
244
 
263
245
#ifdef UNIV_DEBUG
264
246
extern  ibool   srv_print_thread_releases;
282
264
                                query threads, and lock table: we allocate
283
265
                                it from dynamic memory to get it to the
284
266
                                same DRAM page as other hotspot semaphores */
285
 
extern mutex_t* commit_id_mutex_temp;
286
 
 
287
267
#define kernel_mutex (*kernel_mutex_temp)
288
 
#define commit_id_mutex (*commit_id_mutex_temp)
289
268
 
290
269
#define SRV_MAX_N_IO_THREADS    130
291
270
 
310
289
log buffer and have to flush it */
311
290
extern ulint srv_log_waits;
312
291
 
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
292
/* variable that counts amount of data read in total (in bytes) */
320
293
extern ulint srv_data_read;
321
294
 
345
318
/** Number of buffer pool reads that led to the
346
319
reading of a disk page */
347
320
extern ulint srv_buf_pool_reads;
348
 
 
349
 
/** Time in seconds between automatic buffer pool dumps */
350
 
extern uint32_t srv_auto_lru_dump;
 
321
/** Number of sequential read-aheads */
 
322
extern ulint srv_read_ahead_seq;
 
323
/** Number of random read-aheads */
 
324
extern ulint srv_read_ahead_rnd;
351
325
 
352
326
/** Status variables to be passed to MySQL */
353
327
typedef struct export_var_struct export_struc;
360
334
 
361
335
/** The server system */
362
336
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
337
#endif /* !UNIV_HOTBACKUP */
395
338
 
396
339
/** Types of raw partitions in innodb_data_file_path */
410
353
                                when writing data files, but do flush
411
354
                                after writing to log files */
412
355
        SRV_UNIX_NOSYNC,        /*!< do not flush after writing */
413
 
        SRV_UNIX_O_DIRECT,      /*!< invoke os_file_set_nocache() on
 
356
        SRV_UNIX_O_DIRECT       /*!< invoke os_file_set_nocache() on
414
357
                                data files */
415
 
        SRV_UNIX_ALL_O_DIRECT   /*!< Open log file also with O_DIRECT */
416
358
};
417
359
 
418
360
/** Alternatives for file i/o in Windows */
476
418
srv_init(void);
477
419
/*==========*/
478
420
/*********************************************************************//**
479
 
Frees the data structures created in srv_init(). */
 
421
Frees the OS fast mutex created in srv_boot(). */
480
422
UNIV_INTERN
481
423
void
482
424
srv_free(void);
532
474
        void*   arg);   /*!< in: a dummy parameter required by
533
475
                        os_thread_create */
534
476
/*******************************************************************//**
535
 
Wakes up the purge thread if it's not already awake. */
536
 
UNIV_INTERN
537
 
void
538
 
srv_wake_purge_thread(void);
539
 
/*=======================*/
540
 
/*******************************************************************//**
541
477
Tells the Innobase server that there has been activity in the database
542
478
and wakes up the master thread if it is suspended (not sleeping). Used
543
479
in the MySQL interface. Note that there is a small chance that the master
553
489
void
554
490
srv_wake_master_thread(void);
555
491
/*========================*/
556
 
/*******************************************************************//**
557
 
Tells the purge thread that there has been activity in the database
558
 
and wakes up the purge thread if it is suspended (not sleeping).  Note
559
 
that there is a small chance that the purge thread stays suspended
560
 
(we do not protect our operation with the kernel mutex, for
561
 
performace reasons). */
562
 
UNIV_INTERN
563
 
void
564
 
srv_wake_purge_thread_if_not_active(void);
565
 
/*=====================================*/
566
492
/*********************************************************************//**
567
493
Puts an OS thread to wait if there are too many concurrent threads
568
494
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
621
547
                                MySQL OS thread  */
622
548
/*********************************************************************//**
623
549
A thread which wakes up threads whose lock wait may have lasted too long.
 
550
This also prints the info output by various InnoDB monitors.
624
551
@return a dummy parameter */
625
552
UNIV_INTERN
626
553
os_thread_ret_t
627
 
srv_lock_timeout_thread(
628
 
/*====================*/
 
554
srv_lock_timeout_and_monitor_thread(
 
555
/*================================*/
629
556
        void*   arg);   /*!< in: a dummy parameter required by
630
557
                        os_thread_create */
631
558
/*********************************************************************//**
632
 
A thread which prints the info output by various InnoDB monitors.
633
 
@return a dummy parameter */
634
 
UNIV_INTERN
635
 
os_thread_ret_t
636
 
srv_monitor_thread(
637
 
/*===============*/
638
 
        void*   arg);   /*!< in: a dummy parameter required by
639
 
                        os_thread_create */
640
 
/*************************************************************************
641
559
A thread which prints warnings about semaphore waits which have lasted
642
560
too long. These can be used to track bugs which cause hangs.
643
561
@return a dummy parameter */
647
565
/*=====================*/
648
566
        void*   arg);   /*!< in: a dummy parameter required by
649
567
                        os_thread_create */
650
 
/*********************************************************************//**
651
 
A thread which restores the buffer pool from a dump file on startup and does
652
 
periodic buffer pool dumps.
653
 
@return a dummy parameter */
654
 
UNIV_INTERN
655
 
os_thread_ret_t
656
 
srv_LRU_dump_restore_thread(
657
 
/*====================*/
658
 
        void*   arg);   /*!< in: a dummy parameter required by
659
 
                        os_thread_create */
660
568
/******************************************************************//**
661
 
Outputs to a file the output of the InnoDB Monitor.
662
 
@return FALSE if not all information printed
663
 
due to failure to obtain necessary mutex */
 
569
Outputs to a file the output of the InnoDB Monitor. */
664
570
UNIV_INTERN
665
 
ibool
 
571
void
666
572
srv_printf_innodb_monitor(
667
573
/*======================*/
668
574
        FILE*   file,           /*!< in: output stream */
669
 
        ibool   nowait,         /*!< in: whether to wait for kernel mutex */
670
575
        ulint*  trx_start,      /*!< out: file position of the start of
671
576
                                the list of active transactions */
672
577
        ulint*  trx_end);       /*!< out: file position of the end of
679
584
srv_export_innodb_status(void);
680
585
/*==========================*/
681
586
 
682
 
/******************************************************************//**
683
 
Increment the server activity counter. */
684
 
UNIV_INTERN
685
 
void
686
 
srv_inc_activity_count(void);
687
 
/*=========================*/
688
 
 
689
 
/*********************************************************************//**
690
 
Asynchronous purge thread.
691
 
@return a dummy parameter */
692
 
UNIV_INTERN
693
 
os_thread_ret_t
694
 
srv_purge_thread(
695
 
/*=============*/
696
 
        void*   /*arg __attribute__((unused))*/); /*!< in: a dummy parameter
697
 
                                              required by os_thread_create */
698
 
 
699
 
/**********************************************************************//**
700
 
Enqueues a task to server task queue and releases a worker thread, if there
701
 
is a suspended one. */
702
 
UNIV_INTERN
703
 
void
704
 
srv_que_task_enqueue_low(
705
 
/*=====================*/
706
 
        que_thr_t*      thr);   /*!< in: query thread */
707
 
 
708
 
/**********************************************************************//**
709
 
Check whether any background thread is active.
710
 
@return FALSE if all are are suspended or have exited. */
711
 
UNIV_INTERN
712
 
ibool
713
 
srv_is_any_background_thread_active(void);
714
 
/*======================================*/
 
587
/** Thread slot in the thread table */
 
588
typedef struct srv_slot_struct  srv_slot_t;
 
589
 
 
590
/** Thread table is an array of slots */
 
591
typedef srv_slot_t      srv_table_t;
715
592
 
716
593
/** Status variables to be passed to MySQL */
717
594
struct export_var_struct{
731
608
#ifdef UNIV_DEBUG
732
609
        ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
733
610
#endif /* UNIV_DEBUG */
734
 
        ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */
 
611
        ulint innodb_buffer_pool_read_requests; /*!< buf_pool->n_page_gets */
735
612
        ulint innodb_buffer_pool_reads;         /*!< srv_buf_pool_reads */
736
613
        ulint innodb_buffer_pool_wait_free;     /*!< srv_buf_pool_wait_free */
737
614
        ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
738
615
        ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
739
 
        ulint innodb_buffer_pool_read_ahead;    /*!< srv_read_ahead */
740
 
        ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
 
616
        ulint innodb_buffer_pool_read_ahead_seq;/*!< srv_read_ahead_seq */
 
617
        ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */
741
618
        ulint innodb_dblwr_pages_written;       /*!< srv_dblwr_pages_written */
742
619
        ulint innodb_dblwr_writes;              /*!< srv_dblwr_writes */
743
620
        ibool innodb_have_atomic_builtins;      /*!< HAVE_ATOMIC_BUILTINS */
749
626
        ulint innodb_os_log_pending_writes;     /*!< srv_os_log_pending_writes */
750
627
        ulint innodb_os_log_pending_fsyncs;     /*!< fil_n_pending_log_flushes */
751
628
        ulint innodb_page_size;                 /*!< UNIV_PAGE_SIZE */
752
 
        ulint innodb_pages_created;             /*!< buf_pool->stat.n_pages_created */
753
 
        ulint innodb_pages_read;                /*!< buf_pool->stat.n_pages_read */
754
 
        ulint innodb_pages_written;             /*!< buf_pool->stat.n_pages_written */
 
629
        ulint innodb_pages_created;             /*!< buf_pool->n_pages_created */
 
630
        ulint innodb_pages_read;                /*!< buf_pool->n_pages_read */
 
631
        ulint innodb_pages_written;             /*!< buf_pool->n_pages_written */
755
632
        ulint innodb_row_lock_waits;            /*!< srv_n_lock_wait_count */
756
633
        ulint innodb_row_lock_current_waits;    /*!< srv_n_lock_wait_current_count */
757
634
        ib_int64_t innodb_row_lock_time;        /*!< srv_n_lock_wait_time
765
642
        ulint innodb_rows_inserted;             /*!< srv_n_rows_inserted */
766
643
        ulint innodb_rows_updated;              /*!< srv_n_rows_updated */
767
644
        ulint innodb_rows_deleted;              /*!< srv_n_rows_deleted */
768
 
        ulint innodb_truncated_status_writes;   /*!< srv_truncated_status_writes */
769
645
};
770
646
 
771
 
/** Thread slot in the thread table */
772
 
typedef struct srv_slot_struct  srv_slot_t;
773
 
 
774
 
/** Thread table is an array of slots */
775
 
typedef srv_slot_t      srv_table_t;
776
 
 
777
647
/** The server system struct */
778
648
struct srv_sys_struct{
779
649
        srv_table_t*    threads;        /*!< server thread table */
782
652
};
783
653
 
784
654
extern ulint    srv_n_threads_active[];
 
655
 
785
656
#else /* !UNIV_HOTBACKUP */
 
657
# define srv_use_checksums                      TRUE
786
658
# define srv_use_adaptive_hash_indexes          FALSE
787
 
# define srv_use_checksums                      TRUE
788
 
# define srv_use_native_aio                     FALSE
789
659
# define srv_force_recovery                     0UL
790
660
# define srv_set_io_thread_op_info(t,info)      ((void) 0)
791
661
# define srv_is_being_started                   0