~drizzle-trunk/drizzle/development

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