~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/**************************************************//**
 
35
@file include/srv0srv.h
 
36
The server main program
 
37
 
 
38
Created 10/10/1995 Heikki Tuuri
 
39
*******************************************************/
 
40
 
 
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
 
 
56
/** 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#");
 
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
 
 
107
/** store to its own file each table created by an user; data
 
108
dictionary tables are in the system tablespace 0 */
 
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
/** The file format to use on new *.ibd files. */
 
115
extern ulint    srv_file_format;
 
116
/** Whether to check file format during startup.  A value of
 
117
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE.  The default is to
 
118
set it to the highest format we support. */
 
119
extern ulint    srv_max_file_format_at_startup;
 
120
/** Place locks to records only i.e. do not use next-key locking except
 
121
on duplicate key checking and foreign key checking */
 
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;      /*!< requested size in bytes */
 
168
extern ulint    srv_buf_pool_instances; /*!< requested number of buffer pool instances */
 
169
extern ulint    srv_buf_pool_old_size;  /*!< previously requested size */
 
170
extern ulint    srv_buf_pool_curr_size; /*!< current size in bytes */
 
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
 
 
345
/** Number of buffer pool reads that led to the
 
346
reading of a disk page */
 
347
extern ulint srv_buf_pool_reads;
 
348
 
 
349
/** Time in seconds between automatic buffer pool dumps */
 
350
extern uint32_t srv_auto_lru_dump;
 
351
 
 
352
/** Status variables to be passed to MySQL */
 
353
typedef struct export_var_struct export_struc;
 
354
 
 
355
/** Status variables to be passed to MySQL */
 
356
extern export_struc export_vars;
 
357
 
 
358
/** The server system */
 
359
typedef struct srv_sys_struct   srv_sys_t;
 
360
 
 
361
/** The server system */
 
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
 
 
396
/** Types of raw partitions in innodb_data_file_path */
 
397
enum {
 
398
        SRV_NOT_RAW = 0,        /*!< Not a raw partition */
 
399
        SRV_NEW_RAW,            /*!< A 'newraw' partition, only to be
 
400
                                initialized */
 
401
        SRV_OLD_RAW             /*!< An initialized raw partition */
 
402
};
 
403
 
 
404
/** Alternatives for the file flush option in Unix; see the InnoDB manual
 
405
about what these mean */
 
406
enum {
 
407
        SRV_UNIX_FSYNC = 1,     /*!< fsync, the default */
 
408
        SRV_UNIX_O_DSYNC,       /*!< open log files in O_SYNC mode */
 
409
        SRV_UNIX_LITTLESYNC,    /*!< do not call os_file_flush()
 
410
                                when writing data files, but do flush
 
411
                                after writing to log files */
 
412
        SRV_UNIX_NOSYNC,        /*!< do not flush after writing */
 
413
        SRV_UNIX_O_DIRECT,      /*!< invoke os_file_set_nocache() on
 
414
                                data files */
 
415
        SRV_UNIX_ALL_O_DIRECT   /*!< Open log file also with O_DIRECT */
 
416
};
 
417
 
 
418
/** Alternatives for file i/o in Windows */
 
419
enum {
 
420
        SRV_WIN_IO_NORMAL = 1,  /*!< buffered I/O */
 
421
        SRV_WIN_IO_UNBUFFERED   /*!< unbuffered I/O; this is the default */
 
422
};
 
423
 
 
424
/** Alternatives for srv_force_recovery. Non-zero values are intended
 
425
to help the user get a damaged database up so that he can dump intact
 
426
tables and rows with SELECT INTO OUTFILE. The database must not otherwise
 
427
be used with these options! A bigger number below means that all precautions
 
428
of lower numbers are included. */
 
429
enum {
 
430
        SRV_FORCE_IGNORE_CORRUPT = 1,   /*!< let the server run even if it
 
431
                                        detects a corrupt page */
 
432
        SRV_FORCE_NO_BACKGROUND = 2,    /*!< prevent the main thread from
 
433
                                        running: if a crash would occur
 
434
                                        in purge, this prevents it */
 
435
        SRV_FORCE_NO_TRX_UNDO = 3,      /*!< do not run trx rollback after
 
436
                                        recovery */
 
437
        SRV_FORCE_NO_IBUF_MERGE = 4,    /*!< prevent also ibuf operations:
 
438
                                        if they would cause a crash, better
 
439
                                        not do them */
 
440
        SRV_FORCE_NO_UNDO_LOG_SCAN = 5, /*!< do not look at undo logs when
 
441
                                        starting the database: InnoDB will
 
442
                                        treat even incomplete transactions
 
443
                                        as committed */
 
444
        SRV_FORCE_NO_LOG_REDO = 6       /*!< do not do the log roll-forward
 
445
                                        in connection with recovery */
 
446
};
 
447
 
 
448
#ifndef UNIV_HOTBACKUP
 
449
/** Types of threads existing in the system. */
 
450
enum srv_thread_type {
 
451
        SRV_COM = 1,    /**< threads serving communication and queries */
 
452
        SRV_CONSOLE,    /**< thread serving console */
 
453
        SRV_WORKER,     /**< threads serving parallelized queries and
 
454
                        queries released from lock wait */
 
455
#if 0
 
456
        /* Utility threads */
 
457
        SRV_BUFFER,     /**< thread flushing dirty buffer blocks */
 
458
        SRV_RECOVERY,   /**< threads finishing a recovery */
 
459
        SRV_INSERT,     /**< thread flushing the insert buffer to disk */
 
460
#endif
 
461
        SRV_MASTER      /**< the master thread, (whose type number must
 
462
                        be biggest) */
 
463
};
 
464
 
 
465
/*********************************************************************//**
 
466
Boots Innobase server.
 
467
@return DB_SUCCESS or error code */
 
468
UNIV_INTERN
 
469
ulint
 
470
srv_boot(void);
 
471
/*==========*/
 
472
/*********************************************************************//**
 
473
Initializes the server. */
 
474
UNIV_INTERN
 
475
void
 
476
srv_init(void);
 
477
/*==========*/
 
478
/*********************************************************************//**
 
479
Frees the data structures created in srv_init(). */
 
480
UNIV_INTERN
 
481
void
 
482
srv_free(void);
 
483
/*==========*/
 
484
/*********************************************************************//**
 
485
Initializes the synchronization primitives, memory system, and the thread
 
486
local storage. */
 
487
UNIV_INTERN
 
488
void
 
489
srv_general_init(void);
 
490
/*==================*/
 
491
/*********************************************************************//**
 
492
Gets the number of threads in the system.
 
493
@return sum of srv_n_threads[] */
 
494
UNIV_INTERN
 
495
ulint
 
496
srv_get_n_threads(void);
 
497
/*===================*/
 
498
/*********************************************************************//**
 
499
Returns the calling thread type.
 
500
@return SRV_COM, ... */
 
501
 
 
502
enum srv_thread_type
 
503
srv_get_thread_type(void);
 
504
/*=====================*/
 
505
/*********************************************************************//**
 
506
Sets the info describing an i/o thread current state. */
 
507
UNIV_INTERN
 
508
void
 
509
srv_set_io_thread_op_info(
 
510
/*======================*/
 
511
        ulint           i,      /*!< in: the 'segment' of the i/o thread */
 
512
        const char*     str);   /*!< in: constant char string describing the
 
513
                                state */
 
514
/*********************************************************************//**
 
515
Releases threads of the type given from suspension in the thread table.
 
516
NOTE! The server mutex has to be reserved by the caller!
 
517
@return number of threads released: this may be less than n if not
 
518
enough threads were suspended at the moment */
 
519
UNIV_INTERN
 
520
ulint
 
521
srv_release_threads(
 
522
/*================*/
 
523
        enum srv_thread_type    type,   /*!< in: thread type */
 
524
        ulint                   n);     /*!< in: number of threads to release */
 
525
/*********************************************************************//**
 
526
The master thread controlling the server.
 
527
@return a dummy parameter */
 
528
UNIV_INTERN
 
529
os_thread_ret_t
 
530
srv_master_thread(
 
531
/*==============*/
 
532
        void*   arg);   /*!< in: a dummy parameter required by
 
533
                        os_thread_create */
 
534
/*******************************************************************//**
 
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
Tells the Innobase server that there has been activity in the database
 
542
and wakes up the master thread if it is suspended (not sleeping). Used
 
543
in the MySQL interface. Note that there is a small chance that the master
 
544
thread stays suspended (we do not protect our operation with the kernel
 
545
mutex, for performace reasons). */
 
546
UNIV_INTERN
 
547
void
 
548
srv_active_wake_master_thread(void);
 
549
/*===============================*/
 
550
/*******************************************************************//**
 
551
Wakes up the master thread if it is suspended or being suspended. */
 
552
UNIV_INTERN
 
553
void
 
554
srv_wake_master_thread(void);
 
555
/*========================*/
 
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
/*********************************************************************//**
 
567
Puts an OS thread to wait if there are too many concurrent threads
 
568
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
 
569
UNIV_INTERN
 
570
void
 
571
srv_conc_enter_innodb(
 
572
/*==================*/
 
573
        trx_t*  trx);   /*!< in: transaction object associated with the
 
574
                        thread */
 
575
/*********************************************************************//**
 
576
This lets a thread enter InnoDB regardless of the number of threads inside
 
577
InnoDB. This must be called when a thread ends a lock wait. */
 
578
UNIV_INTERN
 
579
void
 
580
srv_conc_force_enter_innodb(
 
581
/*========================*/
 
582
        trx_t*  trx);   /*!< in: transaction object associated with the
 
583
                        thread */
 
584
/*********************************************************************//**
 
585
This must be called when a thread exits InnoDB in a lock wait or at the
 
586
end of an SQL statement. */
 
587
UNIV_INTERN
 
588
void
 
589
srv_conc_force_exit_innodb(
 
590
/*=======================*/
 
591
        trx_t*  trx);   /*!< in: transaction object associated with the
 
592
                        thread */
 
593
/*********************************************************************//**
 
594
This must be called when a thread exits InnoDB. */
 
595
UNIV_INTERN
 
596
void
 
597
srv_conc_exit_innodb(
 
598
/*=================*/
 
599
        trx_t*  trx);   /*!< in: transaction object associated with the
 
600
                        thread */
 
601
/***************************************************************//**
 
602
Puts a MySQL OS thread to wait for a lock to be released. If an error
 
603
occurs during the wait trx->error_state associated with thr is
 
604
!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
 
605
are possible errors. DB_DEADLOCK is returned if selective deadlock
 
606
resolution chose this transaction as a victim. */
 
607
UNIV_INTERN
 
608
void
 
609
srv_suspend_mysql_thread(
 
610
/*=====================*/
 
611
        que_thr_t*      thr);   /*!< in: query thread associated with the MySQL
 
612
                                OS thread */
 
613
/********************************************************************//**
 
614
Releases a MySQL OS thread waiting for a lock to be released, if the
 
615
thread is already suspended. */
 
616
UNIV_INTERN
 
617
void
 
618
srv_release_mysql_thread_if_suspended(
 
619
/*==================================*/
 
620
        que_thr_t*      thr);   /*!< in: query thread associated with the
 
621
                                MySQL OS thread  */
 
622
/*********************************************************************//**
 
623
A thread which wakes up threads whose lock wait may have lasted too long.
 
624
@return a dummy parameter */
 
625
UNIV_INTERN
 
626
os_thread_ret_t
 
627
srv_lock_timeout_thread(
 
628
/*====================*/
 
629
        void*   arg);   /*!< in: a dummy parameter required by
 
630
                        os_thread_create */
 
631
/*********************************************************************//**
 
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
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
 
646
srv_error_monitor_thread(
 
647
/*=====================*/
 
648
        void*   arg);   /*!< in: a dummy parameter required by
 
649
                        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
/******************************************************************//**
 
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 */
 
664
UNIV_INTERN
 
665
ibool
 
666
srv_printf_innodb_monitor(
 
667
/*======================*/
 
668
        FILE*   file,           /*!< in: output stream */
 
669
        ibool   nowait,         /*!< in: whether to wait for kernel mutex */
 
670
        ulint*  trx_start,      /*!< out: file position of the start of
 
671
                                the list of active transactions */
 
672
        ulint*  trx_end);       /*!< out: file position of the end of
 
673
                                the list of active transactions */
 
674
 
 
675
/******************************************************************//**
 
676
Function to pass InnoDB status variables to MySQL */
 
677
UNIV_INTERN
 
678
void
 
679
srv_export_innodb_status(void);
 
680
/*==========================*/
 
681
 
 
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
/*======================================*/
 
715
 
 
716
/** Status variables to be passed to MySQL */
 
717
struct export_var_struct{
 
718
        ulint innodb_data_pending_reads;        /*!< Pending reads */
 
719
        ulint innodb_data_pending_writes;       /*!< Pending writes */
 
720
        ulint innodb_data_pending_fsyncs;       /*!< Pending fsyncs */
 
721
        ulint innodb_data_fsyncs;               /*!< Number of fsyncs so far */
 
722
        ulint innodb_data_read;                 /*!< Data bytes read */
 
723
        ulint innodb_data_writes;               /*!< I/O write requests */
 
724
        ulint innodb_data_written;              /*!< Data bytes written */
 
725
        ulint innodb_data_reads;                /*!< I/O read requests */
 
726
        ulint innodb_buffer_pool_pages_total;   /*!< Buffer pool size */
 
727
        ulint innodb_buffer_pool_pages_data;    /*!< Data pages */
 
728
        ulint innodb_buffer_pool_pages_dirty;   /*!< Dirty data pages */
 
729
        ulint innodb_buffer_pool_pages_misc;    /*!< Miscellanous pages */
 
730
        ulint innodb_buffer_pool_pages_free;    /*!< Free pages */
 
731
#ifdef UNIV_DEBUG
 
732
        ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
 
733
#endif /* UNIV_DEBUG */
 
734
        ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */
 
735
        ulint innodb_buffer_pool_reads;         /*!< srv_buf_pool_reads */
 
736
        ulint innodb_buffer_pool_wait_free;     /*!< srv_buf_pool_wait_free */
 
737
        ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
 
738
        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*/
 
741
        ulint innodb_dblwr_pages_written;       /*!< srv_dblwr_pages_written */
 
742
        ulint innodb_dblwr_writes;              /*!< srv_dblwr_writes */
 
743
        ibool innodb_have_atomic_builtins;      /*!< HAVE_ATOMIC_BUILTINS */
 
744
        ulint innodb_log_waits;                 /*!< srv_log_waits */
 
745
        ulint innodb_log_write_requests;        /*!< srv_log_write_requests */
 
746
        ulint innodb_log_writes;                /*!< srv_log_writes */
 
747
        ulint innodb_os_log_written;            /*!< srv_os_log_written */
 
748
        ulint innodb_os_log_fsyncs;             /*!< fil_n_log_flushes */
 
749
        ulint innodb_os_log_pending_writes;     /*!< srv_os_log_pending_writes */
 
750
        ulint innodb_os_log_pending_fsyncs;     /*!< fil_n_pending_log_flushes */
 
751
        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 */
 
755
        ulint innodb_row_lock_waits;            /*!< srv_n_lock_wait_count */
 
756
        ulint innodb_row_lock_current_waits;    /*!< srv_n_lock_wait_current_count */
 
757
        ib_int64_t innodb_row_lock_time;        /*!< srv_n_lock_wait_time
 
758
                                                / 1000 */
 
759
        ulint innodb_row_lock_time_avg;         /*!< srv_n_lock_wait_time
 
760
                                                / 1000
 
761
                                                / srv_n_lock_wait_count */
 
762
        ulint innodb_row_lock_time_max;         /*!< srv_n_lock_max_wait_time
 
763
                                                / 1000 */
 
764
        ulint innodb_rows_read;                 /*!< srv_n_rows_read */
 
765
        ulint innodb_rows_inserted;             /*!< srv_n_rows_inserted */
 
766
        ulint innodb_rows_updated;              /*!< srv_n_rows_updated */
 
767
        ulint innodb_rows_deleted;              /*!< srv_n_rows_deleted */
 
768
        ulint innodb_truncated_status_writes;   /*!< srv_truncated_status_writes */
 
769
};
 
770
 
 
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
/** The server system struct */
 
778
struct srv_sys_struct{
 
779
        srv_table_t*    threads;        /*!< server thread table */
 
780
        UT_LIST_BASE_NODE_T(que_thr_t)
 
781
                        tasks;          /*!< task queue */
 
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