~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Lee
  • Date: 2009-01-01 17:36:53 UTC
  • mto: (758.1.3 devel)
  • mto: This revision was merged to the branch mainline in revision 759.
  • Revision ID: lbieber@lbieber-desktop-20090101173653-qo5945pnje5j3vuu
more header file cleanup

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
 
1
/******************************************************
36
2
The server main program
37
3
 
 
4
(c) 1995 Innobase Oy
 
5
 
38
6
Created 10/10/1995 Heikki Tuuri
39
7
*******************************************************/
40
8
 
 
9
 
41
10
#ifndef srv0srv_h
42
11
#define srv0srv_h
43
12
 
44
13
#include "univ.i"
45
 
#ifndef UNIV_HOTBACKUP
46
14
#include "sync0sync.h"
47
15
#include "os0sync.h"
48
16
#include "que0types.h"
50
18
 
51
19
extern const char*      srv_main_thread_op_info;
52
20
 
53
 
/** Prefix used by MySQL to indicate pre-5.1 table name encoding */
 
21
/* Prefix used by MySQL to indicate pre-5.1 table name encoding */
54
22
extern const char       srv_mysql50_table_name_prefix[9];
55
23
 
56
24
/* When this event is set the lock timeout and InnoDB monitor
89
57
extern char*    srv_arch_dir;
90
58
#endif /* UNIV_LOG_ARCHIVE */
91
59
 
92
 
/** store to its own file each table created by an user; data
 
60
/* store to its own file each table created by an user; data
93
61
dictionary tables are in the system tablespace 0 */
94
 
#ifndef UNIV_HOTBACKUP
95
62
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. */
 
63
/* The file format to use on new *.ibd files. */
100
64
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
 
65
/* Whether to check file format during startup.*/
 
66
extern ulint    srv_check_file_format_at_startup;
 
67
/* Place locks to records only i.e. do not use next-key locking except
106
68
on duplicate key checking and foreign key checking */
107
69
extern ibool    srv_locks_unsafe_for_binlog;
108
 
#endif /* !UNIV_HOTBACKUP */
109
70
 
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
71
extern ulint    srv_n_data_files;
119
72
extern char**   srv_data_file_names;
120
73
extern ulint*   srv_data_file_sizes;
122
75
 
123
76
extern ibool    srv_auto_extend_last_data_file;
124
77
extern ulint    srv_last_file_size_max;
 
78
extern ulong    srv_auto_extend_increment;
 
79
 
 
80
extern ibool    srv_created_new_raw;
 
81
 
 
82
#define SRV_NEW_RAW     1
 
83
#define SRV_OLD_RAW     2
 
84
 
125
85
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
86
 
131
87
extern ulint    srv_n_log_groups;
132
88
extern ulint    srv_n_log_files;
133
89
extern ulint    srv_log_file_size;
134
90
extern ulint    srv_log_buffer_size;
135
91
extern ulong    srv_flush_log_at_trx_commit;
136
 
extern bool     srv_adaptive_flushing;
137
 
 
138
92
 
139
93
/* The sort order table of the MySQL latin1_swedish_ci character set
140
94
collation */
141
 
#if defined(BUILD_DRIZZLE)
142
95
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 */
 
96
extern ulong    srv_buf_pool_size;      /* requested size in bytes */
 
97
extern ulong    srv_buf_pool_old_size;  /* previously requested size */
 
98
extern ulong    srv_buf_pool_curr_size; /* current size in bytes */
156
99
extern ulint    srv_mem_pool_size;
157
100
extern ulint    srv_lock_table_size;
158
101
 
159
102
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
103
 
171
104
#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;
 
105
extern ibool    srv_log_archive_on;
 
106
extern ibool    srv_archive_recovery;
 
107
extern dulint   srv_archive_recovery_limit_lsn;
175
108
#endif /* UNIV_LOG_ARCHIVE */
176
109
 
177
110
extern char*    srv_file_flush_method_str;
184
117
 
185
118
extern ulint    srv_force_recovery;
186
119
extern ulong    srv_thread_concurrency;
 
120
extern ulong    srv_commit_concurrency;
187
121
 
188
122
extern ulint    srv_max_n_threads;
189
123
 
203
137
extern ibool    srv_use_doublewrite_buf;
204
138
extern ibool    srv_use_checksums;
205
139
 
 
140
extern ibool    srv_set_thread_priorities;
 
141
extern int      srv_query_thread_priority;
 
142
 
206
143
extern ulong    srv_max_buf_pool_modified_pct;
207
144
extern ulong    srv_max_purge_lag;
208
145
 
220
157
extern ibool    srv_print_verbose_log;
221
158
extern ibool    srv_print_innodb_table_monitor;
222
159
 
223
 
extern ibool    srv_lock_timeout_active;
224
 
extern ibool    srv_monitor_active;
 
160
extern ibool    srv_lock_timeout_and_monitor_active;
225
161
extern ibool    srv_error_monitor_active;
226
162
 
227
163
extern ulong    srv_n_spin_wait_rounds;
228
164
extern ulong    srv_n_free_tickets_to_enter;
229
165
extern ulong    srv_thread_sleep_delay;
230
 
extern ulong    srv_spin_wait_delay;
 
166
extern ulint    srv_spin_wait_delay;
231
167
extern ibool    srv_priority_boost;
232
168
 
233
 
extern ulint    srv_truncated_status_writes;
234
169
 
235
170
#ifdef UNIV_DEBUG
236
171
extern  ibool   srv_print_thread_releases;
256
191
                                same DRAM page as other hotspot semaphores */
257
192
#define kernel_mutex (*kernel_mutex_temp)
258
193
 
259
 
#define SRV_MAX_N_IO_THREADS    130
 
194
#define SRV_MAX_N_IO_THREADS    100
260
195
 
261
196
/* Array of English strings describing the current state of an
262
197
i/o handler thread */
279
214
log buffer and have to flush it */
280
215
extern ulint srv_log_waits;
281
216
 
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
217
/* variable that counts amount of data read in total (in bytes) */
289
218
extern ulint srv_data_read;
290
219
 
311
240
buffer pool to disk */
312
241
extern ulint srv_buf_pool_flushed;
313
242
 
314
 
/** Number of buffer pool reads that led to the
 
243
/* variable to count the number of buffer pool reads that led to the
315
244
reading of a disk page */
316
245
extern ulint srv_buf_pool_reads;
317
246
 
318
 
/** Status variables to be passed to MySQL */
 
247
/* variable to count the number of sequential read-aheads were done */
 
248
extern ulint srv_read_ahead_seq;
 
249
 
 
250
/* variable to count the number of random read-aheads were done */
 
251
extern ulint srv_read_ahead_rnd;
 
252
 
 
253
/* In this structure we store status variables to be passed to MySQL */
319
254
typedef struct export_var_struct export_struc;
320
255
 
321
 
/** Status variables to be passed to MySQL */
322
256
extern export_struc export_vars;
323
257
 
324
 
/** The server system */
325
258
typedef struct srv_sys_struct   srv_sys_t;
326
259
 
327
 
/** The server system */
 
260
/* The server system */
328
261
extern srv_sys_t*       srv_sys;
329
262
 
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
 
263
/* Alternatives for the file flush option in Unix; see the InnoDB manual
371
264
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
 
265
#define SRV_UNIX_FSYNC          1       /* This is the default */
 
266
#define SRV_UNIX_O_DSYNC        2
 
267
#define SRV_UNIX_LITTLESYNC     3
 
268
#define SRV_UNIX_NOSYNC         4
 
269
#define SRV_UNIX_O_DIRECT       5
 
270
 
 
271
/* Alternatives for file i/o in Windows */
 
272
#define SRV_WIN_IO_NORMAL               1
 
273
#define SRV_WIN_IO_UNBUFFERED           2       /* This is the default */
 
274
 
 
275
/* Alternatives for srv_force_recovery. Non-zero values are intended
390
276
to help the user get a damaged database up so that he can dump intact
391
277
tables and rows with SELECT INTO OUTFILE. The database must not otherwise
392
278
be used with these options! A bigger number below means that all precautions
393
279
of lower numbers are included. */
394
 
enum {
395
 
        SRV_FORCE_IGNORE_CORRUPT = 1,   /*!< let the server run even if it
 
280
 
 
281
#define SRV_FORCE_IGNORE_CORRUPT 1      /* let the server run even if it
396
282
                                        detects a corrupt page */
397
 
        SRV_FORCE_NO_BACKGROUND = 2,    /*!< prevent the main thread from
 
283
#define SRV_FORCE_NO_BACKGROUND 2       /* prevent the main thread from
398
284
                                        running: if a crash would occur
399
285
                                        in purge, this prevents it */
400
 
        SRV_FORCE_NO_TRX_UNDO = 3,      /*!< do not run trx rollback after
 
286
#define SRV_FORCE_NO_TRX_UNDO   3       /* do not run trx rollback after
401
287
                                        recovery */
402
 
        SRV_FORCE_NO_IBUF_MERGE = 4,    /*!< prevent also ibuf operations:
 
288
#define SRV_FORCE_NO_IBUF_MERGE 4       /* prevent also ibuf operations:
403
289
                                        if they would cause a crash, better
404
290
                                        not do them */
405
 
        SRV_FORCE_NO_UNDO_LOG_SCAN = 5, /*!< do not look at undo logs when
 
291
#define SRV_FORCE_NO_UNDO_LOG_SCAN 5    /* do not look at undo logs when
406
292
                                        starting the database: InnoDB will
407
293
                                        treat even incomplete transactions
408
294
                                        as committed */
409
 
        SRV_FORCE_NO_LOG_REDO = 6       /*!< do not do the log roll-forward
 
295
#define SRV_FORCE_NO_LOG_REDO   6       /* do not do the log roll-forward
410
296
                                        in connection with recovery */
411
 
};
412
297
 
413
 
#ifndef UNIV_HOTBACKUP
414
298
/** Types of threads existing in the system. */
415
299
enum srv_thread_type {
416
300
        SRV_COM = 1,    /**< threads serving communication and queries */
427
311
                        be biggest) */
428
312
};
429
313
 
430
 
/*********************************************************************//**
431
 
Boots Innobase server.
432
 
@return DB_SUCCESS or error code */
 
314
/*************************************************************************
 
315
Boots Innobase server. */
433
316
UNIV_INTERN
434
317
ulint
435
318
srv_boot(void);
436
319
/*==========*/
437
 
/*********************************************************************//**
 
320
                        /* out: DB_SUCCESS or error code */
 
321
/*************************************************************************
438
322
Initializes the server. */
439
323
UNIV_INTERN
440
324
void
441
325
srv_init(void);
442
326
/*==========*/
443
 
/*********************************************************************//**
444
 
Frees the data structures created in srv_init(). */
 
327
/*************************************************************************
 
328
Frees the OS fast mutex created in srv_boot(). */
445
329
UNIV_INTERN
446
330
void
447
331
srv_free(void);
448
332
/*==========*/
449
 
/*********************************************************************//**
 
333
/*************************************************************************
450
334
Initializes the synchronization primitives, memory system, and the thread
451
335
local storage. */
452
336
UNIV_INTERN
453
337
void
454
338
srv_general_init(void);
455
339
/*==================*/
456
 
/*********************************************************************//**
457
 
Gets the number of threads in the system.
458
 
@return sum of srv_n_threads[] */
 
340
/*************************************************************************
 
341
Gets the number of threads in the system. */
459
342
UNIV_INTERN
460
343
ulint
461
344
srv_get_n_threads(void);
462
345
/*===================*/
463
 
/*********************************************************************//**
464
 
Returns the calling thread type.
465
 
@return SRV_COM, ... */
 
346
/*************************************************************************
 
347
Returns the calling thread type. */
466
348
 
467
349
enum srv_thread_type
468
350
srv_get_thread_type(void);
469
351
/*=====================*/
470
 
/*********************************************************************//**
 
352
                        /* out: SRV_COM, ... */
 
353
/*************************************************************************
471
354
Sets the info describing an i/o thread current state. */
472
355
UNIV_INTERN
473
356
void
474
357
srv_set_io_thread_op_info(
475
358
/*======================*/
476
 
        ulint           i,      /*!< in: the 'segment' of the i/o thread */
477
 
        const char*     str);   /*!< in: constant char string describing the
 
359
        ulint           i,      /* in: the 'segment' of the i/o thread */
 
360
        const char*     str);   /* in: constant char string describing the
478
361
                                state */
479
 
/*********************************************************************//**
 
362
/*************************************************************************
480
363
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 */
 
364
NOTE! The server mutex has to be reserved by the caller! */
484
365
UNIV_INTERN
485
366
ulint
486
367
srv_release_threads(
487
368
/*================*/
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 */
 
369
                                        /* out: number of threads
 
370
                                        released: this may be < n if
 
371
                                        not enough threads were
 
372
                                        suspended at the moment */
 
373
        enum srv_thread_type    type,   /* in: thread type */
 
374
        ulint                   n);     /* in: number of threads to release */
 
375
/*************************************************************************
 
376
The master thread controlling the server. */
493
377
UNIV_INTERN
494
378
os_thread_ret_t
495
379
srv_master_thread(
496
380
/*==============*/
497
 
        void*   arg);   /*!< in: a dummy parameter required by
 
381
                        /* out: a dummy parameter */
 
382
        void*   arg);   /* in: a dummy parameter required by
498
383
                        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
 
/*******************************************************************//**
 
384
/***********************************************************************
506
385
Tells the Innobase server that there has been activity in the database
507
386
and wakes up the master thread if it is suspended (not sleeping). Used
508
387
in the MySQL interface. Note that there is a small chance that the master
512
391
void
513
392
srv_active_wake_master_thread(void);
514
393
/*===============================*/
515
 
/*******************************************************************//**
 
394
/***********************************************************************
516
395
Wakes up the master thread if it is suspended or being suspended. */
517
396
UNIV_INTERN
518
397
void
519
398
srv_wake_master_thread(void);
520
399
/*========================*/
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
 
/*********************************************************************//**
 
400
/*************************************************************************
532
401
Puts an OS thread to wait if there are too many concurrent threads
533
402
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
534
403
UNIV_INTERN
535
404
void
536
405
srv_conc_enter_innodb(
537
406
/*==================*/
538
 
        trx_t*  trx);   /*!< in: transaction object associated with the
 
407
        trx_t*  trx);   /* in: transaction object associated with the
539
408
                        thread */
540
 
/*********************************************************************//**
 
409
/*************************************************************************
541
410
This lets a thread enter InnoDB regardless of the number of threads inside
542
411
InnoDB. This must be called when a thread ends a lock wait. */
543
412
UNIV_INTERN
544
413
void
545
414
srv_conc_force_enter_innodb(
546
415
/*========================*/
547
 
        trx_t*  trx);   /*!< in: transaction object associated with the
 
416
        trx_t*  trx);   /* in: transaction object associated with the
548
417
                        thread */
549
 
/*********************************************************************//**
 
418
/*************************************************************************
550
419
This must be called when a thread exits InnoDB in a lock wait or at the
551
420
end of an SQL statement. */
552
421
UNIV_INTERN
553
422
void
554
423
srv_conc_force_exit_innodb(
555
424
/*=======================*/
556
 
        trx_t*  trx);   /*!< in: transaction object associated with the
 
425
        trx_t*  trx);   /* in: transaction object associated with the
557
426
                        thread */
558
 
/*********************************************************************//**
 
427
/*************************************************************************
559
428
This must be called when a thread exits InnoDB. */
560
429
UNIV_INTERN
561
430
void
562
431
srv_conc_exit_innodb(
563
432
/*=================*/
564
 
        trx_t*  trx);   /*!< in: transaction object associated with the
 
433
        trx_t*  trx);   /* in: transaction object associated with the
565
434
                        thread */
566
 
/***************************************************************//**
 
435
/*******************************************************************
567
436
Puts a MySQL OS thread to wait for a lock to be released. If an error
568
437
occurs during the wait trx->error_state associated with thr is
569
438
!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
573
442
void
574
443
srv_suspend_mysql_thread(
575
444
/*=====================*/
576
 
        que_thr_t*      thr);   /*!< in: query thread associated with the MySQL
 
445
        que_thr_t*      thr);   /* in: query thread associated with the MySQL
577
446
                                OS thread */
578
 
/********************************************************************//**
 
447
/************************************************************************
579
448
Releases a MySQL OS thread waiting for a lock to be released, if the
580
449
thread is already suspended. */
581
450
UNIV_INTERN
582
451
void
583
452
srv_release_mysql_thread_if_suspended(
584
453
/*==================================*/
585
 
        que_thr_t*      thr);   /*!< in: query thread associated with the
 
454
        que_thr_t*      thr);   /* in: query thread associated with the
586
455
                                MySQL OS thread  */
587
 
/*********************************************************************//**
 
456
/*************************************************************************
588
457
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
 
458
This also prints the info output by various InnoDB monitors. */
 
459
UNIV_INTERN
 
460
os_thread_ret_t
 
461
srv_lock_timeout_and_monitor_thread(
 
462
/*================================*/
 
463
                        /* out: a dummy parameter */
 
464
        void*   arg);   /* in: a dummy parameter required by
604
465
                        os_thread_create */
605
466
/*************************************************************************
606
467
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 */
 
468
too long. These can be used to track bugs which cause hangs. */
609
469
UNIV_INTERN
610
470
os_thread_ret_t
611
471
srv_error_monitor_thread(
612
472
/*=====================*/
613
 
        void*   arg);   /*!< in: a dummy parameter required by
 
473
                        /* out: a dummy parameter */
 
474
        void*   arg);   /* in: a dummy parameter required by
614
475
                        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 */
 
476
/**********************************************************************
 
477
Outputs to a file the output of the InnoDB Monitor. */
619
478
UNIV_INTERN
620
 
ibool
 
479
void
621
480
srv_printf_innodb_monitor(
622
481
/*======================*/
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
 
482
        FILE*   file,           /* in: output stream */
 
483
        ulint*  trx_start,      /* out: file position of the start of
626
484
                                the list of active transactions */
627
 
        ulint*  trx_end);       /*!< out: file position of the end of
 
485
        ulint*  trx_end);       /* out: file position of the end of
628
486
                                the list of active transactions */
629
487
 
630
 
/******************************************************************//**
 
488
/**********************************************************************
631
489
Function to pass InnoDB status variables to MySQL */
632
490
UNIV_INTERN
633
491
void
634
492
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
493
/*=====================*/
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 */
 
494
 
 
495
/* Thread slot in the thread table */
727
496
typedef struct srv_slot_struct  srv_slot_t;
728
497
 
729
 
/** Thread table is an array of slots */
 
498
/* Thread table is an array of slots */
730
499
typedef srv_slot_t      srv_table_t;
731
500
 
732
 
/** The server system struct */
 
501
/* In this structure we store status variables to be passed to MySQL */
 
502
struct export_var_struct{
 
503
        ulint innodb_data_pending_reads;
 
504
        ulint innodb_data_pending_writes;
 
505
        ulint innodb_data_pending_fsyncs;
 
506
        ulint innodb_data_fsyncs;
 
507
        ulint innodb_data_read;
 
508
        ulint innodb_data_writes;
 
509
        ulint innodb_data_written;
 
510
        ulint innodb_data_reads;
 
511
        ulint innodb_buffer_pool_pages_total;
 
512
        ulint innodb_buffer_pool_pages_data;
 
513
        ulint innodb_buffer_pool_pages_dirty;
 
514
        ulint innodb_buffer_pool_pages_misc;
 
515
        ulint innodb_buffer_pool_pages_free;
 
516
#ifdef UNIV_DEBUG
 
517
        ulint innodb_buffer_pool_pages_latched;
 
518
#endif /* UNIV_DEBUG */
 
519
        ulint innodb_buffer_pool_read_requests;
 
520
        ulint innodb_buffer_pool_reads;
 
521
        ulint innodb_buffer_pool_wait_free;
 
522
        ulint innodb_buffer_pool_pages_flushed;
 
523
        ulint innodb_buffer_pool_write_requests;
 
524
        ulint innodb_buffer_pool_read_ahead_seq;
 
525
        ulint innodb_buffer_pool_read_ahead_rnd;
 
526
        ulint innodb_dblwr_pages_written;
 
527
        ulint innodb_dblwr_writes;
 
528
        ulint innodb_log_waits;
 
529
        ulint innodb_log_write_requests;
 
530
        ulint innodb_log_writes;
 
531
        ulint innodb_os_log_written;
 
532
        ulint innodb_os_log_fsyncs;
 
533
        ulint innodb_os_log_pending_writes;
 
534
        ulint innodb_os_log_pending_fsyncs;
 
535
        ulint innodb_page_size;
 
536
        ulint innodb_pages_created;
 
537
        ulint innodb_pages_read;
 
538
        ulint innodb_pages_written;
 
539
        ulint innodb_row_lock_waits;
 
540
        ulint innodb_row_lock_current_waits;
 
541
        ib_int64_t innodb_row_lock_time;
 
542
        ulint innodb_row_lock_time_avg;
 
543
        ulint innodb_row_lock_time_max;
 
544
        ulint innodb_rows_read;
 
545
        ulint innodb_rows_inserted;
 
546
        ulint innodb_rows_updated;
 
547
        ulint innodb_rows_deleted;
 
548
};
 
549
 
 
550
/* The server system struct */
733
551
struct srv_sys_struct{
734
 
        srv_table_t*    threads;        /*!< server thread table */
 
552
        srv_table_t*    threads;        /* server thread table */
735
553
        UT_LIST_BASE_NODE_T(que_thr_t)
736
 
                        tasks;          /*!< task queue */
 
554
                        tasks;          /* task queue */
 
555
        dict_index_t*   dummy_ind1;     /* dummy index for old-style
 
556
                                        supremum and infimum records */
 
557
        dict_index_t*   dummy_ind2;     /* dummy index for new-style
 
558
                                        supremum and infimum records */
737
559
};
738
560
 
739
561
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
562
 
754
563
#endif
 
564