~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to .pc/debian-changes-2010.12.06-0ubuntu4/plugin/innobase/include/srv0srv.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2011-01-04 09:31:58 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110104093158-smhgvkfdi2y9au3i
Tags: 2011.01.07-0ubuntu1
New upstream release.

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