~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.
4
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
8
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
17
*****************************************************************************/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
18
/*****************************************************************************
19
20
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
21
Copyright (c) 2009, Google Inc.
22
23
Portions of this file contain modifications contributed and copyrighted by
24
Google, Inc. Those modifications are gratefully acknowledged and are described
25
briefly in the InnoDB documentation. The contributions by Google are
26
incorporated with their permission, and subject to the conditions contained in
27
the file COPYING.Google.
28
29
This program is free software; you can redistribute it and/or modify it under
30
the terms of the GNU General Public License as published by the Free Software
31
Foundation; version 2 of the License.
32
33
This program is distributed in the hope that it will be useful, but WITHOUT
34
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
35
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
36
37
You should have received a copy of the GNU General Public License along with
38
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
39
Place, Suite 330, Boston, MA 02111-1307 USA
40
41
*****************************************************************************/
42
43
/**************************************************//**
44
@file include/log0log.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
45
Database log
46
47
Created 12/9/1995 Heikki Tuuri
48
*******************************************************/
49
50
#ifndef log0log_h
51
#define log0log_h
52
53
#include "univ.i"
54
#include "ut0byte.h"
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
55
#include "ut0lst.h"
56
#ifndef UNIV_HOTBACKUP
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
57
#include "sync0sync.h"
58
#include "sync0rw.h"
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
59
#endif /* !UNIV_HOTBACKUP */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
60
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
61
/** Redo log buffer */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
62
typedef struct log_struct	log_t;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
63
/** Redo log group */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
64
typedef struct log_group_struct	log_group_t;
65
66
#ifdef UNIV_DEBUG
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
67
/** Flag: write to log file? */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
68
extern	ibool	log_do_write;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
69
/** Flag: enable debug output when writing to the log? */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
70
extern	ibool	log_debug_writes;
71
#else /* UNIV_DEBUG */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
72
/** Write to log */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
73
# define log_do_write TRUE
74
#endif /* UNIV_DEBUG */
75
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
76
/** Wait modes for log_write_up_to @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
77
#define LOG_NO_WAIT		91
78
#define LOG_WAIT_ONE_GROUP	92
79
#define	LOG_WAIT_ALL_GROUPS	93
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
80
/* @} */
81
/** Maximum number of log groups in log_group_struct::checkpoint_buf */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
82
#define LOG_MAX_N_GROUPS	32
83
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
84
#ifndef UNIV_HOTBACKUP
85
/****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
86
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
87
so that we know that the limit has been written to a log checkpoint field
88
on disk. */
89
UNIV_INTERN
90
void
91
log_fsp_current_free_limit_set_and_checkpoint(
92
/*==========================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
93
	ulint	limit);	/*!< in: limit to set */
94
#endif /* !UNIV_HOTBACKUP */
95
/*******************************************************************//**
96
Calculates where in log files we find a specified lsn.
97
@return	log file number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
98
UNIV_INTERN
99
ulint
100
log_calc_where_lsn_is(
101
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
102
	ib_int64_t*	log_file_offset,	/*!< out: offset in that file
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
103
						(including the header) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
104
	ib_uint64_t	first_header_lsn,	/*!< in: first log file start
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
105
						lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
106
	ib_uint64_t	lsn,			/*!< in: lsn whose position to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
107
						determine */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
108
	ulint		n_log_files,		/*!< in: total number of log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
109
						files */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
110
	ib_int64_t	log_file_size);		/*!< in: log file size
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
111
						(including the header) */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
112
#ifndef UNIV_HOTBACKUP
113
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
114
Writes to the log the string given. The log must be released with
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
115
log_release.
116
@return	end lsn of the log record, zero if did not succeed */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
117
UNIV_INLINE
118
ib_uint64_t
119
log_reserve_and_write_fast(
120
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
121
	byte*		str,	/*!< in: string */
122
	ulint		len,	/*!< in: string length */
123
	ib_uint64_t*	start_lsn,/*!< out: start lsn of the log record */
124
	ibool*		success);/*!< out: TRUE if success */
125
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
126
Releases the log mutex. */
127
UNIV_INLINE
128
void
129
log_release(void);
130
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
131
/***********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
132
Checks if there is need for a log buffer flush or a new checkpoint, and does
133
this if yes. Any database operation should call this when it has modified
134
more than about 4 pages. NOTE that this function may only be called when the
135
OS thread owns no synchronization objects except the dictionary mutex. */
136
UNIV_INLINE
137
void
138
log_free_check(void);
139
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
140
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
141
Opens the log for log_write_low. The log must be closed with log_close and
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
142
released with log_release.
143
@return	start lsn of the log record */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
144
UNIV_INTERN
145
ib_uint64_t
146
log_reserve_and_open(
147
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
148
	ulint	len);	/*!< in: length of data to be catenated */
149
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
150
Writes to the log the string given. It is assumed that the caller holds the
151
log mutex. */
152
UNIV_INTERN
153
void
154
log_write_low(
155
/*==========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
156
	byte*	str,		/*!< in: string */
157
	ulint	str_len);	/*!< in: string length */
158
/************************************************************//**
159
Closes the log.
160
@return	lsn */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
161
UNIV_INTERN
162
ib_uint64_t
163
log_close(void);
164
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
165
/************************************************************//**
166
Gets the current lsn.
167
@return	current lsn */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
168
UNIV_INLINE
169
ib_uint64_t
170
log_get_lsn(void);
171
/*=============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
172
/****************************************************************
173
Gets the log group capacity. It is OK to read the value without
174
holding log_sys->mutex because it is constant.
175
@return	log group capacity */
176
UNIV_INLINE
177
ulint
178
log_get_capacity(void);
179
/*==================*/
180
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
181
Initializes the log. */
182
UNIV_INTERN
183
void
184
log_init(void);
185
/*==========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
186
/******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
187
Inits a log group to the log system. */
188
UNIV_INTERN
189
void
190
log_group_init(
191
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
192
	ulint	id,			/*!< in: group id */
193
	ulint	n_files,		/*!< in: number of log files */
194
	ulint	file_size,		/*!< in: log file size in bytes */
195
	ulint	space_id,		/*!< in: space id of the file space
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
196
					which contains the log files of this
197
					group */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
198
	ulint	archive_space_id);	/*!< in: space id of the file space
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
199
					which contains some archived log
200
					files for this group; currently, only
201
					for the first log group this is
202
					used */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
203
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
204
Completes an i/o to a log file. */
205
UNIV_INTERN
206
void
207
log_io_complete(
208
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
209
	log_group_t*	group);	/*!< in: log group */
210
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
211
This function is called, e.g., when a transaction wants to commit. It checks
212
that the log has been written to the log file up to the last log entry written
213
by the transaction. If there is a flush running, it waits and checks if the
214
flush flushed enough. If not, starts a new flush. */
215
UNIV_INTERN
216
void
217
log_write_up_to(
218
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
219
	ib_uint64_t	lsn,	/*!< in: log sequence number up to which
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
220
				the log should be written,
221
				IB_ULONGLONG_MAX if not specified */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
222
	ulint		wait,	/*!< in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
223
				or LOG_WAIT_ALL_GROUPS */
224
	ibool		flush_to_disk);
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
225
				/*!< in: TRUE if we want the written log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
226
				also to be flushed to disk */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
227
/****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
228
Does a syncronous flush of the log buffer to disk. */
229
UNIV_INTERN
230
void
231
log_buffer_flush_to_disk(void);
232
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
233
/****************************************************************//**
234
This functions writes the log buffer to the log file and if 'flush'
235
is set it forces a flush of the log file as well. This is meant to be
236
called from background master thread only as it does not wait for
237
the write (+ possible flush) to finish. */
238
UNIV_INTERN
239
void
240
log_buffer_sync_in_background(
241
/*==========================*/
242
	ibool	flush);	/*<! in: flush the logs to disk */
243
/****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
244
Advances the smallest lsn for which there are unflushed dirty blocks in the
245
buffer pool and also may make a new checkpoint. NOTE: this function may only
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
246
be called if the calling thread owns no synchronization objects!
247
@return FALSE if there was a flush batch of the same type running,
248
which means that we could not start this flush batch */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
249
UNIV_INTERN
250
ibool
251
log_preflush_pool_modified_pages(
252
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
253
	ib_uint64_t	new_oldest,	/*!< in: try to advance
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
254
					oldest_modified_lsn at least
255
					to this lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
256
	ibool		sync);		/*!< in: TRUE if synchronous
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
257
					operation is desired */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
258
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
259
Makes a checkpoint. Note that this function does not flush dirty
260
blocks from the buffer pool: it only checks what is lsn of the oldest
261
modification in the pool, and writes information about the lsn in
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
262
log files. Use log_make_checkpoint_at to flush also the pool.
263
@return	TRUE if success, FALSE if a checkpoint write was already running */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
264
UNIV_INTERN
265
ibool
266
log_checkpoint(
267
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
268
	ibool	sync,		/*!< in: TRUE if synchronous operation is
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
269
				desired */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
270
	ibool	write_always);	/*!< in: the function normally checks if the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
271
				the new checkpoint would have a greater
272
				lsn than the previous one: if not, then no
273
				physical write is done; by setting this
274
				parameter TRUE, a physical write will always be
275
				made to log files */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
276
/****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
277
Makes a checkpoint at a given lsn or later. */
278
UNIV_INTERN
279
void
280
log_make_checkpoint_at(
281
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
282
	ib_uint64_t	lsn,		/*!< in: make a checkpoint at this or a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
283
					later lsn, if IB_ULONGLONG_MAX, makes
284
					a checkpoint at the latest lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
285
	ibool		write_always);	/*!< in: the function normally checks if
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
286
					the the new checkpoint would have a
287
					greater lsn than the previous one: if
288
					not, then no physical write is done;
289
					by setting this parameter TRUE, a
290
					physical write will always be made to
291
					log files */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
292
/****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
293
Makes a checkpoint at the latest lsn and writes it to first page of each
294
data file in the database, so that we know that the file spaces contain
295
all modifications up to that lsn. This can only be called at database
296
shutdown. This function also writes all log in log files to the log archive. */
297
UNIV_INTERN
298
void
299
logs_empty_and_mark_files_at_shutdown(void);
300
/*=======================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
301
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
302
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. */
303
UNIV_INTERN
304
void
305
log_group_read_checkpoint_info(
306
/*===========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
307
	log_group_t*	group,	/*!< in: log group */
308
	ulint		field);	/*!< in: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2 */
309
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
310
Gets info from a checkpoint about a log group. */
311
UNIV_INTERN
312
void
313
log_checkpoint_get_nth_group_info(
314
/*==============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
315
	const byte*	buf,	/*!< in: buffer containing checkpoint info */
316
	ulint		n,	/*!< in: nth slot */
317
	ulint*		file_no,/*!< out: archived file number */
318
	ulint*		offset);/*!< out: archived file offset */
319
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
320
Writes checkpoint info to groups. */
321
UNIV_INTERN
322
void
323
log_groups_write_checkpoint_info(void);
324
/*==================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
325
/********************************************************************//**
326
Starts an archiving operation.
327
@return	TRUE if succeed, FALSE if an archiving operation was already running */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
328
UNIV_INTERN
329
ibool
330
log_archive_do(
331
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
332
	ibool	sync,	/*!< in: TRUE if synchronous operation is desired */
333
	ulint*	n_bytes);/*!< out: archive log buffer size, 0 if nothing to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
334
			archive */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
335
/****************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
336
Writes the log contents to the archive up to the lsn when this function was
337
called, and stops the archiving. When archiving is started again, the archived
338
log file numbers start from a number one higher, so that the archiving will
339
not write again to the archived log files which exist when this function
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
340
returns.
341
@return	DB_SUCCESS or DB_ERROR */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
342
UNIV_INTERN
343
ulint
344
log_archive_stop(void);
345
/*==================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
346
/****************************************************************//**
347
Starts again archiving which has been stopped.
348
@return	DB_SUCCESS or DB_ERROR */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
349
UNIV_INTERN
350
ulint
351
log_archive_start(void);
352
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
353
/****************************************************************//**
354
Stop archiving the log so that a gap may occur in the archived log files.
355
@return	DB_SUCCESS or DB_ERROR */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
356
UNIV_INTERN
357
ulint
358
log_archive_noarchivelog(void);
359
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
360
/****************************************************************//**
361
Start archiving the log so that a gap may occur in the archived log files.
362
@return	DB_SUCCESS or DB_ERROR */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
363
UNIV_INTERN
364
ulint
365
log_archive_archivelog(void);
366
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
367
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
368
Generates an archived log file name. */
369
UNIV_INTERN
370
void
371
log_archived_file_name_gen(
372
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
373
	char*	buf,	/*!< in: buffer where to write */
374
	ulint	id,	/*!< in: group id */
375
	ulint	file_no);/*!< in: file number */
376
#else /* !UNIV_HOTBACKUP */
377
/******************************************************//**
378
Writes info to a buffer of a log group when log files are created in
379
backup restoration. */
380
UNIV_INTERN
381
void
382
log_reset_first_header_and_checkpoint(
383
/*==================================*/
384
	byte*		hdr_buf,/*!< in: buffer which will be written to the
385
				start of the first log file */
386
	ib_uint64_t	start);	/*!< in: lsn of the start of the first log file;
387
				we pretend that there is a checkpoint at
388
				start + LOG_BLOCK_HDR_SIZE */
389
#endif /* !UNIV_HOTBACKUP */
390
/********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
391
Checks that there is enough free space in the log to start a new query step.
392
Flushes the log buffer or makes a new checkpoint if necessary. NOTE: this
393
function may only be called if the calling thread owns no synchronization
394
objects! */
395
UNIV_INTERN
396
void
397
log_check_margins(void);
398
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
399
#ifndef UNIV_HOTBACKUP
400
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
401
Reads a specified log segment to a buffer. */
402
UNIV_INTERN
403
void
404
log_group_read_log_seg(
405
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
406
	ulint		type,		/*!< in: LOG_ARCHIVE or LOG_RECOVER */
407
	byte*		buf,		/*!< in: buffer where to read */
408
	log_group_t*	group,		/*!< in: log group */
409
	ib_uint64_t	start_lsn,	/*!< in: read area start */
410
	ib_uint64_t	end_lsn);	/*!< in: read area end */
411
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
412
Writes a buffer to a log file group. */
413
UNIV_INTERN
414
void
415
log_group_write_buf(
416
/*================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
417
	log_group_t*	group,		/*!< in: log group */
418
	byte*		buf,		/*!< in: buffer */
419
	ulint		len,		/*!< in: buffer len; must be divisible
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
420
					by OS_FILE_LOG_BLOCK_SIZE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
421
	ib_uint64_t	start_lsn,	/*!< in: start lsn of the buffer; must
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
422
					be divisible by
423
					OS_FILE_LOG_BLOCK_SIZE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
424
	ulint		new_data_offset);/*!< in: start offset of new data in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
425
					buf: this parameter is used to decide
426
					if we have to write a new log file
427
					header */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
428
/********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
429
Sets the field values in group to correspond to a given lsn. For this function
430
to work, the values must already be correctly initialized to correspond to
431
some lsn, for instance, a checkpoint lsn. */
432
UNIV_INTERN
433
void
434
log_group_set_fields(
435
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
436
	log_group_t*	group,	/*!< in/out: group */
437
	ib_uint64_t	lsn);	/*!< in: lsn for which the values should be
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
438
				set */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
439
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
440
Calculates the data capacity of a log group, when the log file headers are not
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
441
included.
442
@return	capacity in bytes */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
443
UNIV_INTERN
444
ulint
445
log_group_get_capacity(
446
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
447
	const log_group_t*	group);	/*!< in: log group */
448
#endif /* !UNIV_HOTBACKUP */
449
/************************************************************//**
450
Gets a log block flush bit.
451
@return	TRUE if this block was the first to be written in a log flush */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
452
UNIV_INLINE
453
ibool
454
log_block_get_flush_bit(
455
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
456
	const byte*	log_block);	/*!< in: log block */
457
/************************************************************//**
458
Gets a log block number stored in the header.
459
@return	log block number stored in the block header */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
460
UNIV_INLINE
461
ulint
462
log_block_get_hdr_no(
463
/*=================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
464
	const byte*	log_block);	/*!< in: log block */
465
/************************************************************//**
466
Gets a log block data length.
467
@return	log block data length measured as a byte offset from the block start */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
468
UNIV_INLINE
469
ulint
470
log_block_get_data_len(
471
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
472
	const byte*	log_block);	/*!< in: log block */
473
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
474
Sets the log block data length. */
475
UNIV_INLINE
476
void
477
log_block_set_data_len(
478
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
479
	byte*	log_block,	/*!< in/out: log block */
480
	ulint	len);		/*!< in: data length */
481
/************************************************************//**
482
Calculates the checksum for a log block.
483
@return	checksum */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
484
UNIV_INLINE
485
ulint
486
log_block_calc_checksum(
487
/*====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
488
	const byte*	block);	/*!< in: log block */
489
/************************************************************//**
490
Gets a log block checksum field value.
491
@return	checksum */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
492
UNIV_INLINE
493
ulint
494
log_block_get_checksum(
495
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
496
	const byte*	log_block);	/*!< in: log block */
497
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
498
Sets a log block checksum field value. */
499
UNIV_INLINE
500
void
501
log_block_set_checksum(
502
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
503
	byte*	log_block,	/*!< in/out: log block */
504
	ulint	checksum);	/*!< in: checksum */
505
/************************************************************//**
506
Gets a log block first mtr log record group offset.
507
@return first mtr log record group byte offset from the block start, 0
508
if none */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
509
UNIV_INLINE
510
ulint
511
log_block_get_first_rec_group(
512
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
513
	const byte*	log_block);	/*!< in: log block */
514
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
515
Sets the log block first mtr log record group offset. */
516
UNIV_INLINE
517
void
518
log_block_set_first_rec_group(
519
/*==========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
520
	byte*	log_block,	/*!< in/out: log block */
521
	ulint	offset);	/*!< in: offset, 0 if none */
522
/************************************************************//**
523
Gets a log block checkpoint number field (4 lowest bytes).
524
@return	checkpoint no (4 lowest bytes) */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
525
UNIV_INLINE
526
ulint
527
log_block_get_checkpoint_no(
528
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
529
	const byte*	log_block);	/*!< in: log block */
530
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
531
Initializes a log block in the log buffer. */
532
UNIV_INLINE
533
void
534
log_block_init(
535
/*===========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
536
	byte*		log_block,	/*!< in: pointer to the log buffer */
537
	ib_uint64_t	lsn);		/*!< in: lsn within the log block */
538
/************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
539
Initializes a log block in the log buffer in the old, < 3.23.52 format, where
540
there was no checksum yet. */
541
UNIV_INLINE
542
void
543
log_block_init_in_old_format(
544
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
545
	byte*		log_block,	/*!< in: pointer to the log buffer */
546
	ib_uint64_t	lsn);		/*!< in: lsn within the log block */
547
/************************************************************//**
548
Converts a lsn to a log block number.
549
@return	log block number, it is > 0 and <= 1G */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
550
UNIV_INLINE
551
ulint
552
log_block_convert_lsn_to_no(
553
/*========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
554
	ib_uint64_t	lsn);	/*!< in: lsn of a byte within the block */
555
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
556
Prints info of the log. */
557
UNIV_INTERN
558
void
559
log_print(
560
/*======*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
561
	FILE*	file);	/*!< in: file where to print */
562
/******************************************************//**
563
Peeks the current lsn.
564
@return	TRUE if success, FALSE if could not get the log system mutex */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
565
UNIV_INTERN
566
ibool
567
log_peek_lsn(
568
/*=========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
569
	ib_uint64_t*	lsn);	/*!< out: if returns TRUE, current lsn is here */
570
/**********************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
571
Refreshes the statistics used to print per-second averages. */
572
UNIV_INTERN
573
void
574
log_refresh_stats(void);
575
/*===================*/
576
577
extern log_t*	log_sys;
578
579
/* Values used as flags */
580
#define LOG_FLUSH	7652559
581
#define LOG_CHECKPOINT	78656949
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
582
#ifdef UNIV_LOG_ARCHIVE
583
# define LOG_ARCHIVE	11122331
584
#endif /* UNIV_LOG_ARCHIVE */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
585
#define LOG_RECOVER	98887331
586
587
/* The counting of lsn's starts from this value: this must be non-zero */
588
#define LOG_START_LSN	((ib_uint64_t) (16 * OS_FILE_LOG_BLOCK_SIZE))
589
590
#define LOG_BUFFER_SIZE		(srv_log_buffer_size * UNIV_PAGE_SIZE)
591
#define LOG_ARCHIVE_BUF_SIZE	(srv_log_buffer_size * UNIV_PAGE_SIZE / 4)
592
593
/* Offsets of a log block header */
594
#define	LOG_BLOCK_HDR_NO	0	/* block number which must be > 0 and
595
					is allowed to wrap around at 2G; the
596
					highest bit is set to 1 if this is the
597
					first log block in a log flush write
598
					segment */
599
#define LOG_BLOCK_FLUSH_BIT_MASK 0x80000000UL
600
					/* mask used to get the highest bit in
601
					the preceding field */
602
#define	LOG_BLOCK_HDR_DATA_LEN	4	/* number of bytes of log written to
603
					this block */
604
#define	LOG_BLOCK_FIRST_REC_GROUP 6	/* offset of the first start of an
605
					mtr log record group in this log block,
606
					0 if none; if the value is the same
607
					as LOG_BLOCK_HDR_DATA_LEN, it means
608
					that the first rec group has not yet
609
					been catenated to this log block, but
610
					if it will, it will start at this
611
					offset; an archive recovery can
612
					start parsing the log records starting
613
					from this offset in this log block,
614
					if value not 0 */
615
#define LOG_BLOCK_CHECKPOINT_NO	8	/* 4 lower bytes of the value of
616
					log_sys->next_checkpoint_no when the
617
					log block was last written to: if the
618
					block has not yet been written full,
619
					this value is only updated before a
620
					log buffer flush */
621
#define LOG_BLOCK_HDR_SIZE	12	/* size of the log block header in
622
					bytes */
623
624
/* Offsets of a log block trailer from the end of the block */
625
#define	LOG_BLOCK_CHECKSUM	4	/* 4 byte checksum of the log block
626
					contents; in InnoDB versions
627
					< 3.23.52 this did not contain the
628
					checksum but the same value as
629
					.._HDR_NO */
630
#define	LOG_BLOCK_TRL_SIZE	4	/* trailer size in bytes */
631
632
/* Offsets for a checkpoint field */
633
#define LOG_CHECKPOINT_NO		0
634
#define LOG_CHECKPOINT_LSN		8
635
#define LOG_CHECKPOINT_OFFSET		16
636
#define LOG_CHECKPOINT_LOG_BUF_SIZE	20
637
#define	LOG_CHECKPOINT_ARCHIVED_LSN	24
638
#define	LOG_CHECKPOINT_GROUP_ARRAY	32
639
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
640
/* For each value smaller than LOG_MAX_N_GROUPS the following 8 bytes: */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
641
642
#define LOG_CHECKPOINT_ARCHIVED_FILE_NO	0
643
#define LOG_CHECKPOINT_ARCHIVED_OFFSET	4
644
645
#define	LOG_CHECKPOINT_ARRAY_END	(LOG_CHECKPOINT_GROUP_ARRAY\
646
							+ LOG_MAX_N_GROUPS * 8)
647
#define LOG_CHECKPOINT_CHECKSUM_1	LOG_CHECKPOINT_ARRAY_END
648
#define LOG_CHECKPOINT_CHECKSUM_2	(4 + LOG_CHECKPOINT_ARRAY_END)
649
#define LOG_CHECKPOINT_FSP_FREE_LIMIT	(8 + LOG_CHECKPOINT_ARRAY_END)
650
					/* current fsp free limit in
651
					tablespace 0, in units of one
652
					megabyte; this information is only used
653
					by ibbackup to decide if it can
654
					truncate unused ends of
655
					non-auto-extending data files in space
656
					0 */
657
#define LOG_CHECKPOINT_FSP_MAGIC_N	(12 + LOG_CHECKPOINT_ARRAY_END)
658
					/* this magic number tells if the
659
					checkpoint contains the above field:
660
					the field was added to
661
					InnoDB-3.23.50 */
662
#define LOG_CHECKPOINT_SIZE		(16 + LOG_CHECKPOINT_ARRAY_END)
663
664
#define LOG_CHECKPOINT_FSP_MAGIC_N_VAL	1441231243
665
666
/* Offsets of a log file header */
667
#define LOG_GROUP_ID		0	/* log group number */
668
#define LOG_FILE_START_LSN	4	/* lsn of the start of data in this
669
					log file */
670
#define LOG_FILE_NO		12	/* 4-byte archived log file number;
671
					this field is only defined in an
672
					archived log file */
673
#define LOG_FILE_WAS_CREATED_BY_HOT_BACKUP 16
674
					/* a 32-byte field which contains
675
					the string 'ibbackup' and the
676
					creation time if the log file was
677
					created by ibbackup --restore;
678
					when mysqld is first time started
679
					on the restored database, it can
680
					print helpful info for the user */
681
#define	LOG_FILE_ARCH_COMPLETED	OS_FILE_LOG_BLOCK_SIZE
682
					/* this 4-byte field is TRUE when
683
					the writing of an archived log file
684
					has been completed; this field is
685
					only defined in an archived log file */
686
#define LOG_FILE_END_LSN	(OS_FILE_LOG_BLOCK_SIZE + 4)
687
					/* lsn where the archived log file
688
					at least extends: actually the
689
					archived log file may extend to a
690
					later lsn, as long as it is within the
691
					same log block as this lsn; this field
692
					is defined only when an archived log
693
					file has been completely written */
694
#define LOG_CHECKPOINT_1	OS_FILE_LOG_BLOCK_SIZE
695
					/* first checkpoint field in the log
696
					header; we write alternately to the
697
					checkpoint fields when we make new
698
					checkpoints; this field is only defined
699
					in the first log file of a log group */
700
#define LOG_CHECKPOINT_2	(3 * OS_FILE_LOG_BLOCK_SIZE)
701
					/* second checkpoint field in the log
702
					header */
703
#define LOG_FILE_HDR_SIZE	(4 * OS_FILE_LOG_BLOCK_SIZE)
704
705
#define LOG_GROUP_OK		301
706
#define LOG_GROUP_CORRUPTED	302
707
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
708
/** Log group consists of a number of log files, each of the same size; a log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
709
group is implemented as a space in the sense of the module fil0fil. */
710
struct log_group_struct{
711
	/* The following fields are protected by log_sys->mutex */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
712
	ulint		id;		/*!< log group id */
713
	ulint		n_files;	/*!< number of files in the group */
714
	ulint		file_size;	/*!< individual log file size in bytes,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
715
					including the log file header */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
716
	ulint		space_id;	/*!< file space which implements the log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
717
					group */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
718
	ulint		state;		/*!< LOG_GROUP_OK or
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
719
					LOG_GROUP_CORRUPTED */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
720
	ib_uint64_t	lsn;		/*!< lsn used to fix coordinates within
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
721
					the log group */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
722
	ulint		lsn_offset;	/*!< the offset of the above lsn */
723
	ulint		n_pending_writes;/*!< number of currently pending flush
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
724
					writes for this log group */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
725
	byte**		file_header_bufs;/*!< buffers for each file
726
					header in the group */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
727
	/*-----------------------------*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
728
	byte**		archive_file_header_bufs;/*!< buffers for each file
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
729
					header in the group */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
730
	ulint		archive_space_id;/*!< file space which
731
					implements the log group
732
					archive */
733
	ulint		archived_file_no;/*!< file number corresponding to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
734
					log_sys->archived_lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
735
	ulint		archived_offset;/*!< file offset corresponding to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
736
					log_sys->archived_lsn, 0 if we have
737
					not yet written to the archive file
738
					number archived_file_no */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
739
	ulint		next_archived_file_no;/*!< during an archive write,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
740
					until the write is completed, we
741
					store the next value for
742
					archived_file_no here: the write
743
					completion function then sets the new
744
					value to ..._file_no */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
745
	ulint		next_archived_offset; /*!< like the preceding field */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
746
	/*-----------------------------*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
747
	ib_uint64_t	scanned_lsn;	/*!< used only in recovery: recovery scan
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
748
					succeeded up to this lsn in this log
749
					group */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
750
	byte*		checkpoint_buf;	/*!< checkpoint header is written from
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
751
					this buffer to the group */
752
	UT_LIST_NODE_T(log_group_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
753
			log_groups;	/*!< list of log groups */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
754
};
755
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
756
/** Redo log buffer */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
757
struct log_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
758
	byte		pad[64];	/*!< padding to prevent other memory
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
759
					update hotspots from residing on the
760
					same memory cache line */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
761
	ib_uint64_t	lsn;		/*!< log sequence number */
762
	ulint		buf_free;	/*!< first free offset within the log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
763
					buffer */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
764
#ifndef UNIV_HOTBACKUP
765
	mutex_t		mutex;		/*!< mutex protecting the log */
766
#endif /* !UNIV_HOTBACKUP */
767
	byte*		buf;		/*!< log buffer */
768
	ulint		buf_size;	/*!< log buffer size in bytes */
769
	ulint		max_buf_free;	/*!< recommended maximum value of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
770
					buf_free, after which the buffer is
771
					flushed */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
772
	ulint		old_buf_free;	/*!< value of buf free when log was
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
773
					last time opened; only in the debug
774
					version */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
775
	ib_uint64_t	old_lsn;	/*!< value of lsn when log was
776
					last time opened; only in the
777
					debug version */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
778
	ibool		check_flush_or_checkpoint;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
779
					/*!< this is set to TRUE when there may
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
780
					be need to flush the log buffer, or
781
					preflush buffer pool pages, or make
782
					a checkpoint; this MUST be TRUE when
783
					lsn - last_checkpoint_lsn >
784
					max_checkpoint_age; this flag is
785
					peeked at by log_free_check(), which
786
					does not reserve the log mutex */
787
	UT_LIST_BASE_NODE_T(log_group_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
788
			log_groups;	/*!< log groups */
789
790
#ifndef UNIV_HOTBACKUP
791
	/** The fields involved in the log buffer flush @{ */
792
793
	ulint		buf_next_to_write;/*!< first offset in the log buffer
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
794
					where the byte content may not exist
795
					written to file, e.g., the start
796
					offset of a log record catenated
797
					later; this is advanced when a flush
798
					operation is completed to all the log
799
					groups */
800
	ib_uint64_t	written_to_some_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
801
					/*!< first log sequence number not yet
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
802
					written to any log group; for this to
803
					be advanced, it is enough that the
804
					write i/o has been completed for any
805
					one log group */
806
	ib_uint64_t	written_to_all_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
807
					/*!< first log sequence number not yet
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
808
					written to some log group; for this to
809
					be advanced, it is enough that the
810
					write i/o has been completed for all
811
					log groups */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
812
	ib_uint64_t	write_lsn;	/*!< end lsn for the current running
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
813
					write */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
814
	ulint		write_end_offset;/*!< the data in buffer has
815
					been written up to this offset
816
					when the current write ends:
817
					this field will then be copied
818
					to buf_next_to_write */
819
	ib_uint64_t	current_flush_lsn;/*!< end lsn for the current running
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
820
					write + flush operation */
821
	ib_uint64_t	flushed_to_disk_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
822
					/*!< how far we have written the log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
823
					AND flushed to disk */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
824
	ulint		n_pending_writes;/*!< number of currently
825
					pending flushes or writes */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
826
	/* NOTE on the 'flush' in names of the fields below: starting from
827
	4.0.14, we separate the write of the log file and the actual fsync()
828
	or other method to flush it to disk. The names below shhould really
829
	be 'flush_or_write'! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
830
	os_event_t	no_flush_event;	/*!< this event is in the reset state
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
831
					when a flush or a write is running;
832
					a thread should wait for this without
833
					owning the log mutex, but NOTE that
834
					to set or reset this event, the
835
					thread MUST own the log mutex! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
836
	ibool		one_flushed;	/*!< during a flush, this is
837
					first FALSE and becomes TRUE
838
					when one log group has been
839
					written or flushed */
840
	os_event_t	one_flushed_event;/*!< this event is reset when the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
841
					flush or write has not yet completed
842
					for any log group; e.g., this means
843
					that a transaction has been committed
844
					when this is set; a thread should wait
845
					for this without owning the log mutex,
846
					but NOTE that to set or reset this
847
					event, the thread MUST own the log
848
					mutex! */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
849
	ulint		n_log_ios;	/*!< number of log i/os initiated thus
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
850
					far */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
851
	ulint		n_log_ios_old;	/*!< number of log i/o's at the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
852
					previous printout */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
853
	time_t		last_printout_time;/*!< when log_print was last time
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
854
					called */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
855
	/* @} */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
856
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
857
	/** Fields involved in checkpoints @{ */
858
	ulint		log_group_capacity; /*!< capacity of the log group; if
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
859
					the checkpoint age exceeds this, it is
860
					a serious error because it is possible
861
					we will then overwrite log and spoil
862
					crash recovery */
863
	ulint		max_modified_age_async;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
864
					/*!< when this recommended
865
					value for lsn -
866
					buf_pool_get_oldest_modification()
867
					is exceeded, we start an
868
					asynchronous preflush of pool pages */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
869
	ulint		max_modified_age_sync;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
870
					/*!< when this recommended
871
					value for lsn -
872
					buf_pool_get_oldest_modification()
873
					is exceeded, we start a
874
					synchronous preflush of pool pages */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
875
	ulint		adm_checkpoint_interval;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
876
					/*!< administrator-specified checkpoint
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
877
					interval in terms of log growth in
878
					bytes; the interval actually used by
879
					the database can be smaller */
880
	ulint		max_checkpoint_age_async;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
881
					/*!< when this checkpoint age
882
					is exceeded we start an
883
					asynchronous writing of a new
884
					checkpoint */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
885
	ulint		max_checkpoint_age;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
886
					/*!< this is the maximum allowed value
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
887
					for lsn - last_checkpoint_lsn when a
888
					new query step is started */
889
	ib_uint64_t	next_checkpoint_no;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
890
					/*!< next checkpoint number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
891
	ib_uint64_t	last_checkpoint_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
892
					/*!< latest checkpoint lsn */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
893
	ib_uint64_t	next_checkpoint_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
894
					/*!< next checkpoint lsn */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
895
	ulint		n_pending_checkpoint_writes;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
896
					/*!< number of currently pending
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
897
					checkpoint writes */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
898
	rw_lock_t	checkpoint_lock;/*!< this latch is x-locked when a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
899
					checkpoint write is running; a thread
900
					should wait for this without owning
901
					the log mutex */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
902
#endif /* !UNIV_HOTBACKUP */
903
	byte*		checkpoint_buf;	/*!< checkpoint header is read to this
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
904
					buffer */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
905
	/* @} */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
906
#ifdef UNIV_LOG_ARCHIVE
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
907
	/** Fields involved in archiving @{ */
908
	ulint		archiving_state;/*!< LOG_ARCH_ON, LOG_ARCH_STOPPING
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
909
					LOG_ARCH_STOPPED, LOG_ARCH_OFF */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
910
	ib_uint64_t	archived_lsn;	/*!< archiving has advanced to this
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
911
					lsn */
912
	ulint		max_archived_lsn_age_async;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
913
					/*!< recommended maximum age of
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
914
					archived_lsn, before we start
915
					asynchronous copying to the archive */
916
	ulint		max_archived_lsn_age;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
917
					/*!< maximum allowed age for
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
918
					archived_lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
919
	ib_uint64_t	next_archived_lsn;/*!< during an archive write,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
920
					until the write is completed, we
921
					store the next value for
922
					archived_lsn here: the write
923
					completion function then sets the new
924
					value to archived_lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
925
	ulint		archiving_phase;/*!< LOG_ARCHIVE_READ or
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
926
					LOG_ARCHIVE_WRITE */
927
	ulint		n_pending_archive_ios;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
928
					/*!< number of currently pending reads
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
929
					or writes in archiving */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
930
	rw_lock_t	archive_lock;	/*!< this latch is x-locked when an
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
931
					archive write is running; a thread
932
					should wait for this without owning
933
					the log mutex */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
934
	ulint		archive_buf_size;/*!< size of archive_buf */
935
	byte*		archive_buf;	/*!< log segment is written to the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
936
					archive from this buffer */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
937
	os_event_t	archiving_on;	/*!< if archiving has been stopped,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
938
					a thread can wait for this event to
939
					become signaled */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
940
	/* @} */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
941
#endif /* UNIV_LOG_ARCHIVE */
942
};
943
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
944
#ifdef UNIV_LOG_ARCHIVE
945
/** Archiving state @{ */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
946
#define LOG_ARCH_ON		71
947
#define LOG_ARCH_STOPPING	72
948
#define LOG_ARCH_STOPPING2	73
949
#define LOG_ARCH_STOPPED	74
950
#define LOG_ARCH_OFF		75
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
951
/* @} */
952
#endif /* UNIV_LOG_ARCHIVE */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
953
954
#ifndef UNIV_NONINL
955
#include "log0log.ic"
956
#endif
957
958
#endif