|
|
@ -98,13 +98,29 @@ recv_recover_page_func( |
|
|
|
/*===================*/ |
|
|
|
#ifndef UNIV_HOTBACKUP |
|
|
|
ibool just_read_in, |
|
|
|
/*!< in: TRUE if the i/o-handler calls this for |
|
|
|
a freshly read page */ |
|
|
|
/*!< in: TRUE if the i/o handler calls |
|
|
|
this for a freshly read page */ |
|
|
|
#endif /* !UNIV_HOTBACKUP */ |
|
|
|
buf_block_t* block); /*!< in: buffer block */ |
|
|
|
buf_block_t* block); /*!< in/out: buffer block */ |
|
|
|
#ifndef UNIV_HOTBACKUP |
|
|
|
/** Wrapper for recv_recover_page_func(). |
|
|
|
Applies the hashed log records to the page, if the page lsn is less than the |
|
|
|
lsn of a log record. This can be called when a buffer page has just been |
|
|
|
read in, or also for a page already in the buffer pool. |
|
|
|
@param jri in: TRUE if just read in (the i/o handler calls this for |
|
|
|
a freshly read page) |
|
|
|
@param block in/out: the buffer block |
|
|
|
*/ |
|
|
|
# define recv_recover_page(jri, block) recv_recover_page_func(jri, block) |
|
|
|
#else /* !UNIV_HOTBACKUP */ |
|
|
|
/** Wrapper for recv_recover_page_func(). |
|
|
|
Applies the hashed log records to the page, if the page lsn is less than the |
|
|
|
lsn of a log record. This can be called when a buffer page has just been |
|
|
|
read in, or also for a page already in the buffer pool. |
|
|
|
@param jri in: TRUE if just read in (the i/o handler calls this for |
|
|
|
a freshly read page) |
|
|
|
@param block in/out: the buffer block |
|
|
|
*/ |
|
|
|
# define recv_recover_page(jri, block) recv_recover_page_func(block) |
|
|
|
#endif /* !UNIV_HOTBACKUP */ |
|
|
|
/********************************************************//** |
|
|
@ -118,7 +134,8 @@ ulint |
|
|
|
recv_recovery_from_checkpoint_start_func( |
|
|
|
/*=====================================*/ |
|
|
|
#ifdef UNIV_LOG_ARCHIVE |
|
|
|
ulint type, /*!< in: LOG_CHECKPOINT or LOG_ARCHIVE */ |
|
|
|
ulint type, /*!< in: LOG_CHECKPOINT or |
|
|
|
LOG_ARCHIVE */ |
|
|
|
ib_uint64_t limit_lsn, /*!< in: recover up to this lsn |
|
|
|
if possible */ |
|
|
|
#endif /* UNIV_LOG_ARCHIVE */ |
|
|
@ -127,9 +144,29 @@ recv_recovery_from_checkpoint_start_func( |
|
|
|
ib_uint64_t max_flushed_lsn);/*!< in: max flushed lsn from |
|
|
|
data files */ |
|
|
|
#ifdef UNIV_LOG_ARCHIVE |
|
|
|
/** Wrapper for recv_recovery_from_checkpoint_start_func(). |
|
|
|
Recovers from a checkpoint. When this function returns, the database is able |
|
|
|
to start processing of new user transactions, but the function |
|
|
|
recv_recovery_from_checkpoint_finish should be called later to complete |
|
|
|
the recovery and free the resources used in it. |
|
|
|
@param type in: LOG_CHECKPOINT or LOG_ARCHIVE |
|
|
|
@param lim in: recover up to this log sequence number if possible |
|
|
|
@param min in: minimum flushed log sequence number from data files |
|
|
|
@param max in: maximum flushed log sequence number from data files |
|
|
|
@return error code or DB_SUCCESS */ |
|
|
|
# define recv_recovery_from_checkpoint_start(type,lim,min,max) \ |
|
|
|
recv_recovery_from_checkpoint_start_func(type,lim,min,max) |
|
|
|
#else /* UNIV_LOG_ARCHIVE */ |
|
|
|
/** Wrapper for recv_recovery_from_checkpoint_start_func(). |
|
|
|
Recovers from a checkpoint. When this function returns, the database is able |
|
|
|
to start processing of new user transactions, but the function |
|
|
|
recv_recovery_from_checkpoint_finish should be called later to complete |
|
|
|
the recovery and free the resources used in it. |
|
|
|
@param type ignored: LOG_CHECKPOINT or LOG_ARCHIVE |
|
|
|
@param lim ignored: recover up to this log sequence number if possible |
|
|
|
@param min in: minimum flushed log sequence number from data files |
|
|
|
@param max in: maximum flushed log sequence number from data files |
|
|
|
@return error code or DB_SUCCESS */ |
|
|
|
# define recv_recovery_from_checkpoint_start(type,lim,min,max) \ |
|
|
|
recv_recovery_from_checkpoint_start_func(min,max) |
|
|
|
#endif /* UNIV_LOG_ARCHIVE */ |
|
|
@ -256,135 +293,170 @@ recv_recovery_from_archive_finish(void); |
|
|
|
/*===================================*/ |
|
|
|
#endif /* UNIV_LOG_ARCHIVE */ |
|
|
|
|
|
|
|
/* Block of log record data */ |
|
|
|
/** Block of log record data */ |
|
|
|
typedef struct recv_data_struct recv_data_t; |
|
|
|
/** Block of log record data */ |
|
|
|
struct recv_data_struct{ |
|
|
|
recv_data_t* next; /* pointer to the next block or NULL */ |
|
|
|
/* the log record data is stored physically |
|
|
|
recv_data_t* next; /*!< pointer to the next block or NULL */ |
|
|
|
/*!< the log record data is stored physically |
|
|
|
immediately after this struct, max amount |
|
|
|
RECV_DATA_BLOCK_SIZE bytes of it */ |
|
|
|
}; |
|
|
|
|
|
|
|
/* Stored log record struct */ |
|
|
|
/** Stored log record struct */ |
|
|
|
typedef struct recv_struct recv_t; |
|
|
|
/** Stored log record struct */ |
|
|
|
struct recv_struct{ |
|
|
|
byte type; /* log record type */ |
|
|
|
ulint len; /* log record body length in bytes */ |
|
|
|
recv_data_t* data; /* chain of blocks containing the log record |
|
|
|
byte type; /*!< log record type */ |
|
|
|
ulint len; /*!< log record body length in bytes */ |
|
|
|
recv_data_t* data; /*!< chain of blocks containing the log record |
|
|
|
body */ |
|
|
|
ib_uint64_t start_lsn;/* start lsn of the log segment written by |
|
|
|
ib_uint64_t start_lsn;/*!< start lsn of the log segment written by |
|
|
|
the mtr which generated this log record: NOTE |
|
|
|
that this is not necessarily the start lsn of |
|
|
|
this log record */ |
|
|
|
ib_uint64_t end_lsn;/* end lsn of the log segment written by |
|
|
|
ib_uint64_t end_lsn;/*!< end lsn of the log segment written by |
|
|
|
the mtr which generated this log record: NOTE |
|
|
|
that this is not necessarily the end lsn of |
|
|
|
this log record */ |
|
|
|
UT_LIST_NODE_T(recv_t) |
|
|
|
rec_list;/* list of log records for this page */ |
|
|
|
rec_list;/*!< list of log records for this page */ |
|
|
|
}; |
|
|
|
|
|
|
|
/** States of recv_addr_struct */ |
|
|
|
enum recv_addr_state { |
|
|
|
/** not yet processed */ |
|
|
|
RECV_NOT_PROCESSED, |
|
|
|
/** page is being read */ |
|
|
|
RECV_BEING_READ, |
|
|
|
/** log records are being applied on the page */ |
|
|
|
RECV_BEING_PROCESSED, |
|
|
|
/** log records have been applied on the page, or they have |
|
|
|
been discarded because the tablespace does not exist */ |
|
|
|
RECV_PROCESSED |
|
|
|
}; |
|
|
|
|
|
|
|
/* Hashed page file address struct */ |
|
|
|
/** Hashed page file address struct */ |
|
|
|
typedef struct recv_addr_struct recv_addr_t; |
|
|
|
/** Hashed page file address struct */ |
|
|
|
struct recv_addr_struct{ |
|
|
|
ulint state; /* RECV_NOT_PROCESSED, RECV_BEING_PROCESSED, |
|
|
|
or RECV_PROCESSED */ |
|
|
|
ulint space; /* space id */ |
|
|
|
ulint page_no;/* page number */ |
|
|
|
enum recv_addr_state state; |
|
|
|
/*!< recovery state of the page */ |
|
|
|
ulint space; /*!< space id */ |
|
|
|
ulint page_no;/*!< page number */ |
|
|
|
UT_LIST_BASE_NODE_T(recv_t) |
|
|
|
rec_list;/* list of log records for this page */ |
|
|
|
hash_node_t addr_hash; |
|
|
|
rec_list;/*!< list of log records for this page */ |
|
|
|
hash_node_t addr_hash;/*!< hash node in the hash bucket chain */ |
|
|
|
}; |
|
|
|
|
|
|
|
/* Recovery system data structure */ |
|
|
|
/** Recovery system data structure */ |
|
|
|
typedef struct recv_sys_struct recv_sys_t; |
|
|
|
/** Recovery system data structure */ |
|
|
|
struct recv_sys_struct{ |
|
|
|
#ifndef UNIV_HOTBACKUP |
|
|
|
mutex_t mutex; /* mutex protecting the fields apply_log_recs, |
|
|
|
mutex_t mutex; /*!< mutex protecting the fields apply_log_recs, |
|
|
|
n_addrs, and the state field in each recv_addr |
|
|
|
struct */ |
|
|
|
#endif /* !UNIV_HOTBACKUP */ |
|
|
|
ibool apply_log_recs; |
|
|
|
/* this is TRUE when log rec application to |
|
|
|
/*!< this is TRUE when log rec application to |
|
|
|
pages is allowed; this flag tells the |
|
|
|
i/o-handler if it should do log record |
|
|
|
application */ |
|
|
|
ibool apply_batch_on; |
|
|
|
/* this is TRUE when a log rec application |
|
|
|
/*!< this is TRUE when a log rec application |
|
|
|
batch is running */ |
|
|
|
ib_uint64_t lsn; /* log sequence number */ |
|
|
|
ib_uint64_t lsn; /*!< log sequence number */ |
|
|
|
ulint last_log_buf_size; |
|
|
|
/* size of the log buffer when the database |
|
|
|
/*!< size of the log buffer when the database |
|
|
|
last time wrote to the log */ |
|
|
|
byte* last_block; |
|
|
|
/* possible incomplete last recovered log |
|
|
|
/*!< possible incomplete last recovered log |
|
|
|
block */ |
|
|
|
byte* last_block_buf_start; |
|
|
|
/* the nonaligned start address of the |
|
|
|
/*!< the nonaligned start address of the |
|
|
|
preceding buffer */ |
|
|
|
byte* buf; /* buffer for parsing log records */ |
|
|
|
ulint len; /* amount of data in buf */ |
|
|
|
byte* buf; /*!< buffer for parsing log records */ |
|
|
|
ulint len; /*!< amount of data in buf */ |
|
|
|
ib_uint64_t parse_start_lsn; |
|
|
|
/* this is the lsn from which we were able to |
|
|
|
/*!< this is the lsn from which we were able to |
|
|
|
start parsing log records and adding them to |
|
|
|
the hash table; zero if a suitable |
|
|
|
start point not found yet */ |
|
|
|
ib_uint64_t scanned_lsn; |
|
|
|
/* the log data has been scanned up to this |
|
|
|
/*!< the log data has been scanned up to this |
|
|
|
lsn */ |
|
|
|
ulint scanned_checkpoint_no; |
|
|
|
/* the log data has been scanned up to this |
|
|
|
/*!< the log data has been scanned up to this |
|
|
|
checkpoint number (lowest 4 bytes) */ |
|
|
|
ulint recovered_offset; |
|
|
|
/* start offset of non-parsed log records in |
|
|
|
/*!< start offset of non-parsed log records in |
|
|
|
buf */ |
|
|
|
ib_uint64_t recovered_lsn; |
|
|
|
/* the log records have been parsed up to |
|
|
|
/*!< the log records have been parsed up to |
|
|
|
this lsn */ |
|
|
|
ib_uint64_t limit_lsn;/* recovery should be made at most up to this |
|
|
|
lsn */ |
|
|
|
ib_uint64_t limit_lsn;/*!< recovery should be made at most |
|
|
|
up to this lsn */ |
|
|
|
ibool found_corrupt_log; |
|
|
|
/* this is set to TRUE if we during log |
|
|
|
/*!< this is set to TRUE if we during log |
|
|
|
scan find a corrupt log block, or a corrupt |
|
|
|
log record, or there is a log parsing |
|
|
|
buffer overflow */ |
|
|
|
#ifdef UNIV_LOG_ARCHIVE |
|
|
|
log_group_t* archive_group; |
|
|
|
/* in archive recovery: the log group whose |
|
|
|
/*!< in archive recovery: the log group whose |
|
|
|
archive is read */ |
|
|
|
#endif /* !UNIV_LOG_ARCHIVE */ |
|
|
|
mem_heap_t* heap; /* memory heap of log records and file |
|
|
|
mem_heap_t* heap; /*!< memory heap of log records and file |
|
|
|
addresses*/ |
|
|
|
hash_table_t* addr_hash;/* hash table of file addresses of pages */ |
|
|
|
ulint n_addrs;/* number of not processed hashed file |
|
|
|
hash_table_t* addr_hash;/*!< hash table of file addresses of pages */ |
|
|
|
ulint n_addrs;/*!< number of not processed hashed file |
|
|
|
addresses in the hash table */ |
|
|
|
}; |
|
|
|
|
|
|
|
/** The recovery system */ |
|
|
|
extern recv_sys_t* recv_sys; |
|
|
|
|
|
|
|
/** TRUE when applying redo log records during crash recovery; FALSE |
|
|
|
otherwise. Note that this is FALSE while a background thread is |
|
|
|
rolling back incomplete transactions. */ |
|
|
|
extern ibool recv_recovery_on; |
|
|
|
/** If the following is TRUE, the buffer pool file pages must be invalidated |
|
|
|
after recovery and no ibuf operations are allowed; this becomes TRUE if |
|
|
|
the log record hash table becomes too full, and log records must be merged |
|
|
|
to file pages already before the recovery is finished: in this case no |
|
|
|
ibuf operations are allowed, as they could modify the pages read in the |
|
|
|
buffer pool before the pages have been recovered to the up-to-date state. |
|
|
|
|
|
|
|
TRUE means that recovery is running and no operations on the log files |
|
|
|
are allowed yet: the variable name is misleading. */ |
|
|
|
extern ibool recv_no_ibuf_operations; |
|
|
|
/** TRUE when recv_init_crash_recovery() has been called. */ |
|
|
|
extern ibool recv_needed_recovery; |
|
|
|
|
|
|
|
/** TRUE if buf_page_is_corrupted() should check if the log sequence |
|
|
|
number (FIL_PAGE_LSN) is in the future. Initially FALSE, and set by |
|
|
|
recv_recovery_from_checkpoint_start_func(). */ |
|
|
|
extern ibool recv_lsn_checks_on; |
|
|
|
#ifdef UNIV_HOTBACKUP |
|
|
|
/** TRUE when the redo log is being backed up */ |
|
|
|
extern ibool recv_is_making_a_backup; |
|
|
|
#endif /* UNIV_HOTBACKUP */ |
|
|
|
/** Maximum page number encountered in the redo log */ |
|
|
|
extern ulint recv_max_parsed_page_no; |
|
|
|
|
|
|
|
/* Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many |
|
|
|
/** Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many |
|
|
|
times! */ |
|
|
|
#define RECV_PARSING_BUF_SIZE (2 * 1024 * 1024) |
|
|
|
|
|
|
|
/* Size of block reads when the log groups are scanned forward to do a |
|
|
|
/** Size of block reads when the log groups are scanned forward to do a |
|
|
|
roll-forward */ |
|
|
|
#define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE) |
|
|
|
|
|
|
|
/* States of recv_addr_struct */ |
|
|
|
#define RECV_NOT_PROCESSED 71 |
|
|
|
#define RECV_BEING_READ 72 |
|
|
|
#define RECV_BEING_PROCESSED 73 |
|
|
|
#define RECV_PROCESSED 74 |
|
|
|
|
|
|
|
/** This many frames must be left free in the buffer pool when we scan |
|
|
|
the log and store the scanned log records in the buffer pool: we will |
|
|
|
use these free frames to read in pages when we start applying the |
|
|
|
log records to the database. */ |
|
|
|
extern ulint recv_n_pool_free_frames; |
|
|
|
|
|
|
|
#ifndef UNIV_NONINL |
|
|
|