MySQL 5.6.14 Source Code Document
|
#include "log0log.h"
#include "mem0mem.h"
#include "buf0buf.h"
#include "buf0flu.h"
#include "srv0srv.h"
#include "log0recv.h"
#include "fil0fil.h"
#include "dict0boot.h"
#include "srv0start.h"
#include "trx0sys.h"
#include "trx0trx.h"
#include "srv0mon.h"
Go to the source code of this file.
Macros | |
#define | LOG_BUF_WRITE_MARGIN (4 * OS_FILE_LOG_BLOCK_SIZE) |
#define | LOG_BUF_FLUSH_RATIO 2 |
#define | LOG_BUF_FLUSH_MARGIN (LOG_BUF_WRITE_MARGIN + 4 * UNIV_PAGE_SIZE) |
#define | LOG_CHECKPOINT_FREE_PER_THREAD (4 * UNIV_PAGE_SIZE) |
#define | LOG_CHECKPOINT_EXTRA_FREE (8 * UNIV_PAGE_SIZE) |
#define | LOG_POOL_CHECKPOINT_RATIO_ASYNC 32 |
#define | LOG_POOL_PREFLUSH_RATIO_SYNC 16 |
#define | LOG_POOL_PREFLUSH_RATIO_ASYNC 8 |
#define | LOG_ARCHIVE_EXTRA_MARGIN (4 * UNIV_PAGE_SIZE) |
#define | LOG_ARCHIVE_RATIO_ASYNC 16 |
#define | LOG_UNLOCK_NONE_FLUSHED_LOCK 1 |
#define | LOG_UNLOCK_FLUSH_LOCK 2 |
#define | LOG_ARCHIVE_READ 1 |
#define | LOG_ARCHIVE_WRITE 2 |
Functions | |
UNIV_INTERN lsn_t | log_reserve_and_open (ulint len) |
UNIV_INTERN void | log_write_low (byte *str, ulint str_len) |
UNIV_INTERN lsn_t | log_close (void) |
UNIV_INTERN lsn_t | log_group_get_capacity (const log_group_t *group) |
UNIV_INLINE lsn_t | log_group_calc_size_offset (lsn_t offset, const log_group_t *group) |
UNIV_INLINE lsn_t | log_group_calc_real_offset (lsn_t offset, const log_group_t *group) |
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_INTERN void | log_group_set_fields (log_group_t *group, lsn_t lsn) |
UNIV_INTERN void | log_init (void) |
UNIV_INTERN void | log_group_init (ulint id, ulint n_files, lsn_t file_size, ulint space_id, ulint archive_space_id __attribute__((unused))) |
UNIV_INLINE void | log_flush_do_unlocks (ulint code) |
UNIV_INLINE ulint | log_group_check_flush_completion (log_group_t *group) |
UNIV_INTERN void | log_io_complete (log_group_t *group) |
UNIV_INTERN void | log_group_write_buf (log_group_t *group, byte *buf, ulint len, lsn_t start_lsn, ulint new_data_offset) |
UNIV_INTERN void | log_write_up_to (lsn_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 void | log_checkpoint_get_nth_group_info (const byte *buf, ulint n, ulint *file_no, ulint *offset) |
UNIV_INTERN void | log_group_read_checkpoint_info (log_group_t *group, ulint field) |
UNIV_INTERN void | log_groups_write_checkpoint_info (void) |
UNIV_INTERN ibool | log_checkpoint (ibool sync, ibool write_always) |
UNIV_INTERN void | log_make_checkpoint_at (lsn_t lsn, ibool write_always) |
UNIV_INTERN void | log_group_read_log_seg (ulint type, byte *buf, log_group_t *group, lsn_t start_lsn, lsn_t end_lsn) |
UNIV_INTERN void | log_check_margins (void) |
UNIV_INTERN void | logs_empty_and_mark_files_at_shutdown (void) |
UNIV_INTERN ibool | log_peek_lsn (lsn_t *lsn) |
UNIV_INTERN void | log_print (FILE *file) |
UNIV_INTERN void | log_refresh_stats (void) |
UNIV_INTERN void | log_group_close_all (void) |
UNIV_INTERN void | log_shutdown (void) |
UNIV_INTERN void | log_mem_free (void) |
Variables | |
UNIV_INTERN log_t * | log_sys = NULL |
UNIV_INTERN ibool | log_has_printed_chkp_warning = FALSE |
UNIV_INTERN time_t | log_last_warning_time |
UNIV_INTERN void log_buffer_flush_to_disk | ( | void | ) |
Does a syncronous flush of the log buffer to disk.
Definition at line 1549 of file log0log.cc.
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 1571 of file log0log.cc.
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.
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 567 of file log0log.cc.
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 3054 of file log0log.cc.
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.
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 1966 of file log0log.cc.
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.
buf | in: buffer containing checkpoint info |
n | in: nth slot |
file_no | out: archived file number |
offset | out: archived file offset |
Definition at line 1726 of file log0log.cc.
UNIV_INTERN lsn_t log_close | ( | void | ) |
Closes the log.
Definition at line 338 of file log0log.cc.
UNIV_INLINE void log_flush_do_unlocks | ( | ulint | code | ) |
Does the unlockings needed in flush i/o completion.
code | in: any ORed combination of LOG_UNLOCK_FLUSH_LOCK and LOG_UNLOCK_NONE_FLUSHED_LOCK |
Definition at line 946 of file log0log.cc.
UNIV_INLINE lsn_t log_group_calc_real_offset | ( | lsn_t | offset, |
const log_group_t * | group | ||
) |
Calculates the offset within a log group, when the log file headers are included.
offset | in: size offset within the log group |
group | in: log group |
Definition at line 499 of file log0log.cc.
UNIV_INLINE lsn_t log_group_calc_size_offset | ( | lsn_t | offset, |
const log_group_t * | group | ||
) |
Calculates the offset within a log group, when the log file headers are not included.
offset | in: real offset within the log group |
group | in: log group |
Definition at line 482 of file log0log.cc.
UNIV_INLINE ulint log_group_check_flush_completion | ( | log_group_t * | group | ) |
Checks if a flush is completed for a log group and does the completion routine if yes.
group | in: log group |
Definition at line 979 of file log0log.cc.
UNIV_INTERN void log_group_close_all | ( | void | ) |
Closes all log groups.
Definition at line 3555 of file log0log.cc.
UNIV_INTERN lsn_t 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.
group | in: log group |
Definition at line 467 of file log0log.cc.
UNIV_INTERN void log_group_init | ( | ulint | id, |
ulint | n_files, | ||
lsn_t | file_size, | ||
ulint | space_id, | ||
ulint archive_space_id | __attribute__(unused) | ||
) |
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 |
__attribute__ | 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 |
Definition at line 862 of file log0log.cc.
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.
group | in: log group |
field | in: LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2 |
Definition at line 1921 of file log0log.cc.
UNIV_INTERN void log_group_read_log_seg | ( | ulint | type, |
byte * | buf, | ||
log_group_t * | group, | ||
lsn_t | start_lsn, | ||
lsn_t | end_lsn | ||
) |
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 2181 of file log0log.cc.
UNIV_INTERN void log_group_set_fields | ( | log_group_t * | group, |
lsn_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.
group | in/out: group |
lsn | in: lsn for which the values should be set |
Definition at line 609 of file log0log.cc.
UNIV_INTERN void log_group_write_buf | ( | log_group_t * | group, |
byte * | buf, | ||
ulint | len, | ||
lsn_t | start_lsn, | ||
ulint | new_data_offset | ||
) |
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 1190 of file log0log.cc.
UNIV_INTERN void log_groups_write_checkpoint_info | ( | void | ) |
Writes checkpoint info to groups.
Definition at line 1941 of file log0log.cc.
UNIV_INTERN void log_init | ( | void | ) |
Initializes the log.
Definition at line 732 of file log0log.cc.
UNIV_INTERN void log_io_complete | ( | log_group_t * | 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 1054 of file log0log.cc.
UNIV_INTERN void log_make_checkpoint_at | ( | lsn_t | lsn, |
ibool | write_always | ||
) |
Makes a checkpoint at a given lsn or later.
lsn | in: make a checkpoint at this or a later lsn, if LSN_MAX, makes a checkpoint at the latest lsn |
write_always | in: the function normally checks if 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.
UNIV_INTERN void log_mem_free | ( | void | ) |
Free the log system data structures.
Definition at line 3611 of file log0log.cc.
UNIV_INTERN ibool log_peek_lsn | ( | lsn_t * | lsn | ) |
Peeks the current lsn.
lsn | out: if returns TRUE, current lsn is here |
Definition at line 3448 of file log0log.cc.
UNIV_INTERN void log_print | ( | FILE * | file | ) |
Prints info of the log.
file | in: file where to print |
Definition at line 3467 of file log0log.cc.
UNIV_INTERN void log_refresh_stats | ( | void | ) |
Refreshes the statistics used to print per-second averages.
Definition at line 3514 of file log0log.cc.
UNIV_INTERN lsn_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.
len | in: length of data to be catenated |
Definition at line 192 of file log0log.cc.
UNIV_INTERN void log_shutdown | ( | void | ) |
Shutdown the log system but do not release all the memory.
Definition at line 3576 of file log0log.cc.
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.
str | in: string |
str_len | in: string length |
Definition at line 266 of file log0log.cc.
UNIV_INTERN void log_write_up_to | ( | lsn_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.
< We assume here that we have only one log group!
lsn | in: log sequence number up to which the log should be written, LSN_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 1321 of file log0log.cc.
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 3086 of file log0log.cc.