~drizzle-trunk/drizzle/development

641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
1
/*****************************************************************************
2
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
3
Copyright (C) 1997, 2010, Innobase Oy. All Rights Reserved.
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
16
17
*****************************************************************************/
18
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
19
/**************************************************//**
20
@file include/log0recv.h
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
21
Recovery
22
23
Created 9/20/1997 Heikki Tuuri
24
*******************************************************/
25
26
#ifndef log0recv_h
27
#define log0recv_h
28
29
#include "univ.i"
30
#include "ut0byte.h"
31
#include "buf0types.h"
32
#include "hash0hash.h"
33
#include "log0log.h"
34
35
#ifdef UNIV_HOTBACKUP
36
extern ibool	recv_replay_file_ops;
37
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
38
/*******************************************************************//**
39
Reads the checkpoint info needed in hot backup.
40
@return	TRUE if success */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
41
UNIV_INTERN
42
ibool
43
recv_read_cp_info_for_backup(
44
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
45
	const byte*	hdr,	/*!< in: buffer containing the log group
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
46
				header */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
47
	ib_uint64_t*	lsn,	/*!< out: checkpoint lsn */
48
	ulint*		offset,	/*!< out: checkpoint offset in the log group */
49
	ulint*		fsp_limit,/*!< out: fsp limit of space 0,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
50
				1000000000 if the database is running
51
				with < version 3.23.50 of InnoDB */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
52
	ib_uint64_t*	cp_no,	/*!< out: checkpoint number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
53
	ib_uint64_t*	first_header_lsn);
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
54
				/*!< out: lsn of of the start of the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
55
				first log file */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
56
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
57
Scans the log segment and n_bytes_scanned is set to the length of valid
58
log scanned. */
59
UNIV_INTERN
60
void
61
recv_scan_log_seg_for_backup(
62
/*=========================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
63
	byte*		buf,		/*!< in: buffer containing log data */
64
	ulint		buf_len,	/*!< in: data length in that buffer */
65
	ib_uint64_t*	scanned_lsn,	/*!< in/out: lsn of buffer start,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
66
					we return scanned lsn */
67
	ulint*		scanned_checkpoint_no,
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
68
					/*!< in/out: 4 lowest bytes of the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
69
					highest scanned checkpoint number so
70
					far */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
71
	ulint*		n_bytes_scanned);/*!< out: how much we were able to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
72
					scan, smaller than buf_len if log
73
					data ended here */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
74
#endif /* UNIV_HOTBACKUP */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
75
/*******************************************************************//**
76
Returns TRUE if recovery is currently running.
77
@return	recv_recovery_on */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
78
UNIV_INLINE
79
ibool
80
recv_recovery_is_on(void);
81
/*=====================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
82
#ifdef UNIV_LOG_ARCHIVE
83
/*******************************************************************//**
84
Returns TRUE if recovery from backup is currently running.
85
@return	recv_recovery_from_backup_on */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
86
UNIV_INLINE
87
ibool
88
recv_recovery_from_backup_is_on(void);
89
/*=================================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
90
#endif /* UNIV_LOG_ARCHIVE */
91
/************************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
92
Applies the hashed log records to the page, if the page lsn is less than the
93
lsn of a log record. This can be called when a buffer page has just been
94
read in, or also for a page already in the buffer pool. */
95
UNIV_INTERN
96
void
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
97
recv_recover_page_func(
98
/*===================*/
99
#ifndef UNIV_HOTBACKUP
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
100
	ibool		just_read_in,
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
101
				/*!< in: TRUE if the i/o handler calls
102
				this for a freshly read page */
103
#endif /* !UNIV_HOTBACKUP */
104
	buf_block_t*	block);	/*!< in/out: buffer block */
105
#ifndef UNIV_HOTBACKUP
106
/** Wrapper for recv_recover_page_func().
107
Applies the hashed log records to the page, if the page lsn is less than the
108
lsn of a log record. This can be called when a buffer page has just been
109
read in, or also for a page already in the buffer pool.
110
@param jri	in: TRUE if just read in (the i/o handler calls this for
111
a freshly read page)
112
@param block	in/out: the buffer block
113
*/
114
# define recv_recover_page(jri, block)	recv_recover_page_func(jri, block)
115
#else /* !UNIV_HOTBACKUP */
116
/** Wrapper for recv_recover_page_func().
117
Applies the hashed log records to the page, if the page lsn is less than the
118
lsn of a log record. This can be called when a buffer page has just been
119
read in, or also for a page already in the buffer pool.
120
@param jri	in: TRUE if just read in (the i/o handler calls this for
121
a freshly read page)
122
@param block	in/out: the buffer block
123
*/
124
# define recv_recover_page(jri, block)	recv_recover_page_func(block)
125
#endif /* !UNIV_HOTBACKUP */
126
/********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
127
Recovers from a checkpoint. When this function returns, the database is able
128
to start processing of new user transactions, but the function
129
recv_recovery_from_checkpoint_finish should be called later to complete
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
130
the recovery and free the resources used in it.
131
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
132
UNIV_INTERN
133
ulint
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
134
recv_recovery_from_checkpoint_start_func(
135
/*=====================================*/
136
#ifdef UNIV_LOG_ARCHIVE
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
137
	ulint		type,		/*!< in: LOG_CHECKPOINT or
138
					LOG_ARCHIVE */
139
	ib_uint64_t	limit_lsn,	/*!< in: recover up to this lsn
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
140
					if possible */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
141
#endif /* UNIV_LOG_ARCHIVE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
142
	ib_uint64_t	min_flushed_lsn,/*!< in: min flushed lsn from
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
143
					data files */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
144
	ib_uint64_t	max_flushed_lsn);/*!< in: max flushed lsn from
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
145
					 data files */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
146
#ifdef UNIV_LOG_ARCHIVE
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
147
/** Wrapper for recv_recovery_from_checkpoint_start_func().
148
Recovers from a checkpoint. When this function returns, the database is able
149
to start processing of new user transactions, but the function
150
recv_recovery_from_checkpoint_finish should be called later to complete
151
the recovery and free the resources used in it.
152
@param type	in: LOG_CHECKPOINT or LOG_ARCHIVE
153
@param lim	in: recover up to this log sequence number if possible
154
@param min	in: minimum flushed log sequence number from data files
155
@param max	in: maximum flushed log sequence number from data files
156
@return	error code or DB_SUCCESS */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
157
# define recv_recovery_from_checkpoint_start(type,lim,min,max)		\
158
	recv_recovery_from_checkpoint_start_func(type,lim,min,max)
159
#else /* UNIV_LOG_ARCHIVE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
160
/** Wrapper for recv_recovery_from_checkpoint_start_func().
161
Recovers from a checkpoint. When this function returns, the database is able
162
to start processing of new user transactions, but the function
163
recv_recovery_from_checkpoint_finish should be called later to complete
164
the recovery and free the resources used in it.
165
@param type	ignored: LOG_CHECKPOINT or LOG_ARCHIVE
166
@param lim	ignored: recover up to this log sequence number if possible
167
@param min	in: minimum flushed log sequence number from data files
168
@param max	in: maximum flushed log sequence number from data files
169
@return	error code or DB_SUCCESS */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
170
# define recv_recovery_from_checkpoint_start(type,lim,min,max)		\
171
	recv_recovery_from_checkpoint_start_func(min,max)
172
#endif /* UNIV_LOG_ARCHIVE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
173
/********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
174
Completes recovery from a checkpoint. */
175
UNIV_INTERN
176
void
177
recv_recovery_from_checkpoint_finish(void);
178
/*======================================*/
1819.5.196 by marko
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6611 from MySQL InnoDB
179
/********************************************************//**
180
Initiates the rollback of active transactions. */
181
UNIV_INTERN
182
void
183
recv_recovery_rollback_active(void);
184
/*===============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
185
/*******************************************************//**
186
Scans log from a buffer and stores new log data to the parsing buffer.
187
Parses and hashes the log records if new data found.  Unless
188
UNIV_HOTBACKUP is defined, this function will apply log records
189
automatically when the hash table becomes full.
190
@return TRUE if limit_lsn has been reached, or not able to scan any
191
more in this log group */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
192
UNIV_INTERN
193
ibool
194
recv_scan_log_recs(
195
/*===============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
196
	ulint		available_memory,/*!< in: we let the hash table of recs
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
197
					to grow to this size, at the maximum */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
198
	ibool		store_to_hash,	/*!< in: TRUE if the records should be
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
199
					stored to the hash table; this is set
200
					to FALSE if just debug checking is
201
					needed */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
202
	const byte*	buf,		/*!< in: buffer containing a log
203
					segment or garbage */
204
	ulint		len,		/*!< in: buffer length */
205
	ib_uint64_t	start_lsn,	/*!< in: buffer start lsn */
206
	ib_uint64_t*	contiguous_lsn,	/*!< in/out: it is known that all log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
207
					groups contain contiguous log data up
208
					to this lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
209
	ib_uint64_t*	group_scanned_lsn);/*!< out: scanning succeeded up to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
210
					this lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
211
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
212
Resets the logs. The contents of log files will be lost! */
213
UNIV_INTERN
214
void
215
recv_reset_logs(
216
/*============*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
217
	ib_uint64_t	lsn,		/*!< in: reset to this lsn
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
218
					rounded up to be divisible by
219
					OS_FILE_LOG_BLOCK_SIZE, after
220
					which we add
221
					LOG_BLOCK_HDR_SIZE */
222
#ifdef UNIV_LOG_ARCHIVE
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
223
	ulint		arch_log_no,	/*!< in: next archived log file number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
224
#endif /* UNIV_LOG_ARCHIVE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
225
	ibool		new_logs_created);/*!< in: TRUE if resetting logs
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
226
					is done at the log creation;
227
					FALSE if it is done after
228
					archive recovery */
229
#ifdef UNIV_HOTBACKUP
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
230
/******************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
231
Creates new log files after a backup has been restored. */
232
UNIV_INTERN
233
void
234
recv_reset_log_files_for_backup(
235
/*============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
236
	const char*	log_dir,	/*!< in: log file directory path */
237
	ulint		n_log_files,	/*!< in: number of log files */
238
	ulint		log_file_size,	/*!< in: log file size */
239
	ib_uint64_t	lsn);		/*!< in: new start lsn, must be
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
240
					divisible by OS_FILE_LOG_BLOCK_SIZE */
241
#endif /* UNIV_HOTBACKUP */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
242
/********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
243
Creates the recovery system. */
244
UNIV_INTERN
245
void
246
recv_sys_create(void);
247
/*=================*/
1819.5.106 by stewart at flamingspork
[patch 106/129] Merge patch for revision 1915 from InnoDB SVN:
248
/**********************************************************//**
249
Release recovery system mutexes. */
250
UNIV_INTERN
251
void
252
recv_sys_close(void);
253
/*================*/
254
/********************************************************//**
255
Frees the recovery system memory. */
256
UNIV_INTERN
257
void
258
recv_sys_mem_free(void);
259
/*===================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
260
/********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
261
Inits the recovery system for a recovery operation. */
262
UNIV_INTERN
263
void
264
recv_sys_init(
265
/*==========*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
266
	ulint	available_memory);	/*!< in: available memory in bytes */
1819.5.149 by pekka
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6275 from MySQL InnoDB
267
#ifndef UNIV_HOTBACKUP
1819.5.106 by stewart at flamingspork
[patch 106/129] Merge patch for revision 1915 from InnoDB SVN:
268
/********************************************************//**
269
Reset the state of the recovery system variables. */
270
UNIV_INTERN
271
void
272
recv_sys_var_init(void);
273
/*===================*/
1819.5.149 by pekka
Merge Revision revid:svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6275 from MySQL InnoDB
274
#endif /* !UNIV_HOTBACKUP */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
275
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
276
Empties the hash table of stored log records, applying them to appropriate
277
pages. */
278
UNIV_INTERN
279
void
280
recv_apply_hashed_log_recs(
281
/*=======================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
282
	ibool	allow_ibuf);	/*!< in: if TRUE, also ibuf operations are
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
283
				allowed during the application; if FALSE,
284
				no ibuf operations are allowed, and after
285
				the application all file pages are flushed to
286
				disk and invalidated in buffer pool: this
287
				alternative means that no new log records
288
				can be generated during the application */
289
#ifdef UNIV_HOTBACKUP
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
290
/*******************************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
291
Applies log records in the hash table to a backup. */
292
UNIV_INTERN
293
void
294
recv_apply_log_recs_for_backup(void);
295
/*================================*/
296
#endif
297
#ifdef UNIV_LOG_ARCHIVE
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
298
/********************************************************//**
299
Recovers from archived log files, and also from log files, if they exist.
300
@return	error code or DB_SUCCESS */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
301
UNIV_INTERN
302
ulint
303
recv_recovery_from_archive_start(
304
/*=============================*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
305
	ib_uint64_t	min_flushed_lsn,/*!< in: min flushed lsn field from the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
306
					data files */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
307
	ib_uint64_t	limit_lsn,	/*!< in: recover up to this lsn if
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
308
					possible */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
309
	ulint		first_log_no);	/*!< in: number of the first archived
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
310
					log file to use in the recovery; the
311
					file will be searched from
312
					INNOBASE_LOG_ARCH_DIR specified in
313
					server config file */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
314
/********************************************************//**
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
315
Completes recovery from archive. */
316
UNIV_INTERN
317
void
318
recv_recovery_from_archive_finish(void);
319
/*===================================*/
320
#endif /* UNIV_LOG_ARCHIVE */
321
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
322
/** Block of log record data */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
323
typedef struct recv_data_struct	recv_data_t;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
324
/** Block of log record data */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
325
struct recv_data_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
326
	recv_data_t*	next;	/*!< pointer to the next block or NULL */
327
				/*!< the log record data is stored physically
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
328
				immediately after this struct, max amount
329
				RECV_DATA_BLOCK_SIZE bytes of it */
330
};
331
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
332
/** Stored log record struct */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
333
typedef struct recv_struct	recv_t;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
334
/** Stored log record struct */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
335
struct recv_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
336
	byte		type;	/*!< log record type */
337
	ulint		len;	/*!< log record body length in bytes */
338
	recv_data_t*	data;	/*!< chain of blocks containing the log record
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
339
				body */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
340
	ib_uint64_t	start_lsn;/*!< start lsn of the log segment written by
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
341
				the mtr which generated this log record: NOTE
342
				that this is not necessarily the start lsn of
343
				this log record */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
344
	ib_uint64_t	end_lsn;/*!< end lsn of the log segment written by
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
345
				the mtr which generated this log record: NOTE
346
				that this is not necessarily the end lsn of
347
				this log record */
348
	UT_LIST_NODE_T(recv_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
349
			rec_list;/*!< list of log records for this page */
350
};
351
352
/** States of recv_addr_struct */
353
enum recv_addr_state {
354
	/** not yet processed */
355
	RECV_NOT_PROCESSED,
356
	/** page is being read */
357
	RECV_BEING_READ,
358
	/** log records are being applied on the page */
359
	RECV_BEING_PROCESSED,
360
	/** log records have been applied on the page, or they have
361
	been discarded because the tablespace does not exist */
362
	RECV_PROCESSED
363
};
364
365
/** Hashed page file address struct */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
366
typedef struct recv_addr_struct	recv_addr_t;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
367
/** Hashed page file address struct */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
368
struct recv_addr_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
369
	enum recv_addr_state state;
370
				/*!< recovery state of the page */
1819.7.87 by Vasil Dimov
Merge Revision revid:vasil.dimov@oracle.com-20100504105413-g3d1l1nlysxbtdvo from MySQL InnoDB
371
	unsigned	space:32;/*!< space id */
372
	unsigned	page_no:32;/*!< page number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
373
	UT_LIST_BASE_NODE_T(recv_t)
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
374
			rec_list;/*!< list of log records for this page */
375
	hash_node_t	addr_hash;/*!< hash node in the hash bucket chain */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
376
};
377
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
378
/** Recovery system data structure */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
379
typedef struct recv_sys_struct	recv_sys_t;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
380
/** Recovery system data structure */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
381
struct recv_sys_struct{
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
382
#ifndef UNIV_HOTBACKUP
383
	mutex_t		mutex;	/*!< mutex protecting the fields apply_log_recs,
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
384
				n_addrs, and the state field in each recv_addr
385
				struct */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
386
#endif /* !UNIV_HOTBACKUP */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
387
	ibool		apply_log_recs;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
388
				/*!< this is TRUE when log rec application to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
389
				pages is allowed; this flag tells the
390
				i/o-handler if it should do log record
391
				application */
392
	ibool		apply_batch_on;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
393
				/*!< this is TRUE when a log rec application
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
394
				batch is running */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
395
	ib_uint64_t	lsn;	/*!< log sequence number */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
396
	ulint		last_log_buf_size;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
397
				/*!< size of the log buffer when the database
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
398
				last time wrote to the log */
399
	byte*		last_block;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
400
				/*!< possible incomplete last recovered log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
401
				block */
402
	byte*		last_block_buf_start;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
403
				/*!< the nonaligned start address of the
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
404
				preceding buffer */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
405
	byte*		buf;	/*!< buffer for parsing log records */
406
	ulint		len;	/*!< amount of data in buf */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
407
	ib_uint64_t	parse_start_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
408
				/*!< this is the lsn from which we were able to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
409
				start parsing log records and adding them to
410
				the hash table; zero if a suitable
411
				start point not found yet */
412
	ib_uint64_t	scanned_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
413
				/*!< the log data has been scanned up to this
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
414
				lsn */
415
	ulint		scanned_checkpoint_no;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
416
				/*!< the log data has been scanned up to this
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
417
				checkpoint number (lowest 4 bytes) */
418
	ulint		recovered_offset;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
419
				/*!< start offset of non-parsed log records in
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
420
				buf */
421
	ib_uint64_t	recovered_lsn;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
422
				/*!< the log records have been parsed up to
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
423
				this lsn */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
424
	ib_uint64_t	limit_lsn;/*!< recovery should be made at most
425
				up to this lsn */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
426
	ibool		found_corrupt_log;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
427
				/*!< this is set to TRUE if we during log
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
428
				scan find a corrupt log block, or a corrupt
429
				log record, or there is a log parsing
430
				buffer overflow */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
431
#ifdef UNIV_LOG_ARCHIVE
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
432
	log_group_t*	archive_group;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
433
				/*!< in archive recovery: the log group whose
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
434
				archive is read */
641.2.2 by Monty Taylor
InnoDB Plugin 1.0.3
435
#endif /* !UNIV_LOG_ARCHIVE */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
436
	mem_heap_t*	heap;	/*!< memory heap of log records and file
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
437
				addresses*/
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
438
	hash_table_t*	addr_hash;/*!< hash table of file addresses of pages */
439
	ulint		n_addrs;/*!< number of not processed hashed file
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
440
				addresses in the hash table */
441
};
442
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
443
/** The recovery system */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
444
extern recv_sys_t*	recv_sys;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
445
446
/** TRUE when applying redo log records during crash recovery; FALSE
447
otherwise.  Note that this is FALSE while a background thread is
448
rolling back incomplete transactions. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
449
extern ibool		recv_recovery_on;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
450
/** If the following is TRUE, the buffer pool file pages must be invalidated
451
after recovery and no ibuf operations are allowed; this becomes TRUE if
452
the log record hash table becomes too full, and log records must be merged
453
to file pages already before the recovery is finished: in this case no
454
ibuf operations are allowed, as they could modify the pages read in the
455
buffer pool before the pages have been recovered to the up-to-date state.
456
457
TRUE means that recovery is running and no operations on the log files
458
are allowed yet: the variable name is misleading. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
459
extern ibool		recv_no_ibuf_operations;
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
460
/** TRUE when recv_init_crash_recovery() has been called. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
461
extern ibool		recv_needed_recovery;
1819.5.84 by stewart at flamingspork
[patch 084/129] Merge patch for revision 1883 from InnoDB SVN:
462
#ifdef UNIV_DEBUG
463
/** TRUE if writing to the redo log (mtr_commit) is forbidden.
464
Protected by log_sys->mutex. */
465
extern ibool		recv_no_log_write;
466
#endif /* UNIV_DEBUG */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
467
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
468
/** TRUE if buf_page_is_corrupted() should check if the log sequence
469
number (FIL_PAGE_LSN) is in the future.  Initially FALSE, and set by
470
recv_recovery_from_checkpoint_start_func(). */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
471
extern ibool		recv_lsn_checks_on;
472
#ifdef UNIV_HOTBACKUP
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
473
/** TRUE when the redo log is being backed up */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
474
extern ibool		recv_is_making_a_backup;
475
#endif /* UNIV_HOTBACKUP */
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
476
/** Maximum page number encountered in the redo log */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
477
extern ulint		recv_max_parsed_page_no;
478
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
479
/** Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
480
times! */
481
#define RECV_PARSING_BUF_SIZE	(2 * 1024 * 1024)
482
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
483
/** Size of block reads when the log groups are scanned forward to do a
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
484
roll-forward */
485
#define RECV_SCAN_SIZE		(4 * UNIV_PAGE_SIZE)
486
641.2.3 by Monty Taylor
InnoDB Plugin 1.0.4
487
/** This many frames must be left free in the buffer pool when we scan
488
the log and store the scanned log records in the buffer pool: we will
489
use these free frames to read in pages when we start applying the
490
log records to the database. */
641.1.2 by Monty Taylor
Imported 1.0.1 with clean - with no changes.
491
extern ulint	recv_n_pool_free_frames;
492
493
#ifndef UNIV_NONINL
494
#include "log0recv.ic"
495
#endif
496
497
#endif