~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-10-07 16:55:53 UTC
  • mfrom: (1161.2.1 bug444827)
  • Revision ID: brian@gaz-20091007165553-9tnp7liw1k9g6gvc
Merge Padraig

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
 
#ifndef srv0srv_h
42
 
#define srv0srv_h
43
 
 
44
 
#include "univ.i"
45
 
#ifndef UNIV_HOTBACKUP
46
 
#include "sync0sync.h"
47
 
#include "os0sync.h"
48
 
#include "que0types.h"
49
 
#include "trx0types.h"
50
 
 
51
 
#include <string>
52
 
 
53
 
extern const char*      srv_main_thread_op_info;
54
 
 
55
 
/** Prefix used by MySQL to indicate pre-5.1 table name encoding */
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#");
60
 
 
61
 
/* When this event is set the lock timeout and InnoDB monitor
62
 
thread starts running */
63
 
extern os_event_t       srv_lock_timeout_thread_event;
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
 
 
74
 
/* If the last data file is auto-extended, we add this many pages to it
75
 
at a time */
76
 
#define SRV_AUTO_EXTEND_INCREMENT       \
77
 
        (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
78
 
 
79
 
/* This is set to TRUE if the MySQL user has set it in MySQL */
80
 
extern ibool    srv_lower_case_table_names;
81
 
 
82
 
/* Mutex for locking srv_monitor_file */
83
 
extern mutex_t  srv_monitor_file_mutex;
84
 
/* Temporary file for innodb monitor output */
85
 
extern FILE*    srv_monitor_file;
86
 
/* Mutex for locking srv_dict_tmpfile.
87
 
This mutex has a very high rank; threads reserving it should not
88
 
be holding any InnoDB latches. */
89
 
extern mutex_t  srv_dict_tmpfile_mutex;
90
 
/* Temporary file for output from the data dictionary */
91
 
extern FILE*    srv_dict_tmpfile;
92
 
/* Mutex for locking srv_misc_tmpfile.
93
 
This mutex has a very low rank; threads reserving it should not
94
 
acquire any further latches or sleep before releasing this one. */
95
 
extern mutex_t  srv_misc_tmpfile_mutex;
96
 
/* Temporary file for miscellanous diagnostic output */
97
 
extern FILE*    srv_misc_tmpfile;
98
 
 
99
 
/* Server parameters which are read from the initfile */
100
 
 
101
 
extern char*    srv_data_home;
102
 
#ifdef UNIV_LOG_ARCHIVE
103
 
extern char*    srv_arch_dir;
104
 
#endif /* UNIV_LOG_ARCHIVE */
105
 
 
106
 
/** store to its own file each table created by an user; data
107
 
dictionary tables are in the system tablespace 0 */
108
 
#ifndef UNIV_HOTBACKUP
109
 
extern my_bool  srv_file_per_table;
110
 
#else
111
 
extern ibool    srv_file_per_table;
112
 
#endif /* UNIV_HOTBACKUP */
113
 
/** The file format to use on new *.ibd files. */
114
 
extern ulint    srv_file_format;
115
 
/** Whether to check file format during startup.  A value of
116
 
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE.  The default is to
117
 
set it to the highest format we support. */
118
 
extern ulint    srv_max_file_format_at_startup;
119
 
/** Place locks to records only i.e. do not use next-key locking except
120
 
on duplicate key checking and foreign key checking */
121
 
extern ibool    srv_locks_unsafe_for_binlog;
122
 
#endif /* !UNIV_HOTBACKUP */
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
132
 
extern ulint    srv_n_data_files;
133
 
extern char**   srv_data_file_names;
134
 
extern ulint*   srv_data_file_sizes;
135
 
extern ulint*   srv_data_file_is_raw_partition;
136
 
 
137
 
extern ibool    srv_auto_extend_last_data_file;
138
 
extern ulint    srv_last_file_size_max;
139
 
extern char**   srv_log_group_home_dirs;
140
 
#ifndef UNIV_HOTBACKUP
141
 
extern unsigned int srv_auto_extend_increment;
142
 
 
143
 
extern ibool    srv_created_new_raw;
144
 
 
145
 
extern ulint    srv_n_log_groups;
146
 
extern ulint    srv_n_log_files;
147
 
extern ulint    srv_log_file_size;
148
 
extern ulint    srv_log_buffer_size;
149
 
extern ulong    srv_flush_log_at_trx_commit;
150
 
extern bool     srv_adaptive_flushing;
151
 
 
152
 
 
153
 
/* The sort order table of the MySQL latin1_swedish_ci character set
154
 
collation */
155
 
#if defined(BUILD_DRIZZLE)
156
 
extern const byte  srv_latin1_ordering[256];
157
 
extern bool     srv_use_sys_malloc;
158
 
#else
159
 
extern const byte*     srv_latin1_ordering;
160
 
# ifndef UNIV_HOTBACKUP
161
 
extern my_bool srv_use_sys_malloc;
162
 
# else
163
 
extern ibool   srv_use_sys_malloc;
164
 
# endif /* UNIV_HOTBACKUP */
165
 
#endif /* BUILD_DRIZZLE */
166
 
extern ulint    srv_buf_pool_size;      /*!< requested size in bytes */
167
 
extern ulint    srv_buf_pool_instances; /*!< requested number of buffer pool instances */
168
 
extern ulint    srv_buf_pool_old_size;  /*!< previously requested size */
169
 
extern ulint    srv_buf_pool_curr_size; /*!< current size in bytes */
170
 
extern ulint    srv_mem_pool_size;
171
 
extern ulint    srv_lock_table_size;
172
 
 
173
 
extern ulint    srv_n_file_io_threads;
174
 
extern ulong    srv_read_ahead_threshold;
175
 
extern ulint    srv_n_read_io_threads;
176
 
extern ulint    srv_n_write_io_threads;
177
 
 
178
 
/* Number of IO operations per second the server can do */
179
 
extern ulong    srv_io_capacity;
180
 
/* Returns the number of IO operations that is X percent of the
181
 
capacity. PCT_IO(5) -> returns the number of IO operations that
182
 
is 5% of the max where max is srv_io_capacity.  */
183
 
#define PCT_IO(p) ((ulong) (srv_io_capacity * ((double) p / 100.0)))
184
 
 
185
 
#ifdef UNIV_LOG_ARCHIVE
186
 
extern ibool            srv_log_archive_on;
187
 
extern ibool            srv_archive_recovery;
188
 
extern ib_uint64_t      srv_archive_recovery_limit_lsn;
189
 
#endif /* UNIV_LOG_ARCHIVE */
190
 
 
191
 
extern char*    srv_file_flush_method_str;
192
 
extern ulint    srv_unix_file_flush_method;
193
 
extern ulint    srv_win_file_flush_method;
194
 
 
195
 
extern ulint    srv_max_n_open_files;
196
 
 
197
 
extern ulint    srv_max_dirty_pages_pct;
198
 
 
199
 
extern ulint    srv_force_recovery;
200
 
extern ulong    srv_thread_concurrency;
201
 
 
202
 
extern ulint    srv_max_n_threads;
203
 
 
204
 
extern lint     srv_conc_n_threads;
205
 
 
206
 
extern ulint    srv_fast_shutdown;       /* If this is 1, do not do a
207
 
                                         purge and index buffer merge.
208
 
                                         If this 2, do not even flush the
209
 
                                         buffer pool to data files at the
210
 
                                         shutdown: we effectively 'crash'
211
 
                                         InnoDB (but lose no committed
212
 
                                         transactions). */
213
 
extern ibool    srv_innodb_status;
214
 
 
215
 
extern ib_uint64_t      srv_stats_sample_pages;
216
 
 
217
 
extern ibool    srv_use_doublewrite_buf;
218
 
extern ibool    srv_use_checksums;
219
 
 
220
 
extern ulong    srv_max_buf_pool_modified_pct;
221
 
extern ulong    srv_max_purge_lag;
222
 
 
223
 
extern ulong    srv_replication_delay;
224
 
/*-------------------------------------------*/
225
 
 
226
 
extern ulint    srv_n_rows_inserted;
227
 
extern ulint    srv_n_rows_updated;
228
 
extern ulint    srv_n_rows_deleted;
229
 
extern ulint    srv_n_rows_read;
230
 
 
231
 
extern ibool    srv_print_innodb_monitor;
232
 
extern ibool    srv_print_innodb_lock_monitor;
233
 
extern ibool    srv_print_innodb_tablespace_monitor;
234
 
extern ibool    srv_print_verbose_log;
235
 
extern ibool    srv_print_innodb_table_monitor;
236
 
 
237
 
extern ibool    srv_lock_timeout_active;
238
 
extern ibool    srv_monitor_active;
239
 
extern ibool    srv_error_monitor_active;
240
 
 
241
 
extern ulong    srv_n_spin_wait_rounds;
242
 
extern ulong    srv_n_free_tickets_to_enter;
243
 
extern ulong    srv_thread_sleep_delay;
244
 
extern ulong    srv_spin_wait_delay;
245
 
extern ibool    srv_priority_boost;
246
 
 
247
 
extern ulint    srv_truncated_status_writes;
248
 
 
249
 
#ifdef UNIV_DEBUG
250
 
extern  ibool   srv_print_thread_releases;
251
 
extern  ibool   srv_print_lock_waits;
252
 
extern  ibool   srv_print_buf_io;
253
 
extern  ibool   srv_print_log_io;
254
 
extern  ibool   srv_print_latch_waits;
255
 
#else /* UNIV_DEBUG */
256
 
# define srv_print_thread_releases      FALSE
257
 
# define srv_print_lock_waits           FALSE
258
 
# define srv_print_buf_io               FALSE
259
 
# define srv_print_log_io               FALSE
260
 
# define srv_print_latch_waits          FALSE
261
 
#endif /* UNIV_DEBUG */
262
 
 
263
 
extern ulint    srv_activity_count;
264
 
extern ulint    srv_fatal_semaphore_wait_threshold;
265
 
extern ulint    srv_dml_needed_delay;
266
 
 
267
 
extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs,
268
 
                                query threads, and lock table: we allocate
269
 
                                it from dynamic memory to get it to the
270
 
                                same DRAM page as other hotspot semaphores */
271
 
extern mutex_t* commit_id_mutex_temp;
272
 
 
273
 
#define kernel_mutex (*kernel_mutex_temp)
274
 
#define commit_id_mutex (*commit_id_mutex_temp)
275
 
 
276
 
#define SRV_MAX_N_IO_THREADS    130
277
 
 
278
 
/* Array of English strings describing the current state of an
279
 
i/o handler thread */
280
 
extern const char* srv_io_thread_op_info[];
281
 
extern const char* srv_io_thread_function[];
282
 
 
283
 
/* the number of the log write requests done */
284
 
extern ulint srv_log_write_requests;
285
 
 
286
 
/* the number of physical writes to the log performed */
287
 
extern ulint srv_log_writes;
288
 
 
289
 
/* amount of data written to the log files in bytes */
290
 
extern ulint srv_os_log_written;
291
 
 
292
 
/* amount of writes being done to the log files */
293
 
extern ulint srv_os_log_pending_writes;
294
 
 
295
 
/* we increase this counter, when there we don't have enough space in the
296
 
log buffer and have to flush it */
297
 
extern ulint srv_log_waits;
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
 
 
305
 
/* variable that counts amount of data read in total (in bytes) */
306
 
extern ulint srv_data_read;
307
 
 
308
 
/* here we count the amount of data written in total (in bytes) */
309
 
extern ulint srv_data_written;
310
 
 
311
 
/* this variable counts the amount of times, when the doublewrite buffer
312
 
was flushed */
313
 
extern ulint srv_dblwr_writes;
314
 
 
315
 
/* here we store the number of pages that have been flushed to the
316
 
doublewrite buffer */
317
 
extern ulint srv_dblwr_pages_written;
318
 
 
319
 
/* in this variable we store the number of write requests issued */
320
 
extern ulint srv_buf_pool_write_requests;
321
 
 
322
 
/* here we store the number of times when we had to wait for a free page
323
 
in the buffer pool. It happens when the buffer pool is full and we need
324
 
to make a flush, in order to be able to read or create a page. */
325
 
extern ulint srv_buf_pool_wait_free;
326
 
 
327
 
/* variable to count the number of pages that were written from the
328
 
buffer pool to disk */
329
 
extern ulint srv_buf_pool_flushed;
330
 
 
331
 
/** Number of buffer pool reads that led to the
332
 
reading of a disk page */
333
 
extern ulint srv_buf_pool_reads;
334
 
 
335
 
/** Status variables to be passed to MySQL */
336
 
typedef struct export_var_struct export_struc;
337
 
 
338
 
/** Status variables to be passed to MySQL */
339
 
extern export_struc export_vars;
340
 
 
341
 
/** The server system */
342
 
typedef struct srv_sys_struct   srv_sys_t;
343
 
 
344
 
/** The server system */
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
 
 
377
 
#endif /* !UNIV_HOTBACKUP */
378
 
 
379
 
/** Types of raw partitions in innodb_data_file_path */
380
 
enum {
381
 
        SRV_NOT_RAW = 0,        /*!< Not a raw partition */
382
 
        SRV_NEW_RAW,            /*!< A 'newraw' partition, only to be
383
 
                                initialized */
384
 
        SRV_OLD_RAW             /*!< An initialized raw partition */
385
 
};
386
 
 
387
 
/** Alternatives for the file flush option in Unix; see the InnoDB manual
388
 
about what these mean */
389
 
enum {
390
 
        SRV_UNIX_FSYNC = 1,     /*!< fsync, the default */
391
 
        SRV_UNIX_O_DSYNC,       /*!< open log files in O_SYNC mode */
392
 
        SRV_UNIX_LITTLESYNC,    /*!< do not call os_file_flush()
393
 
                                when writing data files, but do flush
394
 
                                after writing to log files */
395
 
        SRV_UNIX_NOSYNC,        /*!< do not flush after writing */
396
 
        SRV_UNIX_O_DIRECT       /*!< invoke os_file_set_nocache() on
397
 
                                data files */
398
 
};
399
 
 
400
 
/** Alternatives for file i/o in Windows */
401
 
enum {
402
 
        SRV_WIN_IO_NORMAL = 1,  /*!< buffered I/O */
403
 
        SRV_WIN_IO_UNBUFFERED   /*!< unbuffered I/O; this is the default */
404
 
};
405
 
 
406
 
/** Alternatives for srv_force_recovery. Non-zero values are intended
407
 
to help the user get a damaged database up so that he can dump intact
408
 
tables and rows with SELECT INTO OUTFILE. The database must not otherwise
409
 
be used with these options! A bigger number below means that all precautions
410
 
of lower numbers are included. */
411
 
enum {
412
 
        SRV_FORCE_IGNORE_CORRUPT = 1,   /*!< let the server run even if it
413
 
                                        detects a corrupt page */
414
 
        SRV_FORCE_NO_BACKGROUND = 2,    /*!< prevent the main thread from
415
 
                                        running: if a crash would occur
416
 
                                        in purge, this prevents it */
417
 
        SRV_FORCE_NO_TRX_UNDO = 3,      /*!< do not run trx rollback after
418
 
                                        recovery */
419
 
        SRV_FORCE_NO_IBUF_MERGE = 4,    /*!< prevent also ibuf operations:
420
 
                                        if they would cause a crash, better
421
 
                                        not do them */
422
 
        SRV_FORCE_NO_UNDO_LOG_SCAN = 5, /*!< do not look at undo logs when
423
 
                                        starting the database: InnoDB will
424
 
                                        treat even incomplete transactions
425
 
                                        as committed */
426
 
        SRV_FORCE_NO_LOG_REDO = 6       /*!< do not do the log roll-forward
427
 
                                        in connection with recovery */
428
 
};
429
 
 
430
 
#ifndef UNIV_HOTBACKUP
431
 
/** Types of threads existing in the system. */
432
 
enum srv_thread_type {
433
 
        SRV_COM = 1,    /**< threads serving communication and queries */
434
 
        SRV_CONSOLE,    /**< thread serving console */
435
 
        SRV_WORKER,     /**< threads serving parallelized queries and
436
 
                        queries released from lock wait */
437
 
#if 0
438
 
        /* Utility threads */
439
 
        SRV_BUFFER,     /**< thread flushing dirty buffer blocks */
440
 
        SRV_RECOVERY,   /**< threads finishing a recovery */
441
 
        SRV_INSERT,     /**< thread flushing the insert buffer to disk */
442
 
#endif
443
 
        SRV_MASTER      /**< the master thread, (whose type number must
444
 
                        be biggest) */
445
 
};
446
 
 
447
 
/*********************************************************************//**
448
 
Boots Innobase server.
449
 
@return DB_SUCCESS or error code */
450
 
UNIV_INTERN
451
 
ulint
452
 
srv_boot(void);
453
 
/*==========*/
454
 
/*********************************************************************//**
455
 
Initializes the server. */
456
 
UNIV_INTERN
457
 
void
458
 
srv_init(void);
459
 
/*==========*/
460
 
/*********************************************************************//**
461
 
Frees the data structures created in srv_init(). */
462
 
UNIV_INTERN
463
 
void
464
 
srv_free(void);
465
 
/*==========*/
466
 
/*********************************************************************//**
467
 
Initializes the synchronization primitives, memory system, and the thread
468
 
local storage. */
469
 
UNIV_INTERN
470
 
void
471
 
srv_general_init(void);
472
 
/*==================*/
473
 
/*********************************************************************//**
474
 
Gets the number of threads in the system.
475
 
@return sum of srv_n_threads[] */
476
 
UNIV_INTERN
477
 
ulint
478
 
srv_get_n_threads(void);
479
 
/*===================*/
480
 
/*********************************************************************//**
481
 
Returns the calling thread type.
482
 
@return SRV_COM, ... */
483
 
 
484
 
enum srv_thread_type
485
 
srv_get_thread_type(void);
486
 
/*=====================*/
487
 
/*********************************************************************//**
488
 
Sets the info describing an i/o thread current state. */
489
 
UNIV_INTERN
490
 
void
491
 
srv_set_io_thread_op_info(
492
 
/*======================*/
493
 
        ulint           i,      /*!< in: the 'segment' of the i/o thread */
494
 
        const char*     str);   /*!< in: constant char string describing the
495
 
                                state */
496
 
/*********************************************************************//**
497
 
Releases threads of the type given from suspension in the thread table.
498
 
NOTE! The server mutex has to be reserved by the caller!
499
 
@return number of threads released: this may be less than n if not
500
 
enough threads were suspended at the moment */
501
 
UNIV_INTERN
502
 
ulint
503
 
srv_release_threads(
504
 
/*================*/
505
 
        enum srv_thread_type    type,   /*!< in: thread type */
506
 
        ulint                   n);     /*!< in: number of threads to release */
507
 
/*********************************************************************//**
508
 
The master thread controlling the server.
509
 
@return a dummy parameter */
510
 
UNIV_INTERN
511
 
os_thread_ret_t
512
 
srv_master_thread(
513
 
/*==============*/
514
 
        void*   arg);   /*!< in: a dummy parameter required by
515
 
                        os_thread_create */
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
 
/*******************************************************************//**
523
 
Tells the Innobase server that there has been activity in the database
524
 
and wakes up the master thread if it is suspended (not sleeping). Used
525
 
in the MySQL interface. Note that there is a small chance that the master
526
 
thread stays suspended (we do not protect our operation with the kernel
527
 
mutex, for performace reasons). */
528
 
UNIV_INTERN
529
 
void
530
 
srv_active_wake_master_thread(void);
531
 
/*===============================*/
532
 
/*******************************************************************//**
533
 
Wakes up the master thread if it is suspended or being suspended. */
534
 
UNIV_INTERN
535
 
void
536
 
srv_wake_master_thread(void);
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
 
/*=====================================*/
548
 
/*********************************************************************//**
549
 
Puts an OS thread to wait if there are too many concurrent threads
550
 
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
551
 
UNIV_INTERN
552
 
void
553
 
srv_conc_enter_innodb(
554
 
/*==================*/
555
 
        trx_t*  trx);   /*!< in: transaction object associated with the
556
 
                        thread */
557
 
/*********************************************************************//**
558
 
This lets a thread enter InnoDB regardless of the number of threads inside
559
 
InnoDB. This must be called when a thread ends a lock wait. */
560
 
UNIV_INTERN
561
 
void
562
 
srv_conc_force_enter_innodb(
563
 
/*========================*/
564
 
        trx_t*  trx);   /*!< in: transaction object associated with the
565
 
                        thread */
566
 
/*********************************************************************//**
567
 
This must be called when a thread exits InnoDB in a lock wait or at the
568
 
end of an SQL statement. */
569
 
UNIV_INTERN
570
 
void
571
 
srv_conc_force_exit_innodb(
572
 
/*=======================*/
573
 
        trx_t*  trx);   /*!< in: transaction object associated with the
574
 
                        thread */
575
 
/*********************************************************************//**
576
 
This must be called when a thread exits InnoDB. */
577
 
UNIV_INTERN
578
 
void
579
 
srv_conc_exit_innodb(
580
 
/*=================*/
581
 
        trx_t*  trx);   /*!< in: transaction object associated with the
582
 
                        thread */
583
 
/***************************************************************//**
584
 
Puts a MySQL OS thread to wait for a lock to be released. If an error
585
 
occurs during the wait trx->error_state associated with thr is
586
 
!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
587
 
are possible errors. DB_DEADLOCK is returned if selective deadlock
588
 
resolution chose this transaction as a victim. */
589
 
UNIV_INTERN
590
 
void
591
 
srv_suspend_mysql_thread(
592
 
/*=====================*/
593
 
        que_thr_t*      thr);   /*!< in: query thread associated with the MySQL
594
 
                                OS thread */
595
 
/********************************************************************//**
596
 
Releases a MySQL OS thread waiting for a lock to be released, if the
597
 
thread is already suspended. */
598
 
UNIV_INTERN
599
 
void
600
 
srv_release_mysql_thread_if_suspended(
601
 
/*==================================*/
602
 
        que_thr_t*      thr);   /*!< in: query thread associated with the
603
 
                                MySQL OS thread  */
604
 
/*********************************************************************//**
605
 
A thread which wakes up threads whose lock wait may have lasted too long.
606
 
@return a dummy parameter */
607
 
UNIV_INTERN
608
 
os_thread_ret_t
609
 
srv_lock_timeout_thread(
610
 
/*====================*/
611
 
        void*   arg);   /*!< in: a dummy parameter required by
612
 
                        os_thread_create */
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
 
/*************************************************************************
623
 
A thread which prints warnings about semaphore waits which have lasted
624
 
too long. These can be used to track bugs which cause hangs.
625
 
@return a dummy parameter */
626
 
UNIV_INTERN
627
 
os_thread_ret_t
628
 
srv_error_monitor_thread(
629
 
/*=====================*/
630
 
        void*   arg);   /*!< in: a dummy parameter required by
631
 
                        os_thread_create */
632
 
/******************************************************************//**
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 */
636
 
UNIV_INTERN
637
 
ibool
638
 
srv_printf_innodb_monitor(
639
 
/*======================*/
640
 
        FILE*   file,           /*!< in: output stream */
641
 
        ibool   nowait,         /*!< in: whether to wait for kernel mutex */
642
 
        ulint*  trx_start,      /*!< out: file position of the start of
643
 
                                the list of active transactions */
644
 
        ulint*  trx_end);       /*!< out: file position of the end of
645
 
                                the list of active transactions */
646
 
 
647
 
/******************************************************************//**
648
 
Function to pass InnoDB status variables to MySQL */
649
 
UNIV_INTERN
650
 
void
651
 
srv_export_innodb_status(void);
652
 
/*==========================*/
653
 
 
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
 
/*======================================*/
687
 
 
688
 
/** Status variables to be passed to MySQL */
689
 
struct export_var_struct{
690
 
        ulint innodb_data_pending_reads;        /*!< Pending reads */
691
 
        ulint innodb_data_pending_writes;       /*!< Pending writes */
692
 
        ulint innodb_data_pending_fsyncs;       /*!< Pending fsyncs */
693
 
        ulint innodb_data_fsyncs;               /*!< Number of fsyncs so far */
694
 
        ulint innodb_data_read;                 /*!< Data bytes read */
695
 
        ulint innodb_data_writes;               /*!< I/O write requests */
696
 
        ulint innodb_data_written;              /*!< Data bytes written */
697
 
        ulint innodb_data_reads;                /*!< I/O read requests */
698
 
        ulint innodb_buffer_pool_pages_total;   /*!< Buffer pool size */
699
 
        ulint innodb_buffer_pool_pages_data;    /*!< Data pages */
700
 
        ulint innodb_buffer_pool_pages_dirty;   /*!< Dirty data pages */
701
 
        ulint innodb_buffer_pool_pages_misc;    /*!< Miscellanous pages */
702
 
        ulint innodb_buffer_pool_pages_free;    /*!< Free pages */
703
 
#ifdef UNIV_DEBUG
704
 
        ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */
705
 
#endif /* UNIV_DEBUG */
706
 
        ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */
707
 
        ulint innodb_buffer_pool_reads;         /*!< srv_buf_pool_reads */
708
 
        ulint innodb_buffer_pool_wait_free;     /*!< srv_buf_pool_wait_free */
709
 
        ulint innodb_buffer_pool_pages_flushed; /*!< srv_buf_pool_flushed */
710
 
        ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
711
 
        ulint innodb_buffer_pool_read_ahead;    /*!< srv_read_ahead */
712
 
        ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
713
 
        ulint innodb_dblwr_pages_written;       /*!< srv_dblwr_pages_written */
714
 
        ulint innodb_dblwr_writes;              /*!< srv_dblwr_writes */
715
 
        ibool innodb_have_atomic_builtins;      /*!< HAVE_ATOMIC_BUILTINS */
716
 
        ulint innodb_log_waits;                 /*!< srv_log_waits */
717
 
        ulint innodb_log_write_requests;        /*!< srv_log_write_requests */
718
 
        ulint innodb_log_writes;                /*!< srv_log_writes */
719
 
        ulint innodb_os_log_written;            /*!< srv_os_log_written */
720
 
        ulint innodb_os_log_fsyncs;             /*!< fil_n_log_flushes */
721
 
        ulint innodb_os_log_pending_writes;     /*!< srv_os_log_pending_writes */
722
 
        ulint innodb_os_log_pending_fsyncs;     /*!< fil_n_pending_log_flushes */
723
 
        ulint innodb_page_size;                 /*!< UNIV_PAGE_SIZE */
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 */
727
 
        ulint innodb_row_lock_waits;            /*!< srv_n_lock_wait_count */
728
 
        ulint innodb_row_lock_current_waits;    /*!< srv_n_lock_wait_current_count */
729
 
        ib_int64_t innodb_row_lock_time;        /*!< srv_n_lock_wait_time
730
 
                                                / 1000 */
731
 
        ulint innodb_row_lock_time_avg;         /*!< srv_n_lock_wait_time
732
 
                                                / 1000
733
 
                                                / srv_n_lock_wait_count */
734
 
        ulint innodb_row_lock_time_max;         /*!< srv_n_lock_max_wait_time
735
 
                                                / 1000 */
736
 
        ulint innodb_rows_read;                 /*!< srv_n_rows_read */
737
 
        ulint innodb_rows_inserted;             /*!< srv_n_rows_inserted */
738
 
        ulint innodb_rows_updated;              /*!< srv_n_rows_updated */
739
 
        ulint innodb_rows_deleted;              /*!< srv_n_rows_deleted */
740
 
        ulint innodb_truncated_status_writes;   /*!< srv_truncated_status_writes */
741
 
};
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
 
 
749
 
/** The server system struct */
750
 
struct srv_sys_struct{
751
 
        srv_table_t*    threads;        /*!< server thread table */
752
 
        UT_LIST_BASE_NODE_T(que_thr_t)
753
 
                        tasks;          /*!< task queue */
754
 
};
755
 
 
756
 
extern ulint    srv_n_threads_active[];
757
 
#else /* !UNIV_HOTBACKUP */
758
 
# define srv_use_adaptive_hash_indexes          FALSE
759
 
# define srv_use_checksums                      TRUE
760
 
# define srv_use_native_aio                     FALSE
761
 
# define srv_force_recovery                     0UL
762
 
# define srv_set_io_thread_op_info(t,info)      ((void) 0)
763
 
# define srv_is_being_started                   0
764
 
# define srv_win_file_flush_method              SRV_WIN_IO_UNBUFFERED
765
 
# define srv_unix_file_flush_method             SRV_UNIX_O_DSYNC
766
 
# define srv_start_raw_disk_in_use              0
767
 
# define srv_file_per_table                     1
768
 
#endif /* !UNIV_HOTBACKUP */
769
 
 
770
 
 
771
 
#endif