📄 log0log.h
字号:
megabyte; this information is only used by ibbackup to decide if it can truncate unused ends of non-auto-extending data files in space 0 */#define LOG_CHECKPOINT_FSP_MAGIC_N (12 + LOG_CHECKPOINT_ARRAY_END) /* this magic number tells if the checkpoint contains the above field: the field was added to InnoDB-3.23.50 */#define LOG_CHECKPOINT_SIZE (16 + LOG_CHECKPOINT_ARRAY_END)#define LOG_CHECKPOINT_FSP_MAGIC_N_VAL 1441231243/* Offsets of a log file header */#define LOG_GROUP_ID 0 /* log group number */#define LOG_FILE_START_LSN 4 /* lsn of the start of data in this log file */#define LOG_FILE_NO 12 /* 4-byte archived log file number; this field is only defined in an archived log file */#define LOG_FILE_WAS_CREATED_BY_HOT_BACKUP 16 /* a 32-byte field which contains the string 'ibbackup' and the creation time if the log file was created by ibbackup --restore; when mysqld is first time started on the restored database, it can print helpful info for the user */#define LOG_FILE_ARCH_COMPLETED OS_FILE_LOG_BLOCK_SIZE /* this 4-byte field is TRUE when the writing of an archived log file has been completed; this field is only defined in an archived log file */#define LOG_FILE_END_LSN (OS_FILE_LOG_BLOCK_SIZE + 4) /* lsn where the archived log file at least extends: actually the archived log file may extend to a later lsn, as long as it is within the same log block as this lsn; this field is defined only when an archived log file has been completely written */#define LOG_CHECKPOINT_1 OS_FILE_LOG_BLOCK_SIZE /* first checkpoint field in the log header; we write alternately to the checkpoint fields when we make new checkpoints; this field is only defined in the first log file of a log group */#define LOG_CHECKPOINT_2 (3 * OS_FILE_LOG_BLOCK_SIZE) /* second checkpoint field in the log header */#define LOG_FILE_HDR_SIZE (4 * OS_FILE_LOG_BLOCK_SIZE)#define LOG_GROUP_OK 301#define LOG_GROUP_CORRUPTED 302/* Log group consists of a number of log files, each of the same size; a loggroup is implemented as a space in the sense of the module fil0fil. */struct log_group_struct{ /* The following fields are protected by log_sys->mutex */ ulint id; /* log group id */ ulint n_files; /* number of files in the group */ ulint file_size; /* individual log file size in bytes, including the log file header */ ulint space_id; /* file space which implements the log group */ ulint state; /* LOG_GROUP_OK or LOG_GROUP_CORRUPTED */ dulint lsn; /* lsn used to fix coordinates within the log group */ ulint lsn_offset; /* the offset of the above lsn */ ulint n_pending_writes;/* number of currently pending flush writes for this log group */ byte** file_header_bufs;/* buffers for each file header in the group */ /*-----------------------------*/ byte** archive_file_header_bufs;/* buffers for each file header in the group */ ulint archive_space_id;/* file space which implements the log group archive */ ulint archived_file_no;/* file number corresponding to log_sys->archived_lsn */ ulint archived_offset;/* file offset corresponding to log_sys->archived_lsn, 0 if we have not yet written to the archive file number archived_file_no */ ulint next_archived_file_no;/* during an archive write, until the write is completed, we store the next value for archived_file_no here: the write completion function then sets the new value to ..._file_no */ ulint next_archived_offset; /* like the preceding field */ /*-----------------------------*/ dulint scanned_lsn; /* used only in recovery: recovery scan succeeded up to this lsn in this log group */ byte* checkpoint_buf; /* checkpoint header is written from this buffer to the group */ UT_LIST_NODE_T(log_group_t) log_groups; /* list of log groups */}; struct log_struct{ byte pad[64]; /* padding to prevent other memory update hotspots from residing on the same memory cache line */ dulint lsn; /* log sequence number */ ulint buf_free; /* first free offset within the log buffer */ mutex_t mutex; /* mutex protecting the log */ byte* buf; /* log buffer */ ulint buf_size; /* log buffer size in bytes */ ulint max_buf_free; /* recommended maximum value of buf_free, after which the buffer is flushed */ ulint old_buf_free; /* value of buf free when log was last time opened; only in the debug version */ dulint old_lsn; /* value of lsn when log was last time opened; only in the debug version */ ibool check_flush_or_checkpoint; /* this is set to TRUE when there may be need to flush the log buffer, or preflush buffer pool pages, or make a checkpoint; this MUST be TRUE when lsn - last_checkpoint_lsn > max_checkpoint_age; this flag is peeked at by log_free_check(), which does not reserve the log mutex */ UT_LIST_BASE_NODE_T(log_group_t) log_groups; /* log groups */ /* The fields involved in the log buffer flush */ ulint buf_next_to_write;/* first offset in the log buffer where the byte content may not exist written to file, e.g., the start offset of a log record catenated later; this is advanced when a flush operation is completed to all the log groups */ dulint written_to_some_lsn; /* first log sequence number not yet written to any log group; for this to be advanced, it is enough that the write i/o has been completed for any one log group */ dulint written_to_all_lsn; /* first log sequence number not yet written to some log group; for this to be advanced, it is enough that the write i/o has been completed for all log groups */ dulint write_lsn; /* end lsn for the current running write */ ulint write_end_offset;/* the data in buffer has been written up to this offset when the current write ends: this field will then be copied to buf_next_to_write */ dulint current_flush_lsn;/* end lsn for the current running write + flush operation */ dulint flushed_to_disk_lsn; /* how far we have written the log AND flushed to disk */ ulint n_pending_writes;/* number of currently pending flushes or writes */ /* NOTE on the 'flush' in names of the fields below: starting from 4.0.14, we separate the write of the log file and the actual fsync() or other method to flush it to disk. The names below shhould really be 'flush_or_write'! */ os_event_t no_flush_event; /* this event is in the reset state when a flush or a write is running; a thread should wait for this without owning the log mutex, but NOTE that to set or reset this event, the thread MUST own the log mutex! */ ibool one_flushed; /* during a flush, this is first FALSE and becomes TRUE when one log group has been written or flushed */ os_event_t one_flushed_event;/* this event is reset when the flush or write has not yet completed for any log group; e.g., this means that a transaction has been committed when this is set; a thread should wait for this without owning the log mutex, but NOTE that to set or reset this event, the thread MUST own the log mutex! */ ulint n_log_ios; /* number of log i/os initiated thus far */ ulint n_log_ios_old; /* number of log i/o's at the previous printout */ time_t last_printout_time;/* when log_print was last time called */ /* Fields involved in checkpoints */ ulint log_group_capacity; /* capacity of the log group; if the checkpoint age exceeds this, it is a serious error because it is possible we will then overwrite log and spoil crash recovery */ ulint max_modified_age_async; /* when this recommended value for lsn - buf_pool_get_oldest_modification() is exceeded, we start an asynchronous preflush of pool pages */ ulint max_modified_age_sync; /* when this recommended value for lsn - buf_pool_get_oldest_modification() is exceeded, we start a synchronous preflush of pool pages */ ulint adm_checkpoint_interval; /* administrator-specified checkpoint interval in terms of log growth in bytes; the interval actually used by the database can be smaller */ ulint max_checkpoint_age_async; /* when this checkpoint age is exceeded we start an asynchronous writing of a new checkpoint */ ulint max_checkpoint_age; /* this is the maximum allowed value for lsn - last_checkpoint_lsn when a new query step is started */ dulint next_checkpoint_no; /* next checkpoint number */ dulint last_checkpoint_lsn; /* latest checkpoint lsn */ dulint next_checkpoint_lsn; /* next checkpoint lsn */ ulint n_pending_checkpoint_writes; /* number of currently pending checkpoint writes */ rw_lock_t checkpoint_lock;/* this latch is x-locked when a checkpoint write is running; a thread should wait for this without owning the log mutex */ byte* checkpoint_buf; /* checkpoint header is read to this buffer */ /* Fields involved in archiving */ ulint archiving_state;/* LOG_ARCH_ON, LOG_ARCH_STOPPING LOG_ARCH_STOPPED, LOG_ARCH_OFF */ dulint archived_lsn; /* archiving has advanced to this lsn */ ulint max_archived_lsn_age_async; /* recommended maximum age of archived_lsn, before we start asynchronous copying to the archive */ ulint max_archived_lsn_age; /* maximum allowed age for archived_lsn */ dulint next_archived_lsn;/* during an archive write, until the write is completed, we store the next value for archived_lsn here: the write completion function then sets the new value to archived_lsn */ ulint archiving_phase;/* LOG_ARCHIVE_READ or LOG_ARCHIVE_WRITE */ ulint n_pending_archive_ios; /* number of currently pending reads or writes in archiving */ rw_lock_t archive_lock; /* this latch is x-locked when an archive write is running; a thread should wait for this without owning the log mutex */ ulint archive_buf_size;/* size of archive_buf */ byte* archive_buf; /* log segment is written to the archive from this buffer */ os_event_t archiving_on; /* if archiving has been stopped, a thread can wait for this event to become signaled */};#define LOG_ARCH_ON 71#define LOG_ARCH_STOPPING 72#define LOG_ARCH_STOPPING2 73#define LOG_ARCH_STOPPED 74#define LOG_ARCH_OFF 75#ifndef UNIV_NONINL#include "log0log.ic"#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -