~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Jay Pipes
  • Date: 2008-12-18 15:55:03 UTC
  • mto: This revision was merged to the branch mainline in revision 717.
  • Revision ID: jpipes@serialcoder-20081218155503-u45ygyunrdyyvquq
Fix for Bug#308457.  Gave UTF8 enclosure and escape character on LOAD DATA INFILE and changed the error message to be more descriptive

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