#include "univ.i"
#include "ut0byte.h"
#include "ut0lst.h"
#include "sync0sync.h"
#include "sync0rw.h"
#include "log0log.ic"
Go to the source code of this file.
Classes | |
struct | log_group_struct |
struct | log_struct |
Defines | |
#define | log_do_write TRUE |
#define | LOG_MAX_N_GROUPS 32 |
#define | LOG_FLUSH 7652559 |
#define | LOG_CHECKPOINT 78656949 |
#define | LOG_RECOVER 98887331 |
#define | LOG_START_LSN ((ib_uint64_t) (16 * OS_FILE_LOG_BLOCK_SIZE)) |
#define | LOG_BUFFER_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE) |
#define | LOG_ARCHIVE_BUF_SIZE (srv_log_buffer_size * UNIV_PAGE_SIZE / 4) |
#define | LOG_BLOCK_HDR_NO 0 |
#define | LOG_BLOCK_FLUSH_BIT_MASK 0x80000000UL |
#define | LOG_BLOCK_HDR_DATA_LEN 4 |
#define | LOG_BLOCK_FIRST_REC_GROUP 6 |
#define | LOG_BLOCK_CHECKPOINT_NO 8 |
#define | LOG_BLOCK_HDR_SIZE 12 |
#define | LOG_BLOCK_CHECKSUM 4 |
#define | LOG_BLOCK_TRL_SIZE 4 |
#define | LOG_CHECKPOINT_NO 0 |
#define | LOG_CHECKPOINT_LSN 8 |
#define | LOG_CHECKPOINT_OFFSET 16 |
#define | LOG_CHECKPOINT_LOG_BUF_SIZE 20 |
#define | LOG_CHECKPOINT_ARCHIVED_LSN 24 |
#define | LOG_CHECKPOINT_GROUP_ARRAY 32 |
#define | LOG_CHECKPOINT_ARCHIVED_FILE_NO 0 |
#define | LOG_CHECKPOINT_ARCHIVED_OFFSET 4 |
#define | LOG_CHECKPOINT_ARRAY_END |
#define | LOG_CHECKPOINT_CHECKSUM_1 LOG_CHECKPOINT_ARRAY_END |
#define | LOG_CHECKPOINT_CHECKSUM_2 (4 + LOG_CHECKPOINT_ARRAY_END) |
#define | LOG_CHECKPOINT_FSP_FREE_LIMIT (8 + LOG_CHECKPOINT_ARRAY_END) |
#define | LOG_CHECKPOINT_FSP_MAGIC_N (12 + LOG_CHECKPOINT_ARRAY_END) |
#define | LOG_CHECKPOINT_SIZE (16 + LOG_CHECKPOINT_ARRAY_END) |
#define | LOG_CHECKPOINT_FSP_MAGIC_N_VAL 1441231243 |
#define | LOG_GROUP_ID 0 |
#define | LOG_FILE_START_LSN 4 |
#define | LOG_FILE_NO 12 |
#define | LOG_FILE_WAS_CREATED_BY_HOT_BACKUP 16 |
#define | LOG_FILE_ARCH_COMPLETED OS_FILE_LOG_BLOCK_SIZE |
#define | LOG_FILE_END_LSN (OS_FILE_LOG_BLOCK_SIZE + 4) |
#define | LOG_CHECKPOINT_1 OS_FILE_LOG_BLOCK_SIZE |
#define | LOG_CHECKPOINT_2 (3 * OS_FILE_LOG_BLOCK_SIZE) |
#define | LOG_FILE_HDR_SIZE (4 * OS_FILE_LOG_BLOCK_SIZE) |
#define | LOG_GROUP_OK 301 |
#define | LOG_GROUP_CORRUPTED 302 |
#define | log_flush_order_mutex_own() mutex_own(&log_sys->log_flush_order_mutex) |
#define | log_flush_order_mutex_enter() |
#define | log_flush_order_mutex_exit() |
#define | LOG_NO_WAIT 91 |
#define | LOG_WAIT_ONE_GROUP 92 |
#define | LOG_WAIT_ALL_GROUPS 93 |
Typedefs | |
typedef struct log_struct | log_t |
typedef struct log_group_struct | log_group_t |
Functions | |
UNIV_INTERN void | log_fsp_current_free_limit_set_and_checkpoint (ulint limit) |
UNIV_INTERN ulint | log_calc_where_lsn_is (ib_int64_t *log_file_offset, ib_uint64_t first_header_lsn, ib_uint64_t lsn, ulint n_log_files, ib_int64_t log_file_size) |
UNIV_INLINE ib_uint64_t | log_reserve_and_write_fast (const void *str, ulint len, ib_uint64_t *start_lsn) |
UNIV_INLINE void | log_release (void) |
UNIV_INLINE void | log_free_check (void) |
UNIV_INTERN ib_uint64_t | log_reserve_and_open (ulint len) |
UNIV_INTERN void | log_write_low (byte *str, ulint str_len) |
UNIV_INTERN ib_uint64_t | log_close (void) |
UNIV_INLINE ib_uint64_t | log_get_lsn (void) |
UNIV_INLINE ulint | log_get_capacity (void) |
UNIV_INTERN void | log_init (void) |
UNIV_INTERN void | log_group_init (ulint id, ulint n_files, ulint file_size, ulint space_id, ulint archive_space_id) |
UNIV_INTERN void | log_io_complete (log_group_t *group) |
UNIV_INTERN void | log_write_up_to (ib_uint64_t lsn, ulint wait, ibool flush_to_disk) |
UNIV_INTERN void | log_buffer_flush_to_disk (void) |
UNIV_INTERN void | log_buffer_sync_in_background (ibool flush) |
UNIV_INTERN ibool | log_preflush_pool_modified_pages (ib_uint64_t new_oldest, ibool sync) |
UNIV_INTERN ibool | log_checkpoint (ibool sync, ibool write_always) |
UNIV_INTERN void | log_make_checkpoint_at (ib_uint64_t lsn, ibool write_always) |
UNIV_INTERN void | logs_empty_and_mark_files_at_shutdown (void) |
UNIV_INTERN void | log_group_read_checkpoint_info (log_group_t *group, ulint field) |
UNIV_INTERN void | log_checkpoint_get_nth_group_info (const byte *buf, ulint n, ulint *file_no, ulint *offset) |
UNIV_INTERN void | log_groups_write_checkpoint_info (void) |
UNIV_INTERN ibool | log_archive_do (ibool sync, ulint *n_bytes) |
UNIV_INTERN ulint | log_archive_stop (void) |
UNIV_INTERN ulint | log_archive_start (void) |
UNIV_INTERN ulint | log_archive_noarchivelog (void) |
UNIV_INTERN ulint | log_archive_archivelog (void) |
UNIV_INTERN void | log_archived_file_name_gen (char *buf, ulint id, ulint file_no) |
UNIV_INTERN void | log_check_margins (void) |
UNIV_INTERN void | log_group_read_log_seg (ulint type, byte *buf, log_group_t *group, ib_uint64_t start_lsn, ib_uint64_t end_lsn) |
UNIV_INTERN void | log_group_write_buf (log_group_t *group, byte *buf, ulint len, ib_uint64_t start_lsn, ulint new_data_offset) |
UNIV_INTERN void | log_group_set_fields (log_group_t *group, ib_uint64_t lsn) |
UNIV_INTERN ulint | log_group_get_capacity (const log_group_t *group) |
UNIV_INLINE ibool | log_block_get_flush_bit (const byte *log_block) |
UNIV_INLINE ulint | log_block_get_hdr_no (const byte *log_block) |
UNIV_INLINE ulint | log_block_get_data_len (const byte *log_block) |
UNIV_INLINE void | log_block_set_data_len (byte *log_block, ulint len) |
UNIV_INLINE ulint | log_block_calc_checksum (const byte *block) |
UNIV_INLINE ulint | log_block_get_checksum (const byte *log_block) |
UNIV_INLINE void | log_block_set_checksum (byte *log_block, ulint checksum) |
UNIV_INLINE ulint | log_block_get_first_rec_group (const byte *log_block) |
UNIV_INLINE void | log_block_set_first_rec_group (byte *log_block, ulint offset) |
UNIV_INLINE ulint | log_block_get_checkpoint_no (const byte *log_block) |
UNIV_INLINE void | log_block_init (byte *log_block, ib_uint64_t lsn) |
UNIV_INLINE void | log_block_init_in_old_format (byte *log_block, ib_uint64_t lsn) |
UNIV_INLINE ulint | log_block_convert_lsn_to_no (ib_uint64_t lsn) |
UNIV_INTERN void | log_print (FILE *file) |
UNIV_INTERN ibool | log_peek_lsn (ib_uint64_t *lsn) |
UNIV_INTERN void | log_refresh_stats (void) |
UNIV_INTERN void | log_shutdown (void) |
UNIV_INTERN void | log_mem_free (void) |
Variables | |
log_t * | log_sys |
#define LOG_CHECKPOINT_ARRAY_END |
(LOG_CHECKPOINT_GROUP_ARRAY\ + LOG_MAX_N_GROUPS * 8)
#define log_do_write TRUE |
Write to log
Definition at line 57 of file log0log.h.
Referenced by innobase_start_or_create_for_mysql(), and log_group_write_buf().
#define log_flush_order_mutex_enter | ( | ) |
do { \ mutex_enter(&log_sys->log_flush_order_mutex); \ } while (0)
Acquire the flush order mutex.
Definition at line 970 of file log0log.h.
Referenced by buf_pool_get_oldest_modification(), mtr_memo_release(), and recv_recover_page_func().
#define log_flush_order_mutex_exit | ( | ) |
do { \ mutex_exit(&log_sys->log_flush_order_mutex); \ } while (0)
Release the flush order mutex.
Definition at line 974 of file log0log.h.
Referenced by buf_pool_get_oldest_modification(), mtr_memo_release(), and recv_recover_page_func().
#define log_flush_order_mutex_own | ( | ) | mutex_own(&log_sys->log_flush_order_mutex) |
#define LOG_MAX_N_GROUPS 32 |
Maximum number of log groups in log_group_struct::checkpoint_buf
Definition at line 66 of file log0log.h.
Referenced by log_checkpoint_get_nth_group_info().
#define LOG_NO_WAIT 91 |
Wait modes for log_write_up_to
Definition at line 61 of file log0log.h.
Referenced by log_buffer_sync_in_background(), and log_write_up_to().
typedef struct log_group_struct log_group_t |
typedef struct log_struct log_t |
UNIV_INTERN ulint log_archive_archivelog | ( | void | ) |
Start archiving the log so that a gap may occur in the archived log files.
Referenced by innobase_start_or_create_for_mysql().
UNIV_INTERN ibool log_archive_do | ( | ibool | sync, |
ulint * | n_bytes | ||
) |
Starts an archiving operation.
sync | in: TRUE if synchronous operation is desired |
Referenced by log_reserve_and_open().
UNIV_INTERN ulint log_archive_noarchivelog | ( | void | ) |
Stop archiving the log so that a gap may occur in the archived log files.
Referenced by innobase_start_or_create_for_mysql().
UNIV_INTERN ulint log_archive_start | ( | void | ) |
Starts again archiving which has been stopped.
UNIV_INTERN ulint log_archive_stop | ( | void | ) |
Writes the log contents to the archive up to the lsn when this function was called, and stops the archiving. When archiving is started again, the archived log file numbers start from a number one higher, so that the archiving will not write again to the archived log files which exist when this function returns.
UNIV_INTERN void log_archived_file_name_gen | ( | char * | buf, |
ulint | id, | ||
ulint | file_no | ||
) |
Generates an archived log file name. in: file number
buf | in: buffer where to write |
id | in: group id |
UNIV_INLINE ulint log_block_calc_checksum | ( | const byte * | block | ) |
Calculates the checksum for a log block.
Referenced by recv_scan_log_recs().
UNIV_INLINE ulint log_block_convert_lsn_to_no | ( | ib_uint64_t | lsn | ) |
Converts a lsn to a log block number.
Referenced by log_group_write_buf(), and recv_scan_log_recs().
UNIV_INLINE ulint log_block_get_checkpoint_no | ( | const byte * | log_block | ) |
Gets a log block checkpoint number field (4 lowest bytes).
Referenced by recv_scan_log_recs().
UNIV_INLINE ulint log_block_get_checksum | ( | const byte * | log_block | ) |
Gets a log block checksum field value.
Referenced by recv_scan_log_recs().
UNIV_INLINE ulint log_block_get_data_len | ( | const byte * | log_block | ) |
Gets a log block data length.
Referenced by log_close(), and recv_scan_log_recs().
UNIV_INLINE ulint log_block_get_first_rec_group | ( | const byte * | log_block | ) |
Gets a log block first mtr log record group offset.
Referenced by log_close(), and recv_scan_log_recs().
UNIV_INLINE ibool log_block_get_flush_bit | ( | const byte * | log_block | ) |
Gets a log block flush bit.
Referenced by recv_scan_log_recs().
UNIV_INLINE ulint log_block_get_hdr_no | ( | const byte * | log_block | ) |
Gets a log block number stored in the header.
Referenced by log_group_write_buf(), and recv_scan_log_recs().
UNIV_INLINE void log_block_init | ( | byte * | log_block, |
ib_uint64_t | lsn | ||
) |
Initializes a log block in the log buffer. in: lsn within the log block
log_block | in: pointer to the log buffer |
Referenced by log_init(), log_write_low(), and recv_reset_logs().
UNIV_INLINE void log_block_init_in_old_format | ( | byte * | log_block, |
ib_uint64_t | lsn | ||
) |
Initializes a log block in the log buffer in the old, < 3.23.52 format, where there was no checksum yet. in: lsn within the log block
log_block | in: pointer to the log buffer |
UNIV_INLINE void log_block_set_checksum | ( | byte * | log_block, |
ulint | checksum | ||
) |
Sets a log block checksum field value. in: checksum
log_block | in/out: log block |
UNIV_INLINE void log_block_set_data_len | ( | byte * | log_block, |
ulint | len | ||
) |
Sets the log block data length. in: data length
log_block | in/out: log block |
Referenced by log_write_low().
UNIV_INLINE void log_block_set_first_rec_group | ( | byte * | log_block, |
ulint | offset | ||
) |
Sets the log block first mtr log record group offset. in: offset, 0 if none
log_block | in/out: log block |
Referenced by log_close(), log_init(), and recv_reset_logs().
UNIV_INTERN void log_buffer_flush_to_disk | ( | void | ) |
Does a syncronous flush of the log buffer to disk.
Definition at line 1562 of file log0log.cc.
References log_buffer_flush_to_disk(), log_write_up_to(), log_struct::lsn, and log_struct::mutex.
Referenced by InnobaseEngine::doCreateTable(), InnobaseEngine::doDropSchema(), InnobaseEngine::doDropTable(), InnobaseEngine::flush_logs(), innobase_rename_table(), innobase_start_or_create_for_mysql(), log_buffer_flush_to_disk(), log_reserve_and_open(), and logs_empty_and_mark_files_at_shutdown().
UNIV_INTERN void log_buffer_sync_in_background | ( | ibool | flush | ) |
This functions writes the log buffer to the log file and if 'flush' is set it forces a flush of the log file as well. This is meant to be called from background master thread only as it does not wait for the write (+ possible flush) to finish.
flush | in: flush the logs to disk |
Definition at line 1583 of file log0log.cc.
References log_buffer_sync_in_background(), LOG_NO_WAIT, log_write_up_to(), log_struct::lsn, and log_struct::mutex.
Referenced by log_buffer_sync_in_background().
UNIV_INTERN ulint log_calc_where_lsn_is | ( | ib_int64_t * | log_file_offset, |
ib_uint64_t | first_header_lsn, | ||
ib_uint64_t | lsn, | ||
ulint | n_log_files, | ||
ib_int64_t | log_file_size | ||
) |
Calculates where in log files we find a specified lsn.
Calculates where in log files we find a specified lsn.
log_file_offset | out: offset in that file (including the header) |
first_header_lsn | in: first log file start lsn |
lsn | in: lsn whose position to determine |
n_log_files | in: total number of log files |
log_file_size | in: log file size (including the header) |
Definition at line 601 of file log0log.cc.
References log_calc_where_lsn_is(), and ut_a.
Referenced by log_calc_where_lsn_is().
UNIV_INTERN void log_check_margins | ( | void | ) |
Checks that there is enough free space in the log to start a new query step. Flushes the log buffer or makes a new checkpoint if necessary. NOTE: this function may only be called if the calling thread owns no synchronization objects!
Definition at line 3046 of file log0log.cc.
References log_struct::check_flush_or_checkpoint, log_check_margins(), log_struct::mutex, and ut_ad.
Referenced by log_check_margins().
UNIV_INTERN ibool log_checkpoint | ( | ibool | sync, |
ibool | write_always | ||
) |
Makes a checkpoint. Note that this function does not flush dirty blocks from the buffer pool: it only checks what is lsn of the oldest modification in the pool, and writes information about the lsn in log files. Use log_make_checkpoint_at to flush also the pool.
Makes a checkpoint. Note that this function does not flush dirty blocks from the buffer pool: it only checks what is lsn of the oldest modification in the pool, and writes information about the lsn in log files. Use log_make_checkpoint_at to flush also the pool.
sync | in: TRUE if synchronous operation is desired |
write_always | in: the function normally checks if the the new checkpoint would have a greater lsn than the previous one: if not, then no physical write is done; by setting this parameter TRUE, a physical write will always be made to log files |
Definition at line 1971 of file log0log.cc.
References log_struct::checkpoint_lock, FIL_TABLESPACE, log_struct::flushed_to_disk_lsn, log_struct::last_checkpoint_lsn, log_checkpoint(), log_groups_write_checkpoint_info(), log_write_up_to(), log_struct::mutex, log_struct::n_pending_checkpoint_writes, log_struct::next_checkpoint_lsn, log_struct::next_checkpoint_no, recv_apply_hashed_log_recs(), recv_recovery_is_on(), rw_lock_s_lock, SRV_UNIX_NOSYNC, and ut_ad.
Referenced by log_checkpoint(), log_fsp_current_free_limit_set_and_checkpoint(), log_make_checkpoint_at(), and srv_master_thread().
UNIV_INTERN void log_checkpoint_get_nth_group_info | ( | const byte * | buf, |
ulint | n, | ||
ulint * | file_no, | ||
ulint * | offset | ||
) |
Gets info from a checkpoint about a log group. out: archived file offset
Gets info from a checkpoint about a log group.
buf | in: buffer containing checkpoint info |
n | in: nth slot |
file_no | out: archived file number |
offset | out: archived file offset |
Definition at line 1734 of file log0log.cc.
References log_checkpoint_get_nth_group_info(), LOG_MAX_N_GROUPS, mach_read_from_4(), and ut_ad.
Referenced by log_checkpoint_get_nth_group_info(), and recv_recovery_from_checkpoint_start_func().
UNIV_INTERN ib_uint64_t log_close | ( | void | ) |
Closes the log.
Definition at line 368 of file log0log.cc.
References log_struct::buf, log_struct::buf_free, log_struct::check_flush_or_checkpoint, log_struct::last_checkpoint_lsn, log_block_get_data_len(), log_block_get_first_rec_group(), log_block_set_first_rec_group(), log_close(), log_struct::log_group_capacity, log_struct::lsn, log_struct::max_buf_free, log_struct::max_checkpoint_age_async, log_struct::max_modified_age_async, log_struct::mutex, log_struct::old_buf_free, log_struct::old_lsn, OS_FILE_LOG_BLOCK_SIZE, ut_ad, ut_align_down(), and ut_print_timestamp().
Referenced by log_close().
UNIV_INLINE void log_free_check | ( | void | ) |
Checks if there is need for a log buffer flush or a new checkpoint, and does this if yes. Any database operation should call this when it has modified more than about 4 pages. NOTE that this function may only be called when the OS thread owns no synchronization objects except the dictionary mutex.
Referenced by row_undo_ins(), and srv_master_thread().
UNIV_INTERN void log_fsp_current_free_limit_set_and_checkpoint | ( | ulint | limit | ) |
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint, so that we know that the limit has been written to a log checkpoint field on disk. in: limit to set
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint, so that we know that the limit has been written to a log checkpoint field on disk.
limit | in: limit to set |
Definition at line 174 of file log0log.cc.
References log_checkpoint(), log_fsp_current_free_limit_set_and_checkpoint(), and log_struct::mutex.
Referenced by fsp_header_get_free_limit(), and log_fsp_current_free_limit_set_and_checkpoint().
UNIV_INLINE ib_uint64_t log_get_lsn | ( | void | ) |
Gets the current lsn.
Referenced by row_import_tablespace_for_mysql(), and srv_error_monitor_thread().
UNIV_INTERN ulint log_group_get_capacity | ( | const log_group_t * | group | ) |
Calculates the data capacity of a log group, when the log file headers are not included.
Calculates the data capacity of a log group, when the log file headers are not included.
group | in: log group |
Definition at line 495 of file log0log.cc.
References log_group_struct::file_size, log_group_get_capacity(), log_struct::mutex, log_group_struct::n_files, and ut_ad.
Referenced by log_group_get_capacity(), and recv_recovery_from_checkpoint_start_func().
UNIV_INTERN void log_group_init | ( | ulint | id, |
ulint | n_files, | ||
ulint | file_size, | ||
ulint | space_id, | ||
ulint | |||
) |
Inits a log group to the log system. in: space id of the file space which contains some archived log files for this group; currently, only for the first log group this is used
Inits a log group to the log system.
id | in: group id |
n_files | in: number of log files |
file_size | in: log file size in bytes |
space_id | in: space id of the file space which contains the log files of this group |
Definition at line 892 of file log0log.cc.
References log_group_struct::checkpoint_buf, log_group_struct::checkpoint_buf_ptr, log_group_struct::file_header_bufs, log_group_struct::file_header_bufs_ptr, log_group_struct::file_size, log_group_struct::id, log_group_init(), log_struct::log_groups, log_group_struct::lsn, log_group_struct::lsn_offset, log_group_struct::n_files, log_group_struct::n_pending_writes, OS_FILE_LOG_BLOCK_SIZE, log_group_struct::space_id, log_group_struct::state, ut_a, ut_align(), and UT_LIST_ADD_LAST.
Referenced by log_group_init().
UNIV_INTERN void log_group_read_checkpoint_info | ( | log_group_t * | group, |
ulint | field | ||
) |
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. in: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf.
group | in: log group |
field | in: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2 |
Definition at line 1929 of file log0log.cc.
References log_struct::checkpoint_buf, log_group_read_checkpoint_info(), log_struct::mutex, log_struct::n_log_ios, OS_FILE_LOG_BLOCK_SIZE, OS_FILE_READ, log_group_struct::space_id, and ut_ad.
Referenced by log_group_read_checkpoint_info(), and recv_recovery_from_checkpoint_start_func().
UNIV_INTERN void log_group_read_log_seg | ( | ulint | type, |
byte * | buf, | ||
log_group_t * | group, | ||
ib_uint64_t | start_lsn, | ||
ib_uint64_t | end_lsn | ||
) |
Reads a specified log segment to a buffer. in: read area end
Reads a specified log segment to a buffer.
type | in: LOG_ARCHIVE or LOG_RECOVER |
buf | in: buffer where to read |
group | in: log group |
start_lsn | in: read area start |
end_lsn | in: read area end |
Definition at line 2189 of file log0log.cc.
References log_group_struct::file_size, log_group_read_log_seg(), log_struct::mutex, log_struct::n_log_ios, OS_FILE_READ, log_group_struct::space_id, and ut_ad.
Referenced by log_group_read_log_seg().
UNIV_INTERN void log_group_set_fields | ( | log_group_t * | group, |
ib_uint64_t | lsn | ||
) |
Sets the field values in group to correspond to a given lsn. For this function to work, the values must already be correctly initialized to correspond to some lsn, for instance, a checkpoint lsn. in: lsn for which the values should be set
Sets the field values in group to correspond to a given lsn. For this function to work, the values must already be correctly initialized to correspond to some lsn, for instance, a checkpoint lsn.
group | in/out: group |
lsn | in: lsn for which the values should be set |
Definition at line 643 of file log0log.cc.
References log_group_set_fields(), log_group_struct::lsn, and log_group_struct::lsn_offset.
Referenced by log_group_set_fields(), and log_write_up_to().
UNIV_INTERN void log_group_write_buf | ( | log_group_t * | group, |
byte * | buf, | ||
ulint | len, | ||
ib_uint64_t | start_lsn, | ||
ulint | new_data_offset | ||
) |
Writes a buffer to a log file group. in: start offset of new data in buf: this parameter is used to decide if we have to write a new log file header
Writes a buffer to a log file group.
group | in: log group |
buf | in: buffer |
len | in: buffer len; must be divisible by OS_FILE_LOG_BLOCK_SIZE |
start_lsn | in: start lsn of the buffer; must be divisible by OS_FILE_LOG_BLOCK_SIZE |
new_data_offset | in: start offset of new data in buf: this parameter is used to decide if we have to write a new log file header |
Definition at line 1217 of file log0log.cc.
References log_group_struct::file_size, log_group_struct::id, log_block_convert_lsn_to_no(), log_block_get_hdr_no(), log_do_write, log_group_write_buf(), log_struct::mutex, log_struct::n_log_ios, OS_FILE_LOG_BLOCK_SIZE, log_group_struct::space_id, ut_a, and ut_ad.
Referenced by log_group_write_buf(), and log_write_up_to().
UNIV_INTERN void log_groups_write_checkpoint_info | ( | void | ) |
Writes checkpoint info to groups.
Definition at line 1947 of file log0log.cc.
References log_struct::log_groups, log_groups_write_checkpoint_info(), log_struct::mutex, ut_ad, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.
Referenced by log_checkpoint(), and log_groups_write_checkpoint_info().
UNIV_INTERN void log_init | ( | void | ) |
Initializes the log.
Definition at line 768 of file log0log.cc.
References log_struct::adm_checkpoint_interval, log_struct::buf, log_struct::buf_free, log_struct::buf_next_to_write, buf_pool_get_curr_size(), log_struct::buf_size, log_struct::check_flush_or_checkpoint, log_struct::checkpoint_buf, log_struct::checkpoint_lock, log_struct::current_flush_lsn, log_struct::flushed_to_disk_lsn, log_struct::last_checkpoint_lsn, log_struct::last_printout_time, recv_sys_struct::limit_lsn, log_block_init(), log_block_set_first_rec_group(), log_struct::log_flush_order_mutex, log_struct::log_groups, log_init(), log_struct::lsn, log_struct::max_buf_free, log_struct::mutex, log_struct::n_log_ios, log_struct::n_log_ios_old, log_struct::n_pending_checkpoint_writes, log_struct::n_pending_writes, log_struct::next_checkpoint_no, log_struct::no_flush_event, log_struct::one_flushed_event, os_event_create(), os_event_set(), OS_FILE_LOG_BLOCK_SIZE, recv_sys_struct::parse_start_lsn, recv_sys_struct::recovered_lsn, recv_sys, recv_sys_create(), recv_sys_init(), rw_lock_create, recv_sys_struct::scanned_checkpoint_no, recv_sys_struct::scanned_lsn, ut_a, ut_align(), UT_LIST_INIT, log_struct::write_lsn, log_struct::written_to_all_lsn, and log_struct::written_to_some_lsn.
Referenced by innobase_start_or_create_for_mysql(), and log_init().
UNIV_INTERN void log_io_complete | ( | log_group_t * | group | ) |
Completes an i/o to a log file. in: log group
Completes an i/o to a log file.
< We currently use synchronous writing of the logs and cannot end up here!
group | in: log group or a dummy pointer |
Definition at line 1084 of file log0log.cc.
References log_group_struct::id, log_io_complete(), log_struct::mutex, log_struct::n_pending_writes, log_group_struct::n_pending_writes, log_group_struct::space_id, SRV_UNIX_NOSYNC, SRV_UNIX_O_DSYNC, ut_a, ut_ad, and ut_error.
Referenced by fil_aio_wait(), and log_io_complete().
UNIV_INTERN void log_make_checkpoint_at | ( | ib_uint64_t | lsn, |
ibool | write_always | ||
) |
Makes a checkpoint at a given lsn or later. in: the function normally checks if the the new checkpoint would have a greater lsn than the previous one: if not, then no physical write is done; by setting this parameter TRUE, a physical write will always be made to log files
Makes a checkpoint at a given lsn or later.
lsn | in: make a checkpoint at this or a later lsn, if IB_ULONGLONG_MAX, makes a checkpoint at the latest lsn |
write_always | in: the function normally checks if the the new checkpoint would have a greater lsn than the previous one: if not, then no physical write is done; by setting this parameter TRUE, a physical write will always be made to log files |
Definition at line 2062 of file log0log.cc.
References log_checkpoint(), log_make_checkpoint_at(), and log_preflush_pool_modified_pages().
Referenced by log_make_checkpoint_at(), logs_empty_and_mark_files_at_shutdown(), recv_reset_logs(), trx_sys_create_doublewrite_buf(), and trx_sys_mark_upgraded_to_multiple_tablespaces().
UNIV_INTERN ibool log_peek_lsn | ( | ib_uint64_t * | lsn | ) |
Peeks the current lsn.
Peeks the current lsn.
lsn | out: if returns TRUE, current lsn is here |
Definition at line 3316 of file log0log.cc.
References log_peek_lsn(), log_struct::lsn, and log_struct::mutex.
Referenced by buf_page_is_corrupted(), and log_peek_lsn().
UNIV_INTERN ibool log_preflush_pool_modified_pages | ( | ib_uint64_t | new_oldest, |
ibool | sync | ||
) |
Advances the smallest lsn for which there are unflushed dirty blocks in the buffer pool and also may make a new checkpoint. NOTE: this function may only be called if the calling thread owns no synchronization objects!
Advances the smallest lsn for which there are unflushed dirty blocks in the buffer pool. NOTE: this function may only be called if the calling thread owns no synchronization objects!
new_oldest | in: try to advance oldest_modified_lsn at least to this lsn |
sync | in: TRUE if synchronous operation is desired |
Definition at line 1637 of file log0log.cc.
References BUF_FLUSH_LIST, log_preflush_pool_modified_pages(), recv_apply_hashed_log_recs(), and recv_recovery_on.
Referenced by log_make_checkpoint_at(), and log_preflush_pool_modified_pages().
UNIV_INTERN void log_print | ( | FILE * | file | ) |
Prints info of the log. in: file where to print
Prints info of the log.
file | in: file where to print |
Definition at line 3335 of file log0log.cc.
References log_struct::flushed_to_disk_lsn, log_struct::last_checkpoint_lsn, log_struct::last_printout_time, log_print(), log_struct::lsn, log_struct::mutex, log_struct::n_log_ios, log_struct::n_log_ios_old, log_struct::n_pending_checkpoint_writes, and log_struct::n_pending_writes.
Referenced by log_print(), and srv_printf_innodb_monitor().
UNIV_INTERN void log_refresh_stats | ( | void | ) |
Refreshes the statistics used to print per-second averages.
Definition at line 3375 of file log0log.cc.
References log_struct::last_printout_time, log_refresh_stats(), log_struct::n_log_ios, and log_struct::n_log_ios_old.
Referenced by log_refresh_stats().
UNIV_INLINE void log_release | ( | void | ) |
Releases the log mutex.
UNIV_INTERN ib_uint64_t log_reserve_and_open | ( | ulint | len | ) |
Opens the log for log_write_low. The log must be closed with log_close and released with log_release.
Opens the log for log_write_low. The log must be closed with log_close and released with log_release.
len | in: length of data to be catenated |
Definition at line 224 of file log0log.cc.
References log_struct::buf_free, log_struct::buf_size, log_archive_do(), log_buffer_flush_to_disk(), log_reserve_and_open(), log_struct::lsn, log_struct::mutex, log_struct::old_buf_free, log_struct::old_lsn, ut_a, and ut_ad.
Referenced by log_reserve_and_open().
UNIV_INLINE ib_uint64_t log_reserve_and_write_fast | ( | const void * | str, |
ulint | len, | ||
ib_uint64_t * | start_lsn | ||
) |
Writes to the log the string given. The log must be released with log_release.
str | in: string |
len | in: string length |
UNIV_INTERN void log_write_low | ( | byte * | str, |
ulint | str_len | ||
) |
Writes to the log the string given. It is assumed that the caller holds the log mutex. in: string length
Writes to the log the string given. It is assumed that the caller holds the log mutex.
str | in: string |
str_len | in: string length |
Definition at line 298 of file log0log.cc.
References log_struct::buf, log_struct::buf_free, log_struct::buf_size, log_block_init(), log_block_set_data_len(), log_write_low(), log_struct::lsn, log_struct::mutex, log_struct::next_checkpoint_no, OS_FILE_LOG_BLOCK_SIZE, ut_ad, ut_align_down(), and ut_memcpy().
Referenced by log_write_low().
UNIV_INTERN void log_write_up_to | ( | ib_uint64_t | lsn, |
ulint | wait, | ||
ibool | flush_to_disk | ||
) |
This function is called, e.g., when a transaction wants to commit. It checks that the log has been written to the log file up to the last log entry written by the transaction. If there is a flush running, it waits and checks if the flush flushed enough. If not, starts a new flush. in: TRUE if we want the written log also to be flushed to disk
This function is called, e.g., when a transaction wants to commit. It checks that the log has been written to the log file up to the last log entry written by the transaction. If there is a flush running, it waits and checks if the flush flushed enough. If not, starts a new flush.
< We assume here that we have only one log group!
lsn | in: log sequence number up to which the log should be written, IB_ULONGLONG_MAX if not specified |
wait | in: LOG_NO_WAIT, LOG_WAIT_ONE_GROUP, or LOG_WAIT_ALL_GROUPS |
flush_to_disk | in: TRUE if we want the written log also to be flushed to disk |
Definition at line 1338 of file log0log.cc.
References log_struct::buf, log_struct::buf_free, log_struct::buf_next_to_write, log_struct::current_flush_lsn, log_struct::flushed_to_disk_lsn, log_group_set_fields(), log_group_write_buf(), log_struct::log_groups, LOG_NO_WAIT, log_write_up_to(), log_struct::lsn, log_struct::mutex, log_group_struct::n_pending_writes, log_struct::n_pending_writes, log_struct::next_checkpoint_no, log_struct::no_flush_event, log_struct::one_flushed, log_struct::one_flushed_event, os_event_reset(), OS_FILE_LOG_BLOCK_SIZE, recv_no_ibuf_operations, log_group_struct::space_id, SRV_UNIX_O_DSYNC, ut_a, ut_ad, ut_calc_align, ut_calc_align_down, ut_error, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, ut_memcpy(), ut_uint64_align_down(), log_struct::write_end_offset, log_struct::write_lsn, log_struct::written_to_all_lsn, and log_struct::written_to_some_lsn.
Referenced by log_buffer_flush_to_disk(), log_buffer_sync_in_background(), log_checkpoint(), log_write_up_to(), trx_commit_complete_for_mysql(), and trx_commit_off_kernel().
UNIV_INTERN void logs_empty_and_mark_files_at_shutdown | ( | void | ) |
Makes a checkpoint at the latest lsn and writes it to first page of each data file in the database, so that we know that the file spaces contain all modifications up to that lsn. This can only be called at database shutdown. This function also writes all log in log files to the log archive.
Definition at line 3078 of file log0log.cc.
References FIL_LOG, FIL_TABLESPACE, log_struct::last_checkpoint_lsn, log_buffer_flush_to_disk(), log_struct::log_groups, log_make_checkpoint_at(), logs_empty_and_mark_files_at_shutdown(), log_struct::lsn, log_struct::mutex, log_struct::n_pending_checkpoint_writes, log_struct::n_pending_writes, os_event_set(), os_thread_sleep(), srv_is_any_background_thread_active(), SRV_SHUTDOWN_CLEANUP, SRV_SHUTDOWN_LAST_PHASE, srv_shutdown_lsn, srv_start_lsn, trx_n_mysql_transactions, trx_sys, ut_a, UT_LIST_GET_FIRST, UT_LIST_GET_LEN, and ut_print_timestamp().
Referenced by innobase_shutdown_for_mysql(), and logs_empty_and_mark_files_at_shutdown().