~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/srv/srv0srv.c

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "srv0srv.h"
29
29
 
30
30
#include "ut0mem.h"
31
 
#include "ut0ut.h"
32
31
#include "os0proc.h"
33
32
#include "mem0mem.h"
34
33
#include "mem0pool.h"
43
42
#include "trx0purge.h"
44
43
#include "ibuf0ibuf.h"
45
44
#include "buf0flu.h"
46
 
#include "buf0lru.h"
47
45
#include "btr0sea.h"
48
46
#include "dict0load.h"
49
47
#include "dict0boot.h"
50
48
#include "srv0start.h"
51
49
#include "row0mysql.h"
52
50
#include "ha_prototypes.h"
53
 
#include "trx0i_s.h"
54
51
 
55
52
/* This is set to TRUE if the MySQL user has set it in MySQL; currently
56
53
affects only FOREIGN KEY definition parsing */
57
 
UNIV_INTERN ibool       srv_lower_case_table_names      = FALSE;
 
54
ibool   srv_lower_case_table_names      = FALSE;
58
55
 
59
56
/* The following counter is incremented whenever there is some user activity
60
57
in the server */
61
 
UNIV_INTERN ulint       srv_activity_count      = 0;
 
58
ulint   srv_activity_count      = 0;
62
59
 
63
60
/* The following is the maximum allowed duration of a lock wait. */
64
 
UNIV_INTERN ulint       srv_fatal_semaphore_wait_threshold = 600;
 
61
ulint   srv_fatal_semaphore_wait_threshold = 600;
65
62
 
66
63
/* How much data manipulation language (DML) statements need to be delayed,
67
64
in microseconds, in order to reduce the lagging of the purge thread. */
68
 
UNIV_INTERN ulint       srv_dml_needed_delay = 0;
69
 
 
70
 
UNIV_INTERN ibool       srv_lock_timeout_and_monitor_active = FALSE;
71
 
UNIV_INTERN ibool       srv_error_monitor_active = FALSE;
72
 
 
73
 
UNIV_INTERN const char* srv_main_thread_op_info = "";
 
65
ulint   srv_dml_needed_delay = 0;
 
66
 
 
67
ibool   srv_lock_timeout_and_monitor_active = FALSE;
 
68
ibool   srv_error_monitor_active = FALSE;
 
69
 
 
70
const char*     srv_main_thread_op_info = "";
74
71
 
75
72
/* Prefix used by MySQL to indicate pre-5.1 table name encoding */
76
 
UNIV_INTERN const char  srv_mysql50_table_name_prefix[9] = "#mysql50#";
 
73
const char      srv_mysql50_table_name_prefix[9] = "#mysql50#";
77
74
 
78
75
/* Server parameters which are read from the initfile */
79
76
 
80
77
/* The following three are dir paths which are catenated before file
81
78
names, where the file name itself may also contain a path */
82
79
 
83
 
UNIV_INTERN char*       srv_data_home   = NULL;
 
80
char*   srv_data_home   = NULL;
84
81
#ifdef UNIV_LOG_ARCHIVE
85
 
UNIV_INTERN char*       srv_arch_dir    = NULL;
 
82
char*   srv_arch_dir    = NULL;
86
83
#endif /* UNIV_LOG_ARCHIVE */
87
84
 
88
 
/* store to its own file each table created by an user; data
89
 
dictionary tables are in the system tablespace 0 */
90
 
UNIV_INTERN my_bool     srv_file_per_table;
91
 
/* The file format to use on new *.ibd files. */
92
 
UNIV_INTERN ulint       srv_file_format = 0;
93
 
/* Whether to check file format during startup a value of 
94
 
DICT_TF_FORMAT_MAX + 1 means no checking ie. FALSE.  The default is to
95
 
set it to the highest format we support. */
96
 
UNIV_INTERN ulint       srv_check_file_format_at_startup = DICT_TF_FORMAT_MAX;
97
 
 
98
 
#if DICT_TF_FORMAT_51
99
 
# error "DICT_TF_FORMAT_51 must be 0!"
100
 
#endif
101
 
/* Place locks to records only i.e. do not use next-key locking except
102
 
on duplicate key checking and foreign key checking */
103
 
UNIV_INTERN ibool       srv_locks_unsafe_for_binlog = FALSE;
104
 
 
105
 
UNIV_INTERN ulint       srv_n_data_files = 0;
106
 
UNIV_INTERN char**      srv_data_file_names = NULL;
107
 
/* size in database pages */
108
 
UNIV_INTERN ulint*      srv_data_file_sizes = NULL;
109
 
 
110
 
/* if TRUE, then we auto-extend the last data file */
111
 
UNIV_INTERN ibool       srv_auto_extend_last_data_file  = FALSE;
112
 
/* if != 0, this tells the max size auto-extending may increase the
113
 
last data file size */
114
 
UNIV_INTERN ulint       srv_last_file_size_max  = 0;
115
 
/* If the last data file is auto-extended, we add this
116
 
many pages to it at a time */
117
 
UNIV_INTERN ulong       srv_auto_extend_increment = 8;
118
 
UNIV_INTERN ulint*      srv_data_file_is_raw_partition = NULL;
 
85
ibool   srv_file_per_table = FALSE;     /* store to its own file each table
 
86
                                        created by an user; data dictionary
 
87
                                        tables are in the system tablespace
 
88
                                        0 */
 
89
ibool   srv_locks_unsafe_for_binlog = FALSE;    /* Place locks to
 
90
                                                records only i.e. do
 
91
                                                not use next-key
 
92
                                                locking except on
 
93
                                                duplicate key checking
 
94
                                                and foreign key
 
95
                                                checking */
 
96
ulint   srv_n_data_files = 0;
 
97
char**  srv_data_file_names = NULL;
 
98
ulint*  srv_data_file_sizes = NULL;     /* size in database pages */
 
99
 
 
100
ibool   srv_auto_extend_last_data_file  = FALSE; /* if TRUE, then we
 
101
                                                 auto-extend the last data
 
102
                                                 file */
 
103
ulint   srv_last_file_size_max  = 0;             /* if != 0, this tells
 
104
                                                 the max size auto-extending
 
105
                                                 may increase the last data
 
106
                                                 file size */
 
107
ulong   srv_auto_extend_increment = 8;           /* If the last data file is
 
108
                                                 auto-extended, we add this
 
109
                                                 many pages to it at a time */
 
110
ulint*  srv_data_file_is_raw_partition = NULL;
119
111
 
120
112
/* If the following is TRUE we do not allow inserts etc. This protects
121
113
the user from forgetting the 'newraw' keyword to my.cnf */
122
114
 
123
 
UNIV_INTERN ibool       srv_created_new_raw     = FALSE;
124
 
 
125
 
UNIV_INTERN char**      srv_log_group_home_dirs = NULL;
126
 
 
127
 
UNIV_INTERN ulint       srv_n_log_groups        = ULINT_MAX;
128
 
UNIV_INTERN ulint       srv_n_log_files         = ULINT_MAX;
129
 
/* size in database pages */
130
 
UNIV_INTERN ulint       srv_log_file_size       = ULINT_MAX;
131
 
/* size in database pages */
132
 
UNIV_INTERN ulint       srv_log_buffer_size     = ULINT_MAX;
133
 
UNIV_INTERN ulong       srv_flush_log_at_trx_commit = 1;
134
 
 
135
 
/* The sort order table of the MySQL latin1_swedish_ci character set
136
 
collation */
137
 
UNIV_INTERN const byte  srv_latin1_ordering[256]        /* The sort order table of the latin1
 
115
ibool   srv_created_new_raw     = FALSE;
 
116
 
 
117
char**  srv_log_group_home_dirs = NULL;
 
118
 
 
119
ulint   srv_n_log_groups        = ULINT_MAX;
 
120
ulint   srv_n_log_files         = ULINT_MAX;
 
121
ulint   srv_log_file_size       = ULINT_MAX;    /* size in database pages */
 
122
ulint   srv_log_buffer_size     = ULINT_MAX;    /* size in database pages */
 
123
ulong   srv_flush_log_at_trx_commit = 1;
 
124
 
 
125
byte    srv_latin1_ordering[256]        /* The sort order table of the latin1
138
126
                                        character set. The following table is
139
127
                                        the MySQL order as of Feb 10th, 2002 */
140
128
= {
172
160
, 0xD8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0xFF
173
161
};
174
162
 
175
 
 
176
 
/* requested size in kilobytes */
177
 
UNIV_INTERN ulong       srv_buf_pool_size       = ULINT_MAX;
178
 
/* previously requested size */
179
 
UNIV_INTERN ulong       srv_buf_pool_old_size;
180
 
/* current size in kilobytes */
181
 
UNIV_INTERN ulong       srv_buf_pool_curr_size  = 0;
182
 
/* size in bytes */
183
 
UNIV_INTERN ulint       srv_mem_pool_size       = ULINT_MAX;
184
 
UNIV_INTERN ulint       srv_lock_table_size     = ULINT_MAX;
185
 
 
186
 
UNIV_INTERN ulint       srv_n_file_io_threads   = ULINT_MAX;
 
163
ulint   srv_pool_size           = ULINT_MAX;    /* size in pages; MySQL inits
 
164
                                                this to size in kilobytes but
 
165
                                                we normalize this to pages in
 
166
                                                srv_boot() */
 
167
ulint   srv_awe_window_size     = 0;            /* size in pages; MySQL inits
 
168
                                                this to bytes, but we
 
169
                                                normalize it to pages in
 
170
                                                srv_boot() */
 
171
ulint   srv_mem_pool_size       = ULINT_MAX;    /* size in bytes */
 
172
ulint   srv_lock_table_size     = ULINT_MAX;
 
173
 
 
174
ulint   srv_n_file_io_threads   = ULINT_MAX;
187
175
 
188
176
#ifdef UNIV_LOG_ARCHIVE
189
 
UNIV_INTERN ibool               srv_log_archive_on      = FALSE;
190
 
UNIV_INTERN ibool               srv_archive_recovery    = 0;
191
 
UNIV_INTERN ib_uint64_t srv_archive_recovery_limit_lsn;
 
177
ibool   srv_log_archive_on      = FALSE;
 
178
ibool   srv_archive_recovery    = 0;
 
179
dulint  srv_archive_recovery_limit_lsn;
192
180
#endif /* UNIV_LOG_ARCHIVE */
193
181
 
194
 
UNIV_INTERN ulint       srv_lock_wait_timeout   = 1024 * 1024 * 1024;
 
182
ulint   srv_lock_wait_timeout   = 1024 * 1024 * 1024;
195
183
 
196
184
/* This parameter is used to throttle the number of insert buffers that are
197
185
merged in a batch. By increasing this parameter on a faster disk you can
201
189
the parameter is scaled down by a factor of 4, this is to avoid putting
202
190
a heavier load on the I/O sub system. */
203
191
 
204
 
UNIV_INTERN ulong       srv_insert_buffer_batch_size = 20;
205
 
 
206
 
UNIV_INTERN char*       srv_file_flush_method_str = NULL;
207
 
UNIV_INTERN ulint       srv_unix_file_flush_method = SRV_UNIX_FSYNC;
208
 
UNIV_INTERN ulint       srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
209
 
 
210
 
UNIV_INTERN ulint       srv_max_n_open_files      = 300;
 
192
ulong   srv_insert_buffer_batch_size = 20;
 
193
 
 
194
char*   srv_file_flush_method_str = NULL;
 
195
ulint   srv_unix_file_flush_method = SRV_UNIX_FSYNC;
 
196
ulint   srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
 
197
 
 
198
ulint   srv_max_n_open_files      = 300;
211
199
 
212
200
/* The InnoDB main thread tries to keep the ratio of modified pages
213
201
in the buffer pool to all database pages in the buffer pool smaller than
214
202
the following number. But it is not guaranteed that the value stays below
215
203
that during a time of heavy update/insert activity. */
216
204
 
217
 
UNIV_INTERN ulong       srv_max_buf_pool_modified_pct   = 90;
 
205
ulong   srv_max_buf_pool_modified_pct   = 90;
218
206
 
219
207
/* variable counts amount of data read in total (in bytes) */
220
 
UNIV_INTERN ulint srv_data_read = 0;
 
208
ulint srv_data_read = 0;
221
209
 
222
210
/* here we count the amount of data written in total (in bytes) */
223
 
UNIV_INTERN ulint srv_data_written = 0;
 
211
ulint srv_data_written = 0;
224
212
 
225
213
/* the number of the log write requests done */
226
 
UNIV_INTERN ulint srv_log_write_requests = 0;
 
214
ulint srv_log_write_requests = 0;
227
215
 
228
216
/* the number of physical writes to the log performed */
229
 
UNIV_INTERN ulint srv_log_writes = 0;
 
217
ulint srv_log_writes = 0;
230
218
 
231
219
/* amount of data written to the log files in bytes */
232
 
UNIV_INTERN ulint srv_os_log_written = 0;
 
220
ulint srv_os_log_written = 0;
233
221
 
234
222
/* amount of writes being done to the log files */
235
 
UNIV_INTERN ulint srv_os_log_pending_writes = 0;
 
223
ulint srv_os_log_pending_writes = 0;
236
224
 
237
225
/* we increase this counter, when there we don't have enough space in the
238
226
log buffer and have to flush it */
239
 
UNIV_INTERN ulint srv_log_waits = 0;
 
227
ulint srv_log_waits = 0;
240
228
 
241
229
/* this variable counts the amount of times, when the doublewrite buffer
242
230
was flushed */
243
 
UNIV_INTERN ulint srv_dblwr_writes = 0;
 
231
ulint srv_dblwr_writes = 0;
244
232
 
245
233
/* here we store the number of pages that have been flushed to the
246
234
doublewrite buffer */
247
 
UNIV_INTERN ulint srv_dblwr_pages_written = 0;
 
235
ulint srv_dblwr_pages_written = 0;
248
236
 
249
237
/* in this variable we store the number of write requests issued */
250
 
UNIV_INTERN ulint srv_buf_pool_write_requests = 0;
 
238
ulint srv_buf_pool_write_requests = 0;
251
239
 
252
240
/* here we store the number of times when we had to wait for a free page
253
241
in the buffer pool. It happens when the buffer pool is full and we need
254
242
to make a flush, in order to be able to read or create a page. */
255
 
UNIV_INTERN ulint srv_buf_pool_wait_free = 0;
 
243
ulint srv_buf_pool_wait_free = 0;
256
244
 
257
245
/* variable to count the number of pages that were written from buffer
258
246
pool to the disk */
259
 
UNIV_INTERN ulint srv_buf_pool_flushed = 0;
 
247
ulint srv_buf_pool_flushed = 0;
260
248
 
261
249
/* variable to count the number of buffer pool reads that led to the
262
250
reading of a disk page */
263
 
UNIV_INTERN ulint srv_buf_pool_reads = 0;
 
251
ulint srv_buf_pool_reads = 0;
264
252
 
265
253
/* variable to count the number of sequential read-aheads */
266
 
UNIV_INTERN ulint srv_read_ahead_seq = 0;
 
254
ulint srv_read_ahead_seq = 0;
267
255
 
268
256
/* variable to count the number of random read-aheads */
269
 
UNIV_INTERN ulint srv_read_ahead_rnd = 0;
 
257
ulint srv_read_ahead_rnd = 0;
270
258
 
271
259
/* structure to pass status variables to MySQL */
272
 
UNIV_INTERN export_struc export_vars;
 
260
export_struc export_vars;
273
261
 
274
262
/* If the following is != 0 we do not allow inserts etc. This protects
275
263
the user from forgetting the innodb_force_recovery keyword to my.cnf */
276
264
 
277
 
UNIV_INTERN ulint       srv_force_recovery      = 0;
 
265
ulint   srv_force_recovery      = 0;
278
266
/*-----------------------*/
279
267
/* We are prepared for a situation that we have this many threads waiting for
280
268
a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
281
269
value. */
282
270
 
283
 
UNIV_INTERN ulint       srv_max_n_threads       = 0;
 
271
ulint   srv_max_n_threads       = 0;
284
272
 
285
273
/* The following controls how many threads we let inside InnoDB concurrently:
286
274
threads waiting for locks are not counted into the number because otherwise
290
278
computer. Bigger computers need bigger values. Value 0 will disable the
291
279
concurrency check. */
292
280
 
293
 
UNIV_INTERN ulong       srv_thread_concurrency  = 0;
294
 
UNIV_INTERN ulong       srv_commit_concurrency  = 0;
 
281
ulong   srv_thread_concurrency  = 0;
 
282
ulong   srv_commit_concurrency  = 0;
295
283
 
296
 
/* this mutex protects srv_conc data structures */
297
 
UNIV_INTERN os_fast_mutex_t     srv_conc_mutex;
298
 
/* number of OS threads currently inside InnoDB; it is not an error if
299
 
this drops temporarily below zero because we do not demand that every
300
 
thread increments this, but a thread waiting for a lock decrements
301
 
this temporarily */
302
 
UNIV_INTERN lint        srv_conc_n_threads      = 0;
303
 
/* number of OS threads waiting in the FIFO for a permission to enter
304
 
InnoDB */
305
 
UNIV_INTERN ulint       srv_conc_n_waiting_threads = 0;
 
284
os_fast_mutex_t srv_conc_mutex;         /* this mutex protects srv_conc data
 
285
                                        structures */
 
286
lint    srv_conc_n_threads      = 0;    /* number of OS threads currently
 
287
                                        inside InnoDB; it is not an error
 
288
                                        if this drops temporarily below zero
 
289
                                        because we do not demand that every
 
290
                                        thread increments this, but a thread
 
291
                                        waiting for a lock decrements this
 
292
                                        temporarily */
 
293
ulint   srv_conc_n_waiting_threads = 0; /* number of OS threads waiting in the
 
294
                                        FIFO for a permission to enter InnoDB
 
295
                                        */
306
296
 
307
297
typedef struct srv_conc_slot_struct     srv_conc_slot_t;
308
298
struct srv_conc_slot_struct{
319
309
        UT_LIST_NODE_T(srv_conc_slot_t) srv_conc_queue; /* queue node */
320
310
};
321
311
 
322
 
/* queue of threads waiting to get in */
323
 
UNIV_INTERN UT_LIST_BASE_NODE_T(srv_conc_slot_t)        srv_conc_queue;
324
 
/* array of wait slots */
325
 
UNIV_INTERN srv_conc_slot_t* srv_conc_slots;
 
312
UT_LIST_BASE_NODE_T(srv_conc_slot_t)    srv_conc_queue; /* queue of threads
 
313
                                                        waiting to get in */
 
314
srv_conc_slot_t* srv_conc_slots;                        /* array of wait
 
315
                                                        slots */
326
316
 
327
317
/* Number of times a thread is allowed to enter InnoDB within the same
328
318
SQL query after it has once got the ticket at srv_conc_enter_innodb */
333
323
merge to completion before shutdown. If it is set to 2, do not even flush the
334
324
buffer pool to data files at the shutdown: we effectively 'crash'
335
325
InnoDB (but lose no committed transactions). */
336
 
UNIV_INTERN ulint       srv_fast_shutdown       = 0;
 
326
ulint   srv_fast_shutdown       = 0;
337
327
 
338
328
/* Generate a innodb_status.<pid> file */
339
 
UNIV_INTERN ibool       srv_innodb_status       = FALSE;
340
 
 
341
 
UNIV_INTERN ibool       srv_stats_on_metadata   = TRUE;
342
 
 
343
 
UNIV_INTERN ibool       srv_use_doublewrite_buf = TRUE;
344
 
UNIV_INTERN ibool       srv_use_checksums = TRUE;
345
 
 
346
 
UNIV_INTERN ibool       srv_set_thread_priorities = TRUE;
347
 
UNIV_INTERN int srv_query_thread_priority = 0;
348
 
 
349
 
UNIV_INTERN ulint       srv_replication_delay           = 0;
 
329
ibool   srv_innodb_status       = FALSE;
 
330
 
 
331
ibool   srv_stats_on_metadata   = TRUE;
 
332
 
 
333
ibool   srv_use_doublewrite_buf = TRUE;
 
334
ibool   srv_use_checksums = TRUE;
 
335
 
 
336
ibool   srv_set_thread_priorities = TRUE;
 
337
int     srv_query_thread_priority = 0;
 
338
 
 
339
/* TRUE if the Address Windowing Extensions of Windows are used; then we must
 
340
disable adaptive hash indexes */
 
341
ibool   srv_use_awe                     = FALSE;
 
342
ibool   srv_use_adaptive_hash_indexes   = TRUE;
350
343
 
351
344
/*-------------------------------------------*/
352
 
UNIV_INTERN ulong       srv_n_spin_wait_rounds  = 20;
353
 
UNIV_INTERN ulong       srv_n_free_tickets_to_enter = 500;
354
 
UNIV_INTERN ulong       srv_thread_sleep_delay = 10000;
355
 
UNIV_INTERN ulint       srv_spin_wait_delay     = 5;
356
 
UNIV_INTERN ibool       srv_priority_boost      = TRUE;
357
 
 
358
 
#ifdef UNIV_DEBUG
359
 
UNIV_INTERN ibool       srv_print_thread_releases       = FALSE;
360
 
UNIV_INTERN ibool       srv_print_lock_waits            = FALSE;
361
 
UNIV_INTERN ibool       srv_print_buf_io                = FALSE;
362
 
UNIV_INTERN ibool       srv_print_log_io                = FALSE;
363
 
UNIV_INTERN ibool       srv_print_latch_waits           = FALSE;
364
 
#endif /* UNIV_DEBUG */
365
 
 
366
 
UNIV_INTERN ulint               srv_n_rows_inserted             = 0;
367
 
UNIV_INTERN ulint               srv_n_rows_updated              = 0;
368
 
UNIV_INTERN ulint               srv_n_rows_deleted              = 0;
369
 
UNIV_INTERN ulint               srv_n_rows_read                 = 0;
 
345
ulong   srv_n_spin_wait_rounds  = 20;
 
346
ulong   srv_n_free_tickets_to_enter = 500;
 
347
ulong   srv_thread_sleep_delay = 10000;
 
348
ulint   srv_spin_wait_delay     = 5;
 
349
ibool   srv_priority_boost      = TRUE;
 
350
 
 
351
ibool   srv_print_thread_releases       = FALSE;
 
352
ibool   srv_print_lock_waits            = FALSE;
 
353
ibool   srv_print_buf_io                = FALSE;
 
354
ibool   srv_print_log_io                = FALSE;
 
355
ibool   srv_print_latch_waits           = FALSE;
 
356
 
 
357
ulint           srv_n_rows_inserted             = 0;
 
358
ulint           srv_n_rows_updated              = 0;
 
359
ulint           srv_n_rows_deleted              = 0;
 
360
ulint           srv_n_rows_read                 = 0;
370
361
#ifndef UNIV_HOTBACKUP
371
362
static ulint    srv_n_rows_inserted_old         = 0;
372
363
static ulint    srv_n_rows_updated_old          = 0;
374
365
static ulint    srv_n_rows_read_old             = 0;
375
366
#endif /* !UNIV_HOTBACKUP */
376
367
 
377
 
UNIV_INTERN ulint               srv_n_lock_wait_count           = 0;
378
 
UNIV_INTERN ulint               srv_n_lock_wait_current_count   = 0;
379
 
UNIV_INTERN ib_int64_t  srv_n_lock_wait_time            = 0;
380
 
UNIV_INTERN ulint               srv_n_lock_max_wait_time        = 0;
 
368
ulint           srv_n_lock_wait_count           = 0;
 
369
ulint           srv_n_lock_wait_current_count   = 0;
 
370
ib_longlong     srv_n_lock_wait_time            = 0;
 
371
ulint           srv_n_lock_max_wait_time        = 0;
381
372
 
382
373
 
383
374
/*
384
375
  Set the following to 0 if you want InnoDB to write messages on
385
376
  stderr on startup/shutdown
386
377
*/
387
 
UNIV_INTERN ibool       srv_print_verbose_log           = TRUE;
388
 
UNIV_INTERN ibool       srv_print_innodb_monitor        = FALSE;
389
 
UNIV_INTERN ibool       srv_print_innodb_lock_monitor   = FALSE;
390
 
UNIV_INTERN ibool       srv_print_innodb_tablespace_monitor = FALSE;
391
 
UNIV_INTERN ibool       srv_print_innodb_table_monitor = FALSE;
 
378
ibool   srv_print_verbose_log           = TRUE;
 
379
ibool   srv_print_innodb_monitor        = FALSE;
 
380
ibool   srv_print_innodb_lock_monitor   = FALSE;
 
381
ibool   srv_print_innodb_tablespace_monitor = FALSE;
 
382
ibool   srv_print_innodb_table_monitor = FALSE;
392
383
 
393
384
/* Array of English strings describing the current state of an
394
385
i/o handler thread */
395
386
 
396
 
UNIV_INTERN const char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];
397
 
UNIV_INTERN const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
398
 
 
399
 
UNIV_INTERN time_t      srv_last_monitor_time;
400
 
 
401
 
UNIV_INTERN mutex_t     srv_innodb_monitor_mutex;
 
387
const char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];
 
388
const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
 
389
 
 
390
time_t  srv_last_monitor_time;
 
391
 
 
392
mutex_t srv_innodb_monitor_mutex;
402
393
 
403
394
/* Mutex for locking srv_monitor_file */
404
 
UNIV_INTERN mutex_t     srv_monitor_file_mutex;
 
395
mutex_t srv_monitor_file_mutex;
405
396
/* Temporary file for innodb monitor output */
406
 
UNIV_INTERN FILE*       srv_monitor_file;
 
397
FILE*   srv_monitor_file;
407
398
/* Mutex for locking srv_dict_tmpfile.
408
399
This mutex has a very high rank; threads reserving it should not
409
400
be holding any InnoDB latches. */
410
 
UNIV_INTERN mutex_t     srv_dict_tmpfile_mutex;
 
401
mutex_t srv_dict_tmpfile_mutex;
411
402
/* Temporary file for output from the data dictionary */
412
 
UNIV_INTERN FILE*       srv_dict_tmpfile;
 
403
FILE*   srv_dict_tmpfile;
413
404
/* Mutex for locking srv_misc_tmpfile.
414
405
This mutex has a very low rank; threads reserving it should not
415
406
acquire any further latches or sleep before releasing this one. */
416
 
UNIV_INTERN mutex_t     srv_misc_tmpfile_mutex;
 
407
mutex_t srv_misc_tmpfile_mutex;
417
408
/* Temporary file for miscellanous diagnostic output */
418
 
UNIV_INTERN FILE*       srv_misc_tmpfile;
 
409
FILE*   srv_misc_tmpfile;
419
410
 
420
 
UNIV_INTERN ulint       srv_main_thread_process_no      = 0;
421
 
UNIV_INTERN ulint       srv_main_thread_id              = 0;
 
411
ulint   srv_main_thread_process_no      = 0;
 
412
ulint   srv_main_thread_id              = 0;
422
413
 
423
414
/*
424
415
        IMPLEMENTATION OF THE SERVER MAIN PROGRAM
592
583
struct srv_slot_struct{
593
584
        os_thread_id_t  id;             /* thread id */
594
585
        os_thread_t     handle;         /* thread handle */
595
 
        unsigned        type:3;         /* thread type: user, utility etc. */
596
 
        unsigned        in_use:1;       /* TRUE if this slot is in use */
597
 
        unsigned        suspended:1;    /* TRUE if the thread is waiting
 
586
        ulint           type;           /* thread type: user, utility etc. */
 
587
        ibool           in_use;         /* TRUE if this slot is in use */
 
588
        ibool           suspended;      /* TRUE if the thread is waiting
598
589
                                        for the event of this slot */
599
590
        ib_time_t       suspend_time;   /* time when the thread was
600
591
                                        suspended */
605
596
};
606
597
 
607
598
/* Table for MySQL threads where they will be suspended to wait for locks */
608
 
UNIV_INTERN srv_slot_t* srv_mysql_table = NULL;
609
 
 
610
 
UNIV_INTERN os_event_t  srv_lock_timeout_thread_event;
611
 
 
612
 
UNIV_INTERN srv_sys_t*  srv_sys = NULL;
613
 
 
614
 
/* padding to prevent other memory update hotspots from residing on
615
 
the same memory cache line */
616
 
UNIV_INTERN byte        srv_pad1[64];
617
 
/* mutex protecting the server, trx structs, query threads, and lock table */
618
 
UNIV_INTERN mutex_t*    kernel_mutex_temp;
619
 
/* padding to prevent other memory update hotspots from residing on
620
 
the same memory cache line */
621
 
UNIV_INTERN byte        srv_pad2[64];
622
 
 
623
 
#if 0
 
599
srv_slot_t*     srv_mysql_table = NULL;
 
600
 
 
601
os_event_t      srv_lock_timeout_thread_event;
 
602
 
 
603
srv_sys_t*      srv_sys = NULL;
 
604
 
 
605
byte            srv_pad1[64];   /* padding to prevent other memory update
 
606
                                hotspots from residing on the same memory
 
607
                                cache line */
 
608
mutex_t*        kernel_mutex_temp;/* mutex protecting the server, trx structs,
 
609
                                query threads, and lock table */
 
610
byte            srv_pad2[64];   /* padding to prevent other memory update
 
611
                                hotspots from residing on the same memory
 
612
                                cache line */
 
613
 
624
614
/* The following three values measure the urgency of the jobs of
625
615
buffer, version, and insert threads. They may vary from 0 - 1000.
626
616
The server mutex protects all these variables. The low-water values
627
617
tell that the server can acquiesce the utility when the value
628
618
drops below this low-water mark. */
629
619
 
630
 
static ulint    srv_meter[SRV_MASTER + 1];
631
 
static ulint    srv_meter_low_water[SRV_MASTER + 1];
632
 
static ulint    srv_meter_high_water[SRV_MASTER + 1];
633
 
static ulint    srv_meter_high_water2[SRV_MASTER + 1];
634
 
static ulint    srv_meter_foreground[SRV_MASTER + 1];
635
 
#endif
 
620
ulint   srv_meter[SRV_MASTER + 1];
 
621
ulint   srv_meter_low_water[SRV_MASTER + 1];
 
622
ulint   srv_meter_high_water[SRV_MASTER + 1];
 
623
ulint   srv_meter_high_water2[SRV_MASTER + 1];
 
624
ulint   srv_meter_foreground[SRV_MASTER + 1];
636
625
 
637
626
/* The following values give info about the activity going on in
638
627
the database. They are protected by the server mutex. The arrays
639
628
are indexed by the type of the thread. */
640
629
 
641
 
UNIV_INTERN ulint       srv_n_threads_active[SRV_MASTER + 1];
642
 
UNIV_INTERN ulint       srv_n_threads[SRV_MASTER + 1];
 
630
ulint   srv_n_threads_active[SRV_MASTER + 1];
 
631
ulint   srv_n_threads[SRV_MASTER + 1];
643
632
 
644
633
/*************************************************************************
645
634
Sets the info describing an i/o thread current state. */
646
 
UNIV_INTERN
 
635
 
647
636
void
648
637
srv_set_io_thread_op_info(
649
638
/*======================*/
674
663
#ifndef UNIV_HOTBACKUP
675
664
/*************************************************************************
676
665
Gets the number of threads in the system. */
677
 
UNIV_INTERN
 
666
 
678
667
ulint
679
668
srv_get_n_threads(void)
680
669
/*===================*/
702
691
ulint
703
692
srv_table_reserve_slot(
704
693
/*===================*/
705
 
                                        /* out: reserved slot index */
706
 
        enum srv_thread_type    type)   /* in: type of the thread */
 
694
                        /* out: reserved slot index */
 
695
        ulint   type)   /* in: type of the thread: one of SRV_COM, ... */
707
696
{
708
697
        srv_slot_t*     slot;
709
698
        ulint           i;
723
712
 
724
713
        slot->in_use = TRUE;
725
714
        slot->suspended = FALSE;
 
715
        slot->id = os_thread_get_curr_id();
 
716
        slot->handle = os_thread_get_curr();
726
717
        slot->type = type;
727
 
        slot->id = os_thread_get_curr_id();
728
 
        slot->handle = os_thread_get_curr();
729
718
 
730
719
        thr_local_create();
731
720
 
743
732
/*====================*/
744
733
                        /* out: event for the calling thread to wait */
745
734
{
746
 
        srv_slot_t*             slot;
747
 
        os_event_t              event;
748
 
        ulint                   slot_no;
749
 
        enum srv_thread_type    type;
 
735
        srv_slot_t*     slot;
 
736
        os_event_t      event;
 
737
        ulint           slot_no;
 
738
        ulint           type;
750
739
 
751
740
        ut_ad(mutex_own(&kernel_mutex));
752
741
 
754
743
 
755
744
        if (srv_print_thread_releases) {
756
745
                fprintf(stderr,
757
 
                        "Suspending thread %lu to slot %lu\n",
758
 
                        (ulong) os_thread_get_curr_id(), (ulong) slot_no);
 
746
                        "Suspending thread %lu to slot %lu meter %lu\n",
 
747
                        (ulong) os_thread_get_curr_id(), (ulong) slot_no,
 
748
                        (ulong) srv_meter[SRV_RECOVERY]);
759
749
        }
760
750
 
761
751
        slot = srv_table_get_nth_slot(slot_no);
782
772
/*************************************************************************
783
773
Releases threads of the type given from suspension in the thread table.
784
774
NOTE! The server mutex has to be reserved by the caller! */
785
 
UNIV_INTERN
 
775
 
786
776
ulint
787
777
srv_release_threads(
788
778
/*================*/
789
 
                                        /* out: number of threads
790
 
                                        released: this may be < n if
791
 
                                        not enough threads were
792
 
                                        suspended at the moment */
793
 
        enum srv_thread_type    type,   /* in: thread type */
794
 
        ulint                   n)      /* in: number of threads to release */
 
779
                        /* out: number of threads released: this may be
 
780
                        < n if not enough threads were suspended at the
 
781
                        moment */
 
782
        ulint   type,   /* in: thread type */
 
783
        ulint   n)      /* in: number of threads to release */
795
784
{
796
785
        srv_slot_t*     slot;
797
786
        ulint           i;
817
806
                        if (srv_print_thread_releases) {
818
807
                                fprintf(stderr,
819
808
                                        "Releasing thread %lu type %lu"
820
 
                                        " from slot %lu\n",
 
809
                                        " from slot %lu meter %lu\n",
821
810
                                        (ulong) slot->id, (ulong) type,
822
 
                                        (ulong) i);
 
811
                                        (ulong) i,
 
812
                                        (ulong) srv_meter[SRV_RECOVERY]);
823
813
                        }
824
814
 
825
815
                        count++;
835
825
 
836
826
/*************************************************************************
837
827
Returns the calling thread type. */
838
 
UNIV_INTERN
839
 
enum srv_thread_type
 
828
 
 
829
ulint
840
830
srv_get_thread_type(void)
841
831
/*=====================*/
842
832
                        /* out: SRV_COM, ... */
843
833
{
844
 
        ulint                   slot_no;
845
 
        srv_slot_t*             slot;
846
 
        enum srv_thread_type    type;
 
834
        ulint           slot_no;
 
835
        srv_slot_t*     slot;
 
836
        ulint           type;
847
837
 
848
838
        mutex_enter(&kernel_mutex);
849
839
 
863
853
 
864
854
/*************************************************************************
865
855
Initializes the server. */
866
 
UNIV_INTERN
 
856
 
867
857
void
868
858
srv_init(void)
869
859
/*==========*/
905
895
        for (i = 0; i < SRV_MASTER + 1; i++) {
906
896
                srv_n_threads_active[i] = 0;
907
897
                srv_n_threads[i] = 0;
908
 
#if 0
909
898
                srv_meter[i] = 30;
910
899
                srv_meter_low_water[i] = 50;
911
900
                srv_meter_high_water[i] = 100;
912
901
                srv_meter_high_water2[i] = 200;
913
902
                srv_meter_foreground[i] = 250;
914
 
#endif
915
903
        }
916
904
 
917
905
        UT_LIST_INIT(srv_sys->tasks);
924
912
 
925
913
        srv_sys->dummy_ind1 = dict_mem_index_create(
926
914
                "SYS_DUMMY1", "SYS_DUMMY1", DICT_HDR_SPACE, 0, 1);
927
 
        dict_index_add_col(srv_sys->dummy_ind1, table,
 
915
        dict_index_add_col(srv_sys->dummy_ind1, table, (dict_col_t*)
928
916
                           dict_table_get_nth_col(table, 0), 0);
929
917
        srv_sys->dummy_ind1->table = table;
930
918
        /* create dummy table and index for new-style infimum and supremum */
934
922
                               DATA_ENGLISH | DATA_NOT_NULL, 8);
935
923
        srv_sys->dummy_ind2 = dict_mem_index_create(
936
924
                "SYS_DUMMY2", "SYS_DUMMY2", DICT_HDR_SPACE, 0, 1);
937
 
        dict_index_add_col(srv_sys->dummy_ind2, table,
 
925
        dict_index_add_col(srv_sys->dummy_ind2, table, (dict_col_t*)
938
926
                           dict_table_get_nth_col(table, 0), 0);
939
927
        srv_sys->dummy_ind2->table = table;
940
928
 
955
943
                conc_slot->event = os_event_create(NULL);
956
944
                ut_a(conc_slot->event);
957
945
        }
958
 
 
959
 
        /* Initialize some INFORMATION SCHEMA internal structures */
960
 
        trx_i_s_cache_init(trx_i_s_cache);
961
946
}
962
947
 
963
948
/*************************************************************************
964
949
Frees the OS fast mutex created in srv_init(). */
965
 
UNIV_INTERN
 
950
 
966
951
void
967
952
srv_free(void)
968
953
/*==========*/
973
958
/*************************************************************************
974
959
Initializes the synchronization primitives, memory system, and the thread
975
960
local storage. */
976
 
UNIV_INTERN
 
961
 
977
962
void
978
963
srv_general_init(void)
979
964
/*==================*/
987
972
/*======================= InnoDB Server FIFO queue =======================*/
988
973
 
989
974
/* Maximum allowable purge history length.  <=0 means 'infinite'. */
990
 
UNIV_INTERN ulong       srv_max_purge_lag               = 0;
 
975
ulong   srv_max_purge_lag               = 0;
991
976
 
992
977
/*************************************************************************
993
978
Puts an OS thread to wait if there are too many concurrent threads
994
979
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */
995
 
UNIV_INTERN
 
980
 
996
981
void
997
982
srv_conc_enter_innodb(
998
983
/*==================*/
1006
991
        if (trx->mysql_thd != NULL
1007
992
            && thd_is_replication_slave_thread(trx->mysql_thd)) {
1008
993
 
1009
 
                UT_WAIT_FOR(srv_conc_n_threads
1010
 
                            < (lint)srv_thread_concurrency,
1011
 
                            srv_replication_delay * 1000);
1012
 
 
 
994
                /* TODO Do something more interesting (based on a config
 
995
                parameter). Some users what to give the replication
 
996
                thread very low priority, see http://bugs.mysql.com/25078
 
997
                This can be done by introducing
 
998
                innodb_replication_delay(ms) config parameter */
1013
999
                return;
1014
1000
        }
1015
1001
 
1150
1136
/*************************************************************************
1151
1137
This lets a thread enter InnoDB regardless of the number of threads inside
1152
1138
InnoDB. This must be called when a thread ends a lock wait. */
1153
 
UNIV_INTERN
 
1139
 
1154
1140
void
1155
1141
srv_conc_force_enter_innodb(
1156
1142
/*========================*/
1174
1160
/*************************************************************************
1175
1161
This must be called when a thread exits InnoDB in a lock wait or at the
1176
1162
end of an SQL statement. */
1177
 
UNIV_INTERN
 
1163
 
1178
1164
void
1179
1165
srv_conc_force_exit_innodb(
1180
1166
/*=======================*/
1234
1220
 
1235
1221
/*************************************************************************
1236
1222
This must be called when a thread exits InnoDB. */
1237
 
UNIV_INTERN
 
1223
 
1238
1224
void
1239
1225
srv_conc_exit_innodb(
1240
1226
/*=================*/
1282
1268
 
1283
1269
        srv_log_buffer_size = srv_log_buffer_size / UNIV_PAGE_SIZE;
1284
1270
 
1285
 
        srv_lock_table_size = 5 * (srv_buf_pool_size / UNIV_PAGE_SIZE);
 
1271
        srv_pool_size = srv_pool_size / (UNIV_PAGE_SIZE / 1024);
 
1272
 
 
1273
        srv_awe_window_size = srv_awe_window_size / UNIV_PAGE_SIZE;
 
1274
 
 
1275
        if (srv_use_awe) {
 
1276
                /* If we are using AWE we must save memory in the 32-bit
 
1277
                address space of the process, and cannot bind the lock
 
1278
                table size to the real buffer pool size. */
 
1279
 
 
1280
                srv_lock_table_size = 20 * srv_awe_window_size;
 
1281
        } else {
 
1282
                srv_lock_table_size = 5 * srv_pool_size;
 
1283
        }
1286
1284
 
1287
1285
        return(DB_SUCCESS);
1288
1286
}
1289
1287
 
1290
1288
/*************************************************************************
1291
1289
Boots the InnoDB server. */
1292
 
UNIV_INTERN
 
1290
 
1293
1291
ulint
1294
1292
srv_boot(void)
1295
1293
/*==========*/
1391
1389
!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK
1392
1390
are possible errors. DB_DEADLOCK is returned if selective deadlock
1393
1391
resolution chose this transaction as a victim. */
1394
 
UNIV_INTERN
 
1392
 
1395
1393
void
1396
1394
srv_suspend_mysql_thread(
1397
1395
/*=====================*/
1403
1401
        os_event_t      event;
1404
1402
        double          wait_time;
1405
1403
        trx_t*          trx;
1406
 
        ulint           had_dict_lock;
 
1404
        ibool           had_dict_lock                   = FALSE;
1407
1405
        ibool           was_declared_inside_innodb      = FALSE;
1408
 
        ib_int64_t      start_time                      = 0;
1409
 
        ib_int64_t      finish_time;
 
1406
        ib_longlong     start_time                      = 0;
 
1407
        ib_longlong     finish_time;
1410
1408
        ulint           diff_time;
1411
1409
        ulint           sec;
1412
1410
        ulint           ms;
1456
1454
                srv_n_lock_wait_current_count++;
1457
1455
 
1458
1456
                ut_usectime(&sec, &ms);
1459
 
                start_time = (ib_int64_t)sec * 1000000 + ms;
 
1457
                start_time = (ib_longlong)sec * 1000000 + ms;
1460
1458
        }
1461
1459
        /* Wake the lock timeout monitor thread, if it is suspended */
1462
1460
 
1475
1473
                srv_conc_force_exit_innodb(trx);
1476
1474
        }
1477
1475
 
1478
 
        had_dict_lock = trx->dict_operation_lock_mode;
1479
 
 
1480
 
        switch (had_dict_lock) {
1481
 
        case RW_S_LATCH:
1482
 
                /* Release foreign key check latch */
 
1476
        /* Release possible foreign key check latch */
 
1477
        if (trx->dict_operation_lock_mode == RW_S_LATCH) {
 
1478
 
 
1479
                had_dict_lock = TRUE;
 
1480
 
1483
1481
                row_mysql_unfreeze_data_dictionary(trx);
1484
 
                break;
1485
 
        case RW_X_LATCH:
1486
 
                /* Release fast index creation latch */
1487
 
                row_mysql_unlock_data_dictionary(trx);
1488
 
                break;
1489
1482
        }
1490
1483
 
1491
1484
        ut_a(trx->dict_operation_lock_mode == 0);
1494
1487
 
1495
1488
        os_event_wait(event);
1496
1489
 
1497
 
        switch (had_dict_lock) {
1498
 
        case RW_S_LATCH:
 
1490
        if (had_dict_lock) {
 
1491
 
1499
1492
                row_mysql_freeze_data_dictionary(trx);
1500
 
                break;
1501
 
        case RW_X_LATCH:
1502
 
                row_mysql_lock_data_dictionary(trx);
1503
 
                break;
1504
1493
        }
1505
1494
 
1506
1495
        if (was_declared_inside_innodb) {
1520
1509
 
1521
1510
        if (thr->lock_state == QUE_THR_LOCK_ROW) {
1522
1511
                ut_usectime(&sec, &ms);
1523
 
                finish_time = (ib_int64_t)sec * 1000000 + ms;
 
1512
                finish_time = (ib_longlong)sec * 1000000 + ms;
1524
1513
 
1525
1514
                diff_time = (ulint) (finish_time - start_time);
1526
1515
 
1555
1544
/************************************************************************
1556
1545
Releases a MySQL OS thread waiting for a lock to be released, if the
1557
1546
thread is already suspended. */
1558
 
UNIV_INTERN
 
1547
 
1559
1548
void
1560
1549
srv_release_mysql_thread_if_suspended(
1561
1550
/*==================================*/
1621
1610
 
1622
1611
/**********************************************************************
1623
1612
Outputs to a file the output of the InnoDB Monitor. */
1624
 
UNIV_INTERN
 
1613
 
1625
1614
void
1626
1615
srv_printf_innodb_monitor(
1627
1616
/*======================*/
1733
1722
        fprintf(file, "Dictionary memory allocated " ULINTPF "\n",
1734
1723
                dict_sys->size);
1735
1724
 
 
1725
        if (srv_use_awe) {
 
1726
                fprintf(file,
 
1727
                        "In addition to that %lu MB of AWE memory allocated\n",
 
1728
                        (ulong) (srv_pool_size
 
1729
                                 / ((1024 * 1024) / UNIV_PAGE_SIZE)));
 
1730
        }
 
1731
 
1736
1732
        buf_print_io(file);
1737
1733
 
1738
1734
        fputs("--------------\n"
1797
1793
 
1798
1794
/**********************************************************************
1799
1795
Function to pass InnoDB status variables to MySQL */
1800
 
UNIV_INTERN
 
1796
 
1801
1797
void
1802
1798
srv_export_innodb_status(void)
1803
1799
{
1833
1829
                = buf_get_latched_pages_number();
1834
1830
        export_vars.innodb_buffer_pool_pages_total = buf_pool->curr_size;
1835
1831
 
1836
 
        export_vars.innodb_buffer_pool_pages_misc = buf_pool->curr_size
 
1832
        export_vars.innodb_buffer_pool_pages_misc = buf_pool->max_size
1837
1833
                - UT_LIST_GET_LEN(buf_pool->LRU)
1838
1834
                - UT_LIST_GET_LEN(buf_pool->free);
1839
1835
        export_vars.innodb_page_size = UNIV_PAGE_SIZE;
1872
1868
/*************************************************************************
1873
1869
A thread which wakes up threads whose lock wait may have lasted too long.
1874
1870
This also prints the info output by various InnoDB monitors. */
1875
 
UNIV_INTERN
 
1871
 
1876
1872
os_thread_ret_t
1877
1873
srv_lock_timeout_and_monitor_thread(
1878
1874
/*================================*/
1908
1904
 
1909
1905
        os_thread_sleep(1000000);
1910
1906
 
 
1907
        /* In case mutex_exit is not a memory barrier, it is
 
1908
        theoretically possible some threads are left waiting though
 
1909
        the semaphore is already released. Wake up those threads: */
 
1910
 
 
1911
        sync_arr_wake_threads_if_sema_free();
 
1912
 
1911
1913
        current_time = time(NULL);
1912
1914
 
1913
1915
        time_elapsed = difftime(current_time, last_monitor_time);
2053
2055
/*************************************************************************
2054
2056
A thread which prints warnings about semaphore waits which have lasted
2055
2057
too long. These can be used to track bugs which cause hangs. */
2056
 
UNIV_INTERN
 
2058
 
2057
2059
os_thread_ret_t
2058
2060
srv_error_monitor_thread(
2059
2061
/*=====================*/
2063
2065
                        os_thread_create */
2064
2066
{
2065
2067
        /* number of successive fatal timeouts observed */
2066
 
        ulint           fatal_cnt       = 0;
2067
 
        ib_uint64_t     old_lsn;
2068
 
        ib_uint64_t     new_lsn;
 
2068
        ulint   fatal_cnt       = 0;
 
2069
        dulint  old_lsn;
 
2070
        dulint  new_lsn;
2069
2071
 
2070
2072
        old_lsn = srv_start_lsn;
2071
2073
 
2081
2083
 
2082
2084
        new_lsn = log_get_lsn();
2083
2085
 
2084
 
        if (new_lsn < old_lsn) {
 
2086
        if (ut_dulint_cmp(new_lsn, old_lsn) < 0) {
2085
2087
                ut_print_timestamp(stderr);
2086
2088
                fprintf(stderr,
2087
 
                        "  InnoDB: Error: old log sequence number %"PRIu64""
 
2089
                        "  InnoDB: Error: old log sequence number %lu %lu"
2088
2090
                        " was greater\n"
2089
 
                        "InnoDB: than the new log sequence number %"PRIu64"!\n"
 
2091
                        "InnoDB: than the new log sequence number %lu %lu!\n"
2090
2092
                        "InnoDB: Please submit a bug report"
2091
2093
                        " to http://bugs.mysql.com\n",
2092
 
                        old_lsn, new_lsn);
 
2094
                        (ulong) ut_dulint_get_high(old_lsn),
 
2095
                        (ulong) ut_dulint_get_low(old_lsn),
 
2096
                        (ulong) ut_dulint_get_high(new_lsn),
 
2097
                        (ulong) ut_dulint_get_low(new_lsn));
2093
2098
        }
2094
2099
 
2095
2100
        old_lsn = new_lsn;
2101
2106
                srv_refresh_innodb_monitor_stats();
2102
2107
        }
2103
2108
 
2104
 
        /* Update the statistics collected for deciding LRU
2105
 
        eviction policy. */
2106
 
        buf_LRU_stat_update();
2107
 
 
2108
 
        /* In case mutex_exit is not a memory barrier, it is
2109
 
        theoretically possible some threads are left waiting though
2110
 
        the semaphore is already released. Wake up those threads: */
2111
 
        
2112
 
        sync_arr_wake_threads_if_sema_free();
2113
 
 
2114
2109
        if (sync_array_print_long_waits()) {
2115
2110
                fatal_cnt++;
2116
 
                if (fatal_cnt > 10) {
 
2111
                if (fatal_cnt > 5) {
2117
2112
 
2118
2113
                        fprintf(stderr,
2119
2114
                                "InnoDB: Error: semaphore wait has lasted"
2133
2128
 
2134
2129
        fflush(stderr);
2135
2130
 
2136
 
        os_thread_sleep(1000000);
 
2131
        os_thread_sleep(2000000);
2137
2132
 
2138
2133
        if (srv_shutdown_state < SRV_SHUTDOWN_CLEANUP) {
2139
2134
 
2156
2151
in the MySQL interface. Note that there is a small chance that the master
2157
2152
thread stays suspended (we do not protect our operation with the kernel
2158
2153
mutex, for performace reasons). */
2159
 
UNIV_INTERN
 
2154
 
2160
2155
void
2161
2156
srv_active_wake_master_thread(void)
2162
2157
/*===============================*/
2175
2170
 
2176
2171
/***********************************************************************
2177
2172
Wakes up the master thread if it is suspended or being suspended. */
2178
 
UNIV_INTERN
 
2173
 
2179
2174
void
2180
2175
srv_wake_master_thread(void)
2181
2176
/*========================*/
2191
2186
 
2192
2187
/*************************************************************************
2193
2188
The master thread controlling the server. */
2194
 
UNIV_INTERN
 
2189
 
2195
2190
os_thread_ret_t
2196
2191
srv_master_thread(
2197
2192
/*==============*/
2204
2199
        time_t          last_flush_time;
2205
2200
        time_t          current_time;
2206
2201
        ulint           old_activity_count;
2207
 
        ulint           n_pages_purged  = 0;
 
2202
        ulint           n_pages_purged;
2208
2203
        ulint           n_bytes_merged;
2209
2204
        ulint           n_pages_flushed;
2210
2205
        ulint           n_bytes_archived;
2320
2315
                        buffer pool under the limit wished by the user */
2321
2316
 
2322
2317
                        n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
2323
 
                                                          IB_ULONGLONG_MAX);
 
2318
                                                          ut_dulint_max);
2324
2319
 
2325
2320
                        /* If we had to do the flush, it may have taken
2326
2321
                        even more than 1 second, and also, there may be more
2357
2352
        if (n_pend_ios < 3 && (n_ios - n_ios_very_old < 200)) {
2358
2353
 
2359
2354
                srv_main_thread_op_info = "flushing buffer pool pages";
2360
 
                buf_flush_batch(BUF_FLUSH_LIST, 100, IB_ULONGLONG_MAX);
 
2355
                buf_flush_batch(BUF_FLUSH_LIST, 100, ut_dulint_max);
2361
2356
 
2362
2357
                srv_main_thread_op_info = "flushing log";
2363
2358
                log_buffer_flush_to_disk();
2375
2370
        /* We run a full purge every 10 seconds, even if the server
2376
2371
        were active */
2377
2372
 
 
2373
        n_pages_purged = 1;
 
2374
 
2378
2375
        last_flush_time = time(NULL);
2379
2376
 
2380
 
        do {
 
2377
        while (n_pages_purged) {
2381
2378
 
2382
2379
                if (srv_fast_shutdown && srv_shutdown_state > 0) {
2383
2380
 
2395
2392
                        log_buffer_flush_to_disk();
2396
2393
                        last_flush_time = current_time;
2397
2394
                }
2398
 
        } while (n_pages_purged);
 
2395
        }
2399
2396
 
2400
2397
        srv_main_thread_op_info = "flushing buffer pool pages";
2401
2398
 
2408
2405
                the time it requires to flush 100 pages */
2409
2406
 
2410
2407
                n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
2411
 
                                                  IB_ULONGLONG_MAX);
 
2408
                                                  ut_dulint_max);
2412
2409
        } else {
2413
2410
                /* Otherwise, we only flush a small number of pages so that
2414
2411
                we do not unnecessarily use much disk i/o capacity from
2415
2412
                other work */
2416
2413
 
2417
2414
                n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 10,
2418
 
                                                  IB_ULONGLONG_MAX);
 
2415
                                                  ut_dulint_max);
2419
2416
        }
2420
2417
 
2421
2418
        srv_main_thread_op_info = "making checkpoint";
2466
2463
 
2467
2464
        /* Run a full purge */
2468
2465
 
 
2466
        n_pages_purged = 1;
 
2467
 
2469
2468
        last_flush_time = time(NULL);
2470
2469
 
2471
 
        do {
 
2470
        while (n_pages_purged) {
2472
2471
                if (srv_fast_shutdown && srv_shutdown_state > 0) {
2473
2472
 
2474
2473
                        break;
2485
2484
                        log_buffer_flush_to_disk();
2486
2485
                        last_flush_time = current_time;
2487
2486
                }
2488
 
        } while (n_pages_purged);
 
2487
        }
2489
2488
 
2490
2489
        srv_main_thread_op_info = "reserving kernel mutex";
2491
2490
 
2519
2518
 
2520
2519
        if (srv_fast_shutdown < 2) {
2521
2520
                n_pages_flushed = buf_flush_batch(BUF_FLUSH_LIST, 100,
2522
 
                                                  IB_ULONGLONG_MAX);
 
2521
                                                  ut_dulint_max);
2523
2522
        } else {
2524
2523
                /* In the fastest shutdown we do not flush the buffer pool
2525
2524
                to data files: we set n_pages_flushed to 0 artificially. */