~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Olaf van der Spek
  • Date: 2011-02-12 18:24:24 UTC
  • mto: (2167.1.2 build) (2172.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2168.
  • Revision ID: olafvdspek@gmail.com-20110212182424-kgnm9osi7qo97at2
casts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
4
 
Copyright (c) 2008, 2009, Google Inc.
 
3
Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
 
4
Copyright (C) 2008, 2009, Google Inc.
 
5
Copyright (C) 2009, Percona Inc.
5
6
 
6
7
Portions of this file contain modifications contributed and copyrighted by
7
8
Google, Inc. Those modifications are gratefully acknowledged and are described
9
10
incorporated with their permission, and subject to the conditions contained in
10
11
the file COPYING.Google.
11
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
 
12
20
This program is free software; you can redistribute it and/or modify it under
13
21
the terms of the GNU General Public License as published by the Free Software
14
22
Foundation; version 2 of the License.
18
26
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19
27
 
20
28
You should have received a copy of the GNU General Public License along with
21
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
 
Place, Suite 330, Boston, MA 02111-1307 USA
 
29
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
30
St, Fifth Floor, Boston, MA 02110-1301 USA
23
31
 
24
32
*****************************************************************************/
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
 
***********************************************************************/
51
33
 
52
34
/**************************************************//**
53
35
@file include/srv0srv.h
66
48
#include "que0types.h"
67
49
#include "trx0types.h"
68
50
 
 
51
#include <string>
 
52
 
69
53
extern const char*      srv_main_thread_op_info;
70
54
 
71
55
/** Prefix used by MySQL to indicate pre-5.1 table name encoding */
72
 
extern const char       srv_mysql50_table_name_prefix[9];
 
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
 
58
    '\0'. Thanks C++! */
 
59
static const std::string srv_mysql50_table_name_prefix("#mysql50#");
73
60
 
74
61
/* When this event is set the lock timeout and InnoDB monitor
75
62
thread starts running */
76
63
extern os_event_t       srv_lock_timeout_thread_event;
77
64
 
 
65
/* The monitor thread waits on this event. */
 
66
extern os_event_t       srv_monitor_event;
 
67
 
 
68
/* The lock timeout thread waits on this event. */
 
69
extern os_event_t       srv_timeout_event;
 
70
 
 
71
/* The error monitor thread waits on this event. */
 
72
extern os_event_t       srv_error_event;
 
73
 
78
74
/* If the last data file is auto-extended, we add this many pages to it
79
75
at a time */
80
76
#define SRV_AUTO_EXTEND_INCREMENT       \
119
115
/** Whether to check file format during startup.  A value of
120
116
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE.  The default is to
121
117
set it to the highest format we support. */
122
 
extern ulint    srv_check_file_format_at_startup;
 
118
extern ulint    srv_max_file_format_at_startup;
123
119
/** Place locks to records only i.e. do not use next-key locking except
124
120
on duplicate key checking and foreign key checking */
125
121
extern ibool    srv_locks_unsafe_for_binlog;
126
122
#endif /* !UNIV_HOTBACKUP */
127
123
 
 
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;
 
129
#ifdef __WIN__
 
130
extern ibool    srv_use_native_conditions;
 
131
#endif
128
132
extern ulint    srv_n_data_files;
129
133
extern char**   srv_data_file_names;
130
134
extern ulint*   srv_data_file_sizes;
160
164
# endif /* UNIV_HOTBACKUP */
161
165
#endif /* BUILD_DRIZZLE */
162
166
extern ulint    srv_buf_pool_size;      /*!< requested size in bytes */
 
167
extern ulint    srv_buf_pool_instances; /*!< requested number of buffer pool instances */
163
168
extern ulint    srv_buf_pool_old_size;  /*!< previously requested size */
164
169
extern ulint    srv_buf_pool_curr_size; /*!< current size in bytes */
165
170
extern ulint    srv_mem_pool_size;
178
183
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
179
184
 
180
185
#ifdef UNIV_LOG_ARCHIVE
181
 
extern ibool    srv_log_archive_on;
182
 
extern ibool    srv_archive_recovery;
183
 
extern dulint   srv_archive_recovery_limit_lsn;
 
186
extern ibool            srv_log_archive_on;
 
187
extern ibool            srv_archive_recovery;
 
188
extern ib_uint64_t      srv_archive_recovery_limit_lsn;
184
189
#endif /* UNIV_LOG_ARCHIVE */
185
190
 
186
191
extern char*    srv_file_flush_method_str;
212
217
extern ibool    srv_use_doublewrite_buf;
213
218
extern ibool    srv_use_checksums;
214
219
 
215
 
extern ibool    srv_set_thread_priorities;
216
 
extern int      srv_query_thread_priority;
217
 
 
218
220
extern ulong    srv_max_buf_pool_modified_pct;
219
221
extern ulong    srv_max_purge_lag;
220
222
 
232
234
extern ibool    srv_print_verbose_log;
233
235
extern ibool    srv_print_innodb_table_monitor;
234
236
 
235
 
extern ibool    srv_lock_timeout_and_monitor_active;
 
237
extern ibool    srv_lock_timeout_active;
 
238
extern ibool    srv_monitor_active;
236
239
extern ibool    srv_error_monitor_active;
237
240
 
238
241
extern ulong    srv_n_spin_wait_rounds;
241
244
extern ulong    srv_spin_wait_delay;
242
245
extern ibool    srv_priority_boost;
243
246
 
 
247
extern ulint    srv_truncated_status_writes;
244
248
 
245
249
#ifdef UNIV_DEBUG
246
250
extern  ibool   srv_print_thread_releases;
264
268
                                query threads, and lock table: we allocate
265
269
                                it from dynamic memory to get it to the
266
270
                                same DRAM page as other hotspot semaphores */
 
271
extern mutex_t* commit_id_mutex_temp;
 
272
 
267
273
#define kernel_mutex (*kernel_mutex_temp)
 
274
#define commit_id_mutex (*commit_id_mutex_temp)
268
275
 
269
276
#define SRV_MAX_N_IO_THREADS    130
270
277
 
289
296
log buffer and have to flush it */
290
297
extern ulint srv_log_waits;
291
298
 
 
299
/* the number of purge threads to use from the worker pool (currently 0 or 1) */
 
300
extern ulong srv_n_purge_threads;
 
301
 
 
302
/* the number of records to purge in one batch */
 
303
extern ulong srv_purge_batch_size;
 
304
 
292
305
/* variable that counts amount of data read in total (in bytes) */
293
306
extern ulint srv_data_read;
294
307
 
318
331
/** Number of buffer pool reads that led to the
319
332
reading of a disk page */
320
333
extern ulint srv_buf_pool_reads;
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;
325
334
 
326
335
/** Status variables to be passed to MySQL */
327
336
typedef struct export_var_struct export_struc;
334
343
 
335
344
/** The server system */
336
345
extern srv_sys_t*       srv_sys;
 
346
 
 
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;
 
355
 
 
356
/* This macro register the current thread and its key with performance
 
357
schema */
 
358
#  define pfs_register_thread(key)                      \
 
359
do {                                                            \
 
360
        if (PSI_server) {                                       \
 
361
                struct PSI_thread* psi = PSI_server->new_thread(key, NULL, 0);\
 
362
                if (psi) {                                      \
 
363
                        PSI_server->set_thread(psi);            \
 
364
                }                                               \
 
365
        }                                                       \
 
366
} while (0)
 
367
 
 
368
/* This macro delist the current thread from performance schema */
 
369
#  define pfs_delete_thread()                           \
 
370
do {                                                            \
 
371
        if (PSI_server) {                                       \
 
372
                PSI_server->delete_current_thread();            \
 
373
        }                                                       \
 
374
} while (0)
 
375
# endif /* UNIV_PFS_THREAD */
 
376
 
337
377
#endif /* !UNIV_HOTBACKUP */
338
378
 
339
379
/** Types of raw partitions in innodb_data_file_path */
418
458
srv_init(void);
419
459
/*==========*/
420
460
/*********************************************************************//**
421
 
Frees the OS fast mutex created in srv_boot(). */
 
461
Frees the data structures created in srv_init(). */
422
462
UNIV_INTERN
423
463
void
424
464
srv_free(void);
474
514
        void*   arg);   /*!< in: a dummy parameter required by
475
515
                        os_thread_create */
476
516
/*******************************************************************//**
 
517
Wakes up the purge thread if it's not already awake. */
 
518
UNIV_INTERN
 
519
void
 
520
srv_wake_purge_thread(void);
 
521
/*=======================*/
 
522
/*******************************************************************//**
477
523
Tells the Innobase server that there has been activity in the database
478
524
and wakes up the master thread if it is suspended (not sleeping). Used
479
525
in the MySQL interface. Note that there is a small chance that the master
489
535
void
490
536
srv_wake_master_thread(void);
491
537
/*========================*/
 
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). */
 
544
UNIV_INTERN
 
545
void
 
546
srv_wake_purge_thread_if_not_active(void);
 
547
/*=====================================*/
492
548
/*********************************************************************//**
493
549
Puts an OS thread to wait if there are too many concurrent threads
494
550
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
547
603
                                MySQL OS thread  */
548
604
/*********************************************************************//**
549
605
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.
551
606
@return a dummy parameter */
552
607
UNIV_INTERN
553
608
os_thread_ret_t
554
 
srv_lock_timeout_and_monitor_thread(
555
 
/*================================*/
 
609
srv_lock_timeout_thread(
 
610
/*====================*/
556
611
        void*   arg);   /*!< in: a dummy parameter required by
557
612
                        os_thread_create */
558
613
/*********************************************************************//**
 
614
A thread which prints the info output by various InnoDB monitors.
 
615
@return a dummy parameter */
 
616
UNIV_INTERN
 
617
os_thread_ret_t
 
618
srv_monitor_thread(
 
619
/*===============*/
 
620
        void*   arg);   /*!< in: a dummy parameter required by
 
621
                        os_thread_create */
 
622
/*************************************************************************
559
623
A thread which prints warnings about semaphore waits which have lasted
560
624
too long. These can be used to track bugs which cause hangs.
561
625
@return a dummy parameter */
566
630
        void*   arg);   /*!< in: a dummy parameter required by
567
631
                        os_thread_create */
568
632
/******************************************************************//**
569
 
Outputs to a file the output of the InnoDB Monitor. */
 
633
Outputs to a file the output of the InnoDB Monitor.
 
634
@return FALSE if not all information printed
 
635
due to failure to obtain necessary mutex */
570
636
UNIV_INTERN
571
 
void
 
637
ibool
572
638
srv_printf_innodb_monitor(
573
639
/*======================*/
574
640
        FILE*   file,           /*!< in: output stream */
 
641
        ibool   nowait,         /*!< in: whether to wait for kernel mutex */
575
642
        ulint*  trx_start,      /*!< out: file position of the start of
576
643
                                the list of active transactions */
577
644
        ulint*  trx_end);       /*!< out: file position of the end of
584
651
srv_export_innodb_status(void);
585
652
/*==========================*/
586
653
 
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;
 
654
/******************************************************************//**
 
655
Increment the server activity counter. */
 
656
UNIV_INTERN
 
657
void
 
658
srv_inc_activity_count(void);
 
659
/*=========================*/
 
660
 
 
661
/*********************************************************************//**
 
662
Asynchronous purge thread.
 
663
@return a dummy parameter */
 
664
UNIV_INTERN
 
665
os_thread_ret_t
 
666
srv_purge_thread(
 
667
/*=============*/
 
668
        void*   /*arg __attribute__((unused))*/); /*!< in: a dummy parameter
 
669
                                              required by os_thread_create */
 
670
 
 
671
/**********************************************************************//**
 
672
Enqueues a task to server task queue and releases a worker thread, if there
 
673
is a suspended one. */
 
674
UNIV_INTERN
 
675
void
 
676
srv_que_task_enqueue_low(
 
677
/*=====================*/
 
678
        que_thr_t*      thr);   /*!< in: query thread */
 
679
 
 
680
/**********************************************************************//**
 
681
Check whether any background thread is active.
 
682
@return FALSE if all are are suspended or have exited. */
 
683
UNIV_INTERN
 
684
ibool
 
685
srv_is_any_background_thread_active(void);
 
686
/*======================================*/
592
687
 
593
688
/** Status variables to be passed to MySQL */
594
689
struct export_var_struct{
608
703
#ifdef UNIV_DEBUG
609
704
        ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
610
705
#endif /* UNIV_DEBUG */
611
 
        ulint innodb_buffer_pool_read_requests; /*!< buf_pool->n_page_gets */
 
706
        ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */
612
707
        ulint innodb_buffer_pool_reads;         /*!< srv_buf_pool_reads */
613
708
        ulint innodb_buffer_pool_wait_free;     /*!< srv_buf_pool_wait_free */
614
709
        ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
615
710
        ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
616
 
        ulint innodb_buffer_pool_read_ahead_seq;/*!< srv_read_ahead_seq */
617
 
        ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */
 
711
        ulint innodb_buffer_pool_read_ahead;    /*!< srv_read_ahead */
 
712
        ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
618
713
        ulint innodb_dblwr_pages_written;       /*!< srv_dblwr_pages_written */
619
714
        ulint innodb_dblwr_writes;              /*!< srv_dblwr_writes */
620
715
        ibool innodb_have_atomic_builtins;      /*!< HAVE_ATOMIC_BUILTINS */
626
721
        ulint innodb_os_log_pending_writes;     /*!< srv_os_log_pending_writes */
627
722
        ulint innodb_os_log_pending_fsyncs;     /*!< fil_n_pending_log_flushes */
628
723
        ulint innodb_page_size;                 /*!< UNIV_PAGE_SIZE */
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 */
 
724
        ulint innodb_pages_created;             /*!< buf_pool->stat.n_pages_created */
 
725
        ulint innodb_pages_read;                /*!< buf_pool->stat.n_pages_read */
 
726
        ulint innodb_pages_written;             /*!< buf_pool->stat.n_pages_written */
632
727
        ulint innodb_row_lock_waits;            /*!< srv_n_lock_wait_count */
633
728
        ulint innodb_row_lock_current_waits;    /*!< srv_n_lock_wait_current_count */
634
729
        ib_int64_t innodb_row_lock_time;        /*!< srv_n_lock_wait_time
642
737
        ulint innodb_rows_inserted;             /*!< srv_n_rows_inserted */
643
738
        ulint innodb_rows_updated;              /*!< srv_n_rows_updated */
644
739
        ulint innodb_rows_deleted;              /*!< srv_n_rows_deleted */
 
740
        ulint innodb_truncated_status_writes;   /*!< srv_truncated_status_writes */
645
741
};
646
742
 
 
743
/** Thread slot in the thread table */
 
744
typedef struct srv_slot_struct  srv_slot_t;
 
745
 
 
746
/** Thread table is an array of slots */
 
747
typedef srv_slot_t      srv_table_t;
 
748
 
647
749
/** The server system struct */
648
750
struct srv_sys_struct{
649
751
        srv_table_t*    threads;        /*!< server thread table */
652
754
};
653
755
 
654
756
extern ulint    srv_n_threads_active[];
655
 
 
656
757
#else /* !UNIV_HOTBACKUP */
 
758
# define srv_use_adaptive_hash_indexes          FALSE
657
759
# define srv_use_checksums                      TRUE
658
 
# define srv_use_adaptive_hash_indexes          FALSE
 
760
# define srv_use_native_aio                     FALSE
659
761
# define srv_force_recovery                     0UL
660
762
# define srv_set_io_thread_op_info(t,info)      ((void) 0)
661
763
# define srv_is_being_started                   0