~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

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