~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 01:02:23 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321010223-j8cph7eeyt1u3xol
Fixed function object to ensure it correctly returns a boolean type since
memcmp returns an integer. Added some more comments.

Show diffs side-by-side

added added

removed removed

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