MySQL 8.0.31
Source Code Documentation
log0constants.h File Reference

Redo log constant values. More...

#include "log0types.h"
#include "os0file.h"

Go to the source code of this file.

Variables

constexpr size_t LOG_BUFFER_ALIGNMENT = OS_FILE_LOG_BLOCK_SIZE
 Align the log buffer (log_t::buf) to this size. More...
 
constexpr size_t LOG_WRITE_AHEAD_BUFFER_ALIGNMENT
 Align the log write-ahead buffer (log_t::write_ahead_buf) to this size. More...
 
Log constants related to the log file i-nodes.
constexpr const char *const LOG_DIRECTORY_NAME = "#innodb_redo"
 Name of subdirectory which contains redo log files. More...
 
constexpr const char *const LOG_FILE_BASE_NAME = "#ib_redo"
 Prefix of log file name in the current redo format. More...
 
constexpr uint32_t LOG_FILE_NAME_MAX_LENGTH = 8 + 22
 Maximum length of log file name, computed as: base name length(8) More...
 
constexpr size_t LOG_N_FILES = 32
 Targeted number of log files. More...
 
constexpr double LOG_N_FILES_MAX_DOWNSIZE_RATIO = 1.0 / 8
 Determines maximum downsize for maximum redo file size during resize. More...
 
constexpr os_offset_t LOG_FILE_MIN_SIZE = 64 * 1024
 Minimum size of single log file, expressed in bytes. More...
 
constexpr os_offset_t LOG_FILE_MAX_SIZE = 4ULL * 1024 * 1024 * 1024
 Maximum size of single log file, expressed in bytes. More...
 
constexpr os_offset_t LOG_CAPACITY_MIN = 8 * 1024 * 1024
 Minimum allowed value for innodb_redo_log_capacity. More...
 
constexpr os_offset_t LOG_CAPACITY_MAX = LOG_N_FILES * LOG_FILE_MAX_SIZE
 Maximum allowed value for innodb_redo_log_capacity. More...
 
constexpr Log_file_id LOG_FIRST_FILE_ID = 0
 Id of the first redo log file (assigned to the first log file when new data directory is being initialized). More...
 
constexpr size_t LOG_MAX_OPEN_FILES = 2
 Maximum number of handles for opened redo log files (in parallel). More...
 
Log constants related to the log margins.

Ensure, that 64 bits are enough to represent lsn values, when 63 bits are used to represent sn values.

It is enough to ensure that lsn < 2*sn, and that is guaranteed if the overhead enumerated in lsn sequence is not bigger than number of actual data bytes.

constexpr os_offset_t LOG_EXTRA_SAFETY_MARGIN = 2 * UNIV_PAGE_SIZE_MAX
 Extra safety margin in the redo capacity, never ever used ! More...
 
constexpr double LOG_NEXT_FILE_EARLIER_MARGIN = 10
 Margin which is used ahead of log.write_lsn to create unused files earlier than the log.write_lsn reaches the m_end_lsn of the log.m_current_file. More...
 
constexpr double LOG_EXTRA_WRITER_MARGIN_PCT = 5
 Extra margin, reserved in the redo capacity for the log writer thread. More...
 
constexpr double LOG_EXTRA_CONC_MARGIN_PCT = 5
 Extra margin, reserved in the redo capacity for the concurrency margin. More...
 
constexpr double LOG_CONCCURENCY_MARGIN_MAX_PCT = 50
 The maximum limit for concurrency_margin expressed as percentage of the redo capacity available for user threads (soft capacity). More...
 
constexpr size_t LOG_BACKGROUND_THREADS_USING_RW_MTRS = 10
 Maximum number of concurrent background threads, that could be using mini transactions which are not read-only (producing redo log records). More...
 
constexpr uint32_t LOG_CHECKPOINT_FREE_PER_THREAD = 4
 Per thread margin for the free space in the log, before a new query step which modifies the database, is started. More...
 
constexpr uint32_t LOG_FILES_DUMMY_INTAKE_SIZE = 4 * 1024
 Number of bytes that might be generated by log_files_governor thread to fill up the current log file faster. More...
 
constexpr uint32_t LOG_AGGRESSIVE_CHECKPOINT_RATIO_MIN = 32
 Controls when the aggressive checkpointing should be started, with regards to the free space in the redo log. More...
 
constexpr uint32_t LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MAX = 16
 Controls when the maximum speed of adaptive flushing of modified pages is reached (with regards to free space in the redo log). More...
 
constexpr uint32_t LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MIN = 8
 Controls when the speed of adaptive flushing of modified pages starts to increase. More...
 
Log constants related to the system variables.
constexpr ulint INNODB_LOG_WRITE_MAX_SIZE_DEFAULT = 4096
 Default value of innodb_log_write_max_size (in bytes). More...
 
constexpr ulong INNODB_LOG_CHECKPOINT_EVERY_DEFAULT = 1000
 Default value of innodb_log_checkpointer_every (in milliseconds). More...
 
constexpr ulong INNODB_LOG_WRITER_SPIN_DELAY_DEFAULT = 250000
 Default value of innodb_log_writer_spin_delay (in spin rounds). More...
 
constexpr ulong INNODB_LOG_WRITER_TIMEOUT_DEFAULT = 10
 Default value of innodb_log_writer_timeout (in microseconds). More...
 
constexpr ulong INNODB_LOG_SPIN_CPU_ABS_LWM_DEFAULT = 80
 Default value of innodb_log_spin_cpu_abs_lwm. More...
 
constexpr uint INNODB_LOG_SPIN_CPU_PCT_HWM_DEFAULT = 50
 Default value of innodb_log_spin_cpu_pct_hwm. More...
 
constexpr ulong INNODB_LOG_WAIT_FOR_WRITE_SPIN_DELAY_DEFAULT = 25000
 Default value of innodb_log_wait_for_write_spin_delay (in spin rounds). More...
 
constexpr ulong INNODB_LOG_WAIT_FOR_WRITE_TIMEOUT_DEFAULT = 1000
 Default value of innodb_log_wait_for_write_timeout (in microseconds). More...
 
constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_SPIN_DELAY_DEFAULT = 25000
 Default value of innodb_log_wait_for_flush_spin_delay (in spin rounds). More...
 
constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_SPIN_HWM_DEFAULT = 400
 Default value of innodb_log_wait_for_flush_spin_hwm (in microseconds). More...
 
constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_TIMEOUT_DEFAULT = 1000
 Default value of innodb_log_wait_for_flush_timeout (in microseconds). More...
 
constexpr ulong INNODB_LOG_FLUSHER_SPIN_DELAY_DEFAULT = 250000
 Default value of innodb_log_flusher_spin_delay (in spin rounds). More...
 
constexpr ulong INNODB_LOG_FLUSHER_TIMEOUT_DEFAULT = 10
 Default value of innodb_log_flusher_timeout (in microseconds). More...
 
constexpr ulong INNODB_LOG_WRITE_NOTIFIER_SPIN_DELAY_DEFAULT = 0
 Default value of innodb_log_write_notifier_spin_delay (in spin rounds). More...
 
constexpr ulong INNODB_LOG_WRITE_NOTIFIER_TIMEOUT_DEFAULT = 10
 Default value of innodb_log_write_notifier_timeout (in microseconds). More...
 
constexpr ulong INNODB_LOG_FLUSH_NOTIFIER_SPIN_DELAY_DEFAULT = 0
 Default value of innodb_log_flush_notifier_spin_delay (in spin rounds). More...
 
constexpr ulong INNODB_LOG_FLUSH_NOTIFIER_TIMEOUT_DEFAULT = 10
 Default value of innodb_log_flush_notifier_timeout (in microseconds). More...
 
constexpr ulong INNODB_LOG_BUFFER_SIZE_DEFAULT = 16 * 1024 * 1024UL
 Default value of innodb_log_buffer_size (in bytes). More...
 
constexpr ulong INNODB_LOG_BUFFER_SIZE_MIN = 256 * 1024UL
 Minimum allowed value of innodb_log_buffer_size. More...
 
constexpr ulong INNODB_LOG_BUFFER_SIZE_MAX = ULONG_MAX
 Maximum allowed value of innodb_log_buffer_size. More...
 
constexpr ulong INNODB_LOG_RECENT_WRITTEN_SIZE_DEFAULT = 1024 * 1024
 Default value of innodb_log_recent_written_size (in bytes). More...
 
constexpr ulong INNODB_LOG_RECENT_WRITTEN_SIZE_MIN = OS_FILE_LOG_BLOCK_SIZE
 Minimum allowed value of innodb_log_recent_written_size. More...
 
constexpr ulong INNODB_LOG_RECENT_WRITTEN_SIZE_MAX = 1024 * 1024 * 1024UL
 Maximum allowed value of innodb_log_recent_written_size. More...
 
constexpr ulong INNODB_LOG_RECENT_CLOSED_SIZE_DEFAULT = 2 * 1024 * 1024
 Default value of innodb_log_recent_closed_size (in bytes). More...
 
constexpr ulong INNODB_LOG_RECENT_CLOSED_SIZE_MIN = OS_FILE_LOG_BLOCK_SIZE
 Minimum allowed value of innodb_log_recent_closed_size. More...
 
constexpr ulong INNODB_LOG_RECENT_CLOSED_SIZE_MAX = 1024 * 1024 * 1024UL
 Maximum allowed value of innodb_log_recent_closed_size. More...
 
constexpr ulong INNODB_LOG_EVENTS_DEFAULT = 2048
 Default value of innodb_log_events (number of events). More...
 
constexpr ulong INNODB_LOG_EVENTS_MIN = 1
 Minimum allowed value of innodb_log_events. More...
 
constexpr ulong INNODB_LOG_EVENTS_MAX = 1024 * 1024 * 1024UL
 Maximum allowed value of innodb_log_events. More...
 
constexpr ulong INNODB_LOG_WRITE_AHEAD_SIZE_DEFAULT = 8192
 Default value of innodb_log_write_ahead_size (in bytes). More...
 
constexpr ulong INNODB_LOG_WRITE_AHEAD_SIZE_MIN = OS_FILE_LOG_BLOCK_SIZE
 Minimum allowed value of innodb_log_write_ahead_size. More...
 
constexpr ulint INNODB_LOG_WRITE_AHEAD_SIZE_MAX
 Maximum allowed value of innodb_log_write_ahead_size. More...
 
Log constants used in the tests of the redo log.
constexpr int64_t MLOG_TEST_VALUE = 10000
 Value to which MLOG_TEST records should sum up within a group. More...
 
constexpr uint32_t MLOG_TEST_MAX_REC_LEN = 100
 Maximum size of single MLOG_TEST record (in bytes). More...
 
constexpr uint32_t MLOG_TEST_GROUP_MAX_REC_N = 100
 Maximum number of MLOG_TEST records in single group of log records. More...
 
constexpr uint32_t MLOG_TEST_REC_OVERHEAD = 37
 Bytes occupied by MLOG_TEST record with an empty payload. More...
 

Log constants related to the log file format.

#define LOG_HEADER_CREATOR_CURRENT   "MySQL " INNODB_VERSION_STR
 Contents of the LOG_HEADER_CREATOR field. More...
 
#define LOG_HEADER_CREATOR_CLONE   "MySQL Clone"
 Header is created during DB clone. More...
 
constexpr uint32_t LOG_NO_CHECKSUM_MAGIC = 0xDEADBEEFUL
 Magic value to use instead of log checksums when they are disabled. More...
 
constexpr lsn_t LOG_START_LSN = 16 * OS_FILE_LOG_BLOCK_SIZE
 The counting of lsn's starts from this value: this must be non-zero. More...
 
constexpr lsn_t LSN_MAX = (1ULL << 63) - 1
 Maximum possible lsn value is slightly higher than the maximum sn value, because lsn sequence enumerates also bytes used for headers and footers of all log blocks. More...
 
constexpr sn_t SN_LOCKED = 1ULL << 63
 The sn bit to express locked state. More...
 
constexpr os_offset_t LOG_CHECKPOINT_1 = OS_FILE_LOG_BLOCK_SIZE
 First checkpoint field in the log header. More...
 
constexpr os_offset_t LOG_ENCRYPTION = 2 * OS_FILE_LOG_BLOCK_SIZE
 Log Encryption information in redo log header. More...
 
constexpr os_offset_t LOG_CHECKPOINT_2 = 3 * OS_FILE_LOG_BLOCK_SIZE
 Second checkpoint field in the header of the first log file. More...
 
constexpr os_offset_t LOG_FILE_HDR_SIZE = 4 * OS_FILE_LOG_BLOCK_SIZE
 Size of log file's header. More...
 
constexpr os_offset_t LOG_HEADER_FORMAT = 0
 Log file header format identifier (32-bit unsigned big-endian integer). More...
 
constexpr uint32_t LOG_HEADER_LOG_UUID = 4
 Offset within the log file header, to the field which stores the log_uuid. More...
 
constexpr os_offset_t LOG_HEADER_START_LSN = 8
 LSN of the start of data in this log file (with format version 1 and 2). More...
 
constexpr os_offset_t LOG_HEADER_CREATOR = 16
 A null-terminated string which will contain either the string 'MEB' and the MySQL version if the log file was created by mysqlbackup, or 'MySQL' and the MySQL version that created the redo log file. More...
 
constexpr size_t LOG_HEADER_CREATOR_MAX_LENGTH = 31
 Maximum length of string with creator name (excludes \0). More...
 
constexpr os_offset_t LOG_HEADER_CREATOR_END
 End of the log file creator field (we add 1 for \0). More...
 
constexpr os_offset_t LOG_HEADER_ENCRYPTION_INFO_OFFSET
 Offset to encryption information in the log encryption header. More...
 
constexpr os_offset_t LOG_HEADER_FLAGS = LOG_HEADER_CREATOR_END
 32 BITs flag More...
 
constexpr uint32_t LOG_HEADER_FLAG_NO_LOGGING = 1
 Flag at BIT-1 to indicate if redo logging is disabled or not. More...
 
constexpr uint32_t LOG_HEADER_FLAG_CRASH_UNSAFE = 2
 Flag at BIT-2 to indicate if server is not recoverable on crash. More...
 
constexpr uint32_t LOG_HEADER_FLAG_NOT_INITIALIZED = 3
 Flag at BIT-3 to indicate if server is not recoverable on crash because data directory still has not been fully initialized. More...
 
constexpr uint32_t LOG_HEADER_FLAG_FILE_FULL = 4
 Flag at BIT-4 to mark the redo log file as completely full and closed for any future writes. More...
 
constexpr uint32_t LOG_HEADER_FLAG_MAX = LOG_HEADER_FLAG_FILE_FULL
 Maximum BIT position number. More...
 
constexpr os_offset_t LOG_HEADER_SIZE = LOG_HEADER_FLAGS + 4
 Current total size of LOG header. More...
 
constexpr os_offset_t LOG_CHECKPOINT_LSN = 8
 Checkpoint lsn. More...
 
constexpr uint32_t LOG_BLOCK_HDR_NO = 0
 Offset to hdr_no, which is a log block number and must be > 0. More...
 
constexpr uint32_t LOG_BLOCK_FLUSH_BIT_MASK = 0x80000000UL
 Mask used to get the highest bit in the hdr_no field. More...
 
constexpr uint32_t LOG_BLOCK_MAX_NO = 0x3FFFFFFFUL + 1
 Maximum allowed block's number (stored in hdr_no) increased by 1. More...
 
constexpr uint32_t LOG_BLOCK_HDR_DATA_LEN = 4
 Offset to number of bytes written to this block (also header bytes). More...
 
constexpr uint32_t LOG_BLOCK_ENCRYPT_BIT_MASK = 0x8000UL
 Mask used to get the highest bit in the data len field, this bit is to indicate if this block is encrypted or not. More...
 
constexpr uint32_t LOG_BLOCK_FIRST_REC_GROUP = 6
 Offset to "first_rec_group offset" stored in the log block header. More...
 
constexpr uint32_t LOG_BLOCK_EPOCH_NO = 8
 Offset to epoch_no stored in this log block. More...
 
constexpr uint32_t LOG_BLOCK_HDR_SIZE = 12
 Size of the log block's header in bytes. More...
 
constexpr uint32_t LOG_BLOCK_CHECKSUM = 4
 4 byte checksum of the log block contents. More...
 
constexpr uint32_t LOG_BLOCK_TRL_SIZE = 4
 Size of the log block footer (trailer) in bytes. More...
 
constexpr uint32_t LOG_BLOCK_DATA_SIZE
 Size of log block's data fragment (where actual data is stored). More...
 

Detailed Description

Redo log constant values.

This file should not be included except the include in log0types.h.

Include log0types.h if you needed to use constants.

Macro Definition Documentation

◆ LOG_HEADER_CREATOR_CLONE

#define LOG_HEADER_CREATOR_CLONE   "MySQL Clone"

Header is created during DB clone.

◆ LOG_HEADER_CREATOR_CURRENT

#define LOG_HEADER_CREATOR_CURRENT   "MySQL " INNODB_VERSION_STR

Contents of the LOG_HEADER_CREATOR field.

Variable Documentation

◆ INNODB_LOG_BUFFER_SIZE_DEFAULT

constexpr ulong INNODB_LOG_BUFFER_SIZE_DEFAULT = 16 * 1024 * 1024UL
constexpr

Default value of innodb_log_buffer_size (in bytes).

◆ INNODB_LOG_BUFFER_SIZE_MAX

constexpr ulong INNODB_LOG_BUFFER_SIZE_MAX = ULONG_MAX
constexpr

Maximum allowed value of innodb_log_buffer_size.

◆ INNODB_LOG_BUFFER_SIZE_MIN

constexpr ulong INNODB_LOG_BUFFER_SIZE_MIN = 256 * 1024UL
constexpr

Minimum allowed value of innodb_log_buffer_size.

◆ INNODB_LOG_CHECKPOINT_EVERY_DEFAULT

constexpr ulong INNODB_LOG_CHECKPOINT_EVERY_DEFAULT = 1000
constexpr

Default value of innodb_log_checkpointer_every (in milliseconds).

◆ INNODB_LOG_EVENTS_DEFAULT

constexpr ulong INNODB_LOG_EVENTS_DEFAULT = 2048
constexpr

Default value of innodb_log_events (number of events).

◆ INNODB_LOG_EVENTS_MAX

constexpr ulong INNODB_LOG_EVENTS_MAX = 1024 * 1024 * 1024UL
constexpr

Maximum allowed value of innodb_log_events.

◆ INNODB_LOG_EVENTS_MIN

constexpr ulong INNODB_LOG_EVENTS_MIN = 1
constexpr

Minimum allowed value of innodb_log_events.

◆ INNODB_LOG_FLUSH_NOTIFIER_SPIN_DELAY_DEFAULT

constexpr ulong INNODB_LOG_FLUSH_NOTIFIER_SPIN_DELAY_DEFAULT = 0
constexpr

Default value of innodb_log_flush_notifier_spin_delay (in spin rounds).

◆ INNODB_LOG_FLUSH_NOTIFIER_TIMEOUT_DEFAULT

constexpr ulong INNODB_LOG_FLUSH_NOTIFIER_TIMEOUT_DEFAULT = 10
constexpr

Default value of innodb_log_flush_notifier_timeout (in microseconds).

◆ INNODB_LOG_FLUSHER_SPIN_DELAY_DEFAULT

constexpr ulong INNODB_LOG_FLUSHER_SPIN_DELAY_DEFAULT = 250000
constexpr

Default value of innodb_log_flusher_spin_delay (in spin rounds).

Read about INNODB_LOG_WRITER_SPIN_DELAY_DEFAULT.

◆ INNODB_LOG_FLUSHER_TIMEOUT_DEFAULT

constexpr ulong INNODB_LOG_FLUSHER_TIMEOUT_DEFAULT = 10
constexpr

Default value of innodb_log_flusher_timeout (in microseconds).

Note that it will anyway take at least 50us.

◆ INNODB_LOG_RECENT_CLOSED_SIZE_DEFAULT

constexpr ulong INNODB_LOG_RECENT_CLOSED_SIZE_DEFAULT = 2 * 1024 * 1024
constexpr

Default value of innodb_log_recent_closed_size (in bytes).

◆ INNODB_LOG_RECENT_CLOSED_SIZE_MAX

constexpr ulong INNODB_LOG_RECENT_CLOSED_SIZE_MAX = 1024 * 1024 * 1024UL
constexpr

Maximum allowed value of innodb_log_recent_closed_size.

◆ INNODB_LOG_RECENT_CLOSED_SIZE_MIN

constexpr ulong INNODB_LOG_RECENT_CLOSED_SIZE_MIN = OS_FILE_LOG_BLOCK_SIZE
constexpr

Minimum allowed value of innodb_log_recent_closed_size.

◆ INNODB_LOG_RECENT_WRITTEN_SIZE_DEFAULT

constexpr ulong INNODB_LOG_RECENT_WRITTEN_SIZE_DEFAULT = 1024 * 1024
constexpr

Default value of innodb_log_recent_written_size (in bytes).

◆ INNODB_LOG_RECENT_WRITTEN_SIZE_MAX

constexpr ulong INNODB_LOG_RECENT_WRITTEN_SIZE_MAX = 1024 * 1024 * 1024UL
constexpr

Maximum allowed value of innodb_log_recent_written_size.

◆ INNODB_LOG_RECENT_WRITTEN_SIZE_MIN

constexpr ulong INNODB_LOG_RECENT_WRITTEN_SIZE_MIN = OS_FILE_LOG_BLOCK_SIZE
constexpr

Minimum allowed value of innodb_log_recent_written_size.

◆ INNODB_LOG_SPIN_CPU_ABS_LWM_DEFAULT

constexpr ulong INNODB_LOG_SPIN_CPU_ABS_LWM_DEFAULT = 80
constexpr

Default value of innodb_log_spin_cpu_abs_lwm.

Expressed in percent (80 stands for 80%) of a single CPU core.

◆ INNODB_LOG_SPIN_CPU_PCT_HWM_DEFAULT

constexpr uint INNODB_LOG_SPIN_CPU_PCT_HWM_DEFAULT = 50
constexpr

Default value of innodb_log_spin_cpu_pct_hwm.

Expressed in percent (50 stands for 50%) of all CPU cores.

◆ INNODB_LOG_WAIT_FOR_FLUSH_SPIN_DELAY_DEFAULT

constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_SPIN_DELAY_DEFAULT = 25000
constexpr

Default value of innodb_log_wait_for_flush_spin_delay (in spin rounds).

Read about INNODB_LOG_WAIT_FOR_WRITE_SPIN_DELAY_DEFAULT. The same mechanism applies here (to compute max rounds).

◆ INNODB_LOG_WAIT_FOR_FLUSH_SPIN_HWM_DEFAULT

constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_SPIN_HWM_DEFAULT = 400
constexpr

Default value of innodb_log_wait_for_flush_spin_hwm (in microseconds).

◆ INNODB_LOG_WAIT_FOR_FLUSH_TIMEOUT_DEFAULT

constexpr ulong INNODB_LOG_WAIT_FOR_FLUSH_TIMEOUT_DEFAULT = 1000
constexpr

Default value of innodb_log_wait_for_flush_timeout (in microseconds).

◆ INNODB_LOG_WAIT_FOR_WRITE_SPIN_DELAY_DEFAULT

constexpr ulong INNODB_LOG_WAIT_FOR_WRITE_SPIN_DELAY_DEFAULT = 25000
constexpr

Default value of innodb_log_wait_for_write_spin_delay (in spin rounds).

Read about INNODB_LOG_WRITER_SPIN_DELAY_DEFAULT. Number of spin rounds is calculated according to current usage of CPU cores. If the usage is smaller than lwm percents of single core, then max rounds = 0. If the usage is smaller than 50% of hwm percents of all cores, then max rounds is decreasing linearly from 10x innodb_log_writer_spin_delay to 1x (for 50%). Then in range from 50% of hwm to 100% of hwm, the max rounds stays equal to the innodb_log_writer_spin_delay, because it doesn't make sense to use too short waits. Hence this is minimum value for the max rounds when non-zero value is being used.

◆ INNODB_LOG_WAIT_FOR_WRITE_TIMEOUT_DEFAULT

constexpr ulong INNODB_LOG_WAIT_FOR_WRITE_TIMEOUT_DEFAULT = 1000
constexpr

Default value of innodb_log_wait_for_write_timeout (in microseconds).

◆ INNODB_LOG_WRITE_AHEAD_SIZE_DEFAULT

constexpr ulong INNODB_LOG_WRITE_AHEAD_SIZE_DEFAULT = 8192
constexpr

Default value of innodb_log_write_ahead_size (in bytes).

◆ INNODB_LOG_WRITE_AHEAD_SIZE_MAX

constexpr ulint INNODB_LOG_WRITE_AHEAD_SIZE_MAX
constexpr
Initial value:
=
constexpr uint32_t UNIV_PAGE_SIZE_DEF
Default page size for InnoDB tablespaces.
Definition: univ.i:326

Maximum allowed value of innodb_log_write_ahead_size.

◆ INNODB_LOG_WRITE_AHEAD_SIZE_MIN

constexpr ulong INNODB_LOG_WRITE_AHEAD_SIZE_MIN = OS_FILE_LOG_BLOCK_SIZE
constexpr

Minimum allowed value of innodb_log_write_ahead_size.

◆ INNODB_LOG_WRITE_MAX_SIZE_DEFAULT

constexpr ulint INNODB_LOG_WRITE_MAX_SIZE_DEFAULT = 4096
constexpr

Default value of innodb_log_write_max_size (in bytes).

◆ INNODB_LOG_WRITE_NOTIFIER_SPIN_DELAY_DEFAULT

constexpr ulong INNODB_LOG_WRITE_NOTIFIER_SPIN_DELAY_DEFAULT = 0
constexpr

Default value of innodb_log_write_notifier_spin_delay (in spin rounds).

◆ INNODB_LOG_WRITE_NOTIFIER_TIMEOUT_DEFAULT

constexpr ulong INNODB_LOG_WRITE_NOTIFIER_TIMEOUT_DEFAULT = 10
constexpr

Default value of innodb_log_write_notifier_timeout (in microseconds).

◆ INNODB_LOG_WRITER_SPIN_DELAY_DEFAULT

constexpr ulong INNODB_LOG_WRITER_SPIN_DELAY_DEFAULT = 250000
constexpr

Default value of innodb_log_writer_spin_delay (in spin rounds).

We measured that 1000 spin round takes 4us. We decided to select 1ms as the maximum time for busy waiting. Therefore it corresponds to 250k spin rounds. Note that first wait on event takes 50us-100us (even if 10us is passed), so it is 5%-10% of the total time that we have already spent on busy waiting, when we fall back to wait on event.

◆ INNODB_LOG_WRITER_TIMEOUT_DEFAULT

constexpr ulong INNODB_LOG_WRITER_TIMEOUT_DEFAULT = 10
constexpr

Default value of innodb_log_writer_timeout (in microseconds).

Note that it will anyway take at least 50us.

◆ LOG_AGGRESSIVE_CHECKPOINT_RATIO_MIN

constexpr uint32_t LOG_AGGRESSIVE_CHECKPOINT_RATIO_MIN = 32
constexpr

Controls when the aggressive checkpointing should be started, with regards to the free space in the redo log.

Should be bigger than LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MAX.

◆ LOG_BACKGROUND_THREADS_USING_RW_MTRS

constexpr size_t LOG_BACKGROUND_THREADS_USING_RW_MTRS = 10
constexpr

Maximum number of concurrent background threads, that could be using mini transactions which are not read-only (producing redo log records).

These are threads, which also call log_free_check() to reserve space in the redo log, but which are not included in the innodb_thread_concurrency limitation. That's why this number is added to the innodb_thread_concurrency when computing the concurrency_margin, which is used in log_free_check() calls.

◆ LOG_BLOCK_CHECKSUM

constexpr uint32_t LOG_BLOCK_CHECKSUM = 4
constexpr

4 byte checksum of the log block contents.

In InnoDB versions < 3.23.52 this did not contain the checksum, but the same value as .._HDR_NO.

◆ LOG_BLOCK_DATA_SIZE

constexpr uint32_t LOG_BLOCK_DATA_SIZE
constexpr
Initial value:
=
constexpr uint32_t LOG_BLOCK_HDR_SIZE
Size of the log block's header in bytes.
Definition: log0constants.h:290
constexpr uint32_t LOG_BLOCK_TRL_SIZE
Size of the log block footer (trailer) in bytes.
Definition: log0constants.h:299
constexpr uint32_t OS_FILE_LOG_BLOCK_SIZE
The next value should be smaller or equal to the smallest sector size used on any disk.
Definition: os0file.h:192

Size of log block's data fragment (where actual data is stored).

◆ LOG_BLOCK_ENCRYPT_BIT_MASK

constexpr uint32_t LOG_BLOCK_ENCRYPT_BIT_MASK = 0x8000UL
constexpr

Mask used to get the highest bit in the data len field, this bit is to indicate if this block is encrypted or not.

◆ LOG_BLOCK_EPOCH_NO

constexpr uint32_t LOG_BLOCK_EPOCH_NO = 8
constexpr

Offset to epoch_no stored in this log block.

The epoch_no is computed as the number of epochs passed by the value of start_lsn of the log block. Single epoch is defined as range of lsn values containing LOG_BLOCK_MAX_NO log blocks, each of OS_FILE_LOG_BLOCK_SIZE bytes. Note, that hdr_no stored in header of log block at offset=LOG_BLOCK_HDR_NO, can address the block within a given epoch, whereas epoch_no stored at offset=LOG_BLOCK_EPOCH_NO is the number of full epochs that were before. The pair <epoch_no, hdr_no> would be the absolute block number, so the epoch_no helps in discovery of unexpected end of the log during recovery in similar way as hdr_no does.

Remarks
The epoch_no for block that starts at start_lsn is computed as the start_lsn divided by OS_FILE_LOG_BLOCK_SIZE, and then divided by the LOG_BLOCK_MAX_NO.

◆ LOG_BLOCK_FIRST_REC_GROUP

constexpr uint32_t LOG_BLOCK_FIRST_REC_GROUP = 6
constexpr

Offset to "first_rec_group offset" stored in the log block header.

The first_rec_group offset is an offset of the first start of mtr log record group in this log block (0 if no mtr starts in that log block).

If the value is the same as LOG_BLOCK_HDR_DATA_LEN, it means that the first rec group has not yet been concatenated to this log block, but if it was supposed to be appended, it would start at this offset.

An archive recovery can start parsing the log records starting from this offset in this log block, if value is not 0.

◆ LOG_BLOCK_FLUSH_BIT_MASK

constexpr uint32_t LOG_BLOCK_FLUSH_BIT_MASK = 0x80000000UL
constexpr

Mask used to get the highest bit in the hdr_no field.

In the older MySQL versions this bit was used to mark first block in a write.

◆ LOG_BLOCK_HDR_DATA_LEN

constexpr uint32_t LOG_BLOCK_HDR_DATA_LEN = 4
constexpr

Offset to number of bytes written to this block (also header bytes).

◆ LOG_BLOCK_HDR_NO

constexpr uint32_t LOG_BLOCK_HDR_NO = 0
constexpr

Offset to hdr_no, which is a log block number and must be > 0.

It is allowed to wrap around at LOG_BLOCK_MAX_NO. In older versions of MySQL the highest bit (LOG_BLOCK_FLUSH_BIT_MASK) of hdr_no is set to 1, if this is the first block in a call to write.

◆ LOG_BLOCK_HDR_SIZE

constexpr uint32_t LOG_BLOCK_HDR_SIZE = 12
constexpr

Size of the log block's header in bytes.

◆ LOG_BLOCK_MAX_NO

constexpr uint32_t LOG_BLOCK_MAX_NO = 0x3FFFFFFFUL + 1
constexpr

Maximum allowed block's number (stored in hdr_no) increased by 1.

◆ LOG_BLOCK_TRL_SIZE

constexpr uint32_t LOG_BLOCK_TRL_SIZE = 4
constexpr

Size of the log block footer (trailer) in bytes.

◆ LOG_BUFFER_ALIGNMENT

constexpr size_t LOG_BUFFER_ALIGNMENT = OS_FILE_LOG_BLOCK_SIZE
constexpr

Align the log buffer (log_t::buf) to this size.

This is to preserve the compatibility with older MySQL versions which also aligned the log buffer to OS_FILE_LOG_BLOCK_SIZE. Note, that each write from the log buffer starts at the beginning of one of the blocks in this buffer i.e. from address being a multiple of OS_FILE_LOG_BLOCK_SIZE. Therefore any bigger value for alignment here does not make sense. Please do not use this constant for other buffers.

◆ LOG_CAPACITY_MAX

constexpr os_offset_t LOG_CAPACITY_MAX = LOG_N_FILES * LOG_FILE_MAX_SIZE
constexpr

Maximum allowed value for innodb_redo_log_capacity.

◆ LOG_CAPACITY_MIN

constexpr os_offset_t LOG_CAPACITY_MIN = 8 * 1024 * 1024
constexpr

Minimum allowed value for innodb_redo_log_capacity.

◆ LOG_CHECKPOINT_1

constexpr os_offset_t LOG_CHECKPOINT_1 = OS_FILE_LOG_BLOCK_SIZE
constexpr

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.

◆ LOG_CHECKPOINT_2

constexpr os_offset_t LOG_CHECKPOINT_2 = 3 * OS_FILE_LOG_BLOCK_SIZE
constexpr

Second checkpoint field in the header of the first log file.

◆ LOG_CHECKPOINT_FREE_PER_THREAD

constexpr uint32_t LOG_CHECKPOINT_FREE_PER_THREAD = 4
constexpr

Per thread margin for the free space in the log, before a new query step which modifies the database, is started.

It's multiplied by maximum number of threads, that can concurrently enter mini-transactions. Expressed in number of pages.

◆ LOG_CHECKPOINT_LSN

constexpr os_offset_t LOG_CHECKPOINT_LSN = 8
constexpr

Checkpoint lsn.

Recovery starts from this lsn and searches for the first log record group that starts since then.

◆ LOG_CONCCURENCY_MARGIN_MAX_PCT

constexpr double LOG_CONCCURENCY_MARGIN_MAX_PCT = 50
constexpr

The maximum limit for concurrency_margin expressed as percentage of the redo capacity available for user threads (soft capacity).

Remarks
The concurrency margin is computed as the maximum number of concurrent threads multiplied by some fixed size. Therefore it could happen that it would be even bigger than the redo capacity. To avoid such problem, we need to limit the concurrency margin and warn if the limitation is hit.

◆ LOG_DIRECTORY_NAME

constexpr const char* const LOG_DIRECTORY_NAME = "#innodb_redo"
constexpr

Name of subdirectory which contains redo log files.

◆ LOG_ENCRYPTION

constexpr os_offset_t LOG_ENCRYPTION = 2 * OS_FILE_LOG_BLOCK_SIZE
constexpr

Log Encryption information in redo log header.

◆ LOG_EXTRA_CONC_MARGIN_PCT

constexpr double LOG_EXTRA_CONC_MARGIN_PCT = 5
constexpr

Extra margin, reserved in the redo capacity for the concurrency margin.

Expressed in percentage of the total redo capacity available for user threads (soft capacity). Excluded from LOG_CONCCURENCY_MARGIN_MAX_PCT.

◆ LOG_EXTRA_SAFETY_MARGIN

constexpr os_offset_t LOG_EXTRA_SAFETY_MARGIN = 2 * UNIV_PAGE_SIZE_MAX
constexpr

Extra safety margin in the redo capacity, never ever used !

◆ LOG_EXTRA_WRITER_MARGIN_PCT

constexpr double LOG_EXTRA_WRITER_MARGIN_PCT = 5
constexpr

Extra margin, reserved in the redo capacity for the log writer thread.

When checkpoint age exceeds its maximum limits and user threads are waiting in log_free_check() calls, the log writer thread still has "extra margin" space reserved in the log files (it is his private fragment of the redo log, not announced to users of the redo log). When that happens, all user threads are paused at log_free_check. This mechanism is supposed to help with getting out of possible deadlocks between mini-transactions holding latched pages and page cleaners trying to reclaim space in the redo log by flushing the oldest modified pages. It is supposed to help if the innodb_thread_concurrency is unlimited or we missed to do some log_free_check() calls. This margin is expressed in percentage of the total redo capacity available for the log writer thread (hard capacity).

◆ LOG_FILE_BASE_NAME

constexpr const char* const LOG_FILE_BASE_NAME = "#ib_redo"
constexpr

Prefix of log file name in the current redo format.

◆ LOG_FILE_HDR_SIZE

constexpr os_offset_t LOG_FILE_HDR_SIZE = 4 * OS_FILE_LOG_BLOCK_SIZE
constexpr

Size of log file's header.

◆ LOG_FILE_MAX_SIZE

constexpr os_offset_t LOG_FILE_MAX_SIZE = 4ULL * 1024 * 1024 * 1024
constexpr

Maximum size of single log file, expressed in bytes.

◆ LOG_FILE_MIN_SIZE

constexpr os_offset_t LOG_FILE_MIN_SIZE = 64 * 1024
constexpr

Minimum size of single log file, expressed in bytes.

◆ LOG_FILE_NAME_MAX_LENGTH

constexpr uint32_t LOG_FILE_NAME_MAX_LENGTH = 8 + 22
constexpr

Maximum length of log file name, computed as: base name length(8)

  • length for decimal digits(22).

◆ LOG_FILES_DUMMY_INTAKE_SIZE

constexpr uint32_t LOG_FILES_DUMMY_INTAKE_SIZE = 4 * 1024
constexpr

Number of bytes that might be generated by log_files_governor thread to fill up the current log file faster.

Note that before generating those bytes, the log_files_governor checks if log_free_check is required:

  • no: acts as automatic reservation of space for the records to generate,
  • yes: it skips the redo records generation in this round

◆ LOG_FIRST_FILE_ID

constexpr Log_file_id LOG_FIRST_FILE_ID = 0
constexpr

Id of the first redo log file (assigned to the first log file when new data directory is being initialized).

◆ LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MAX

constexpr uint32_t LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MAX = 16
constexpr

Controls when the maximum speed of adaptive flushing of modified pages is reached (with regards to free space in the redo log).

◆ LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MIN

constexpr uint32_t LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MIN = 8
constexpr

Controls when the speed of adaptive flushing of modified pages starts to increase.

Should be less than the LOG_FORCING_ADAPTIVE_FLUSH_RATIO_MAX.

◆ LOG_HEADER_CREATOR

constexpr os_offset_t LOG_HEADER_CREATOR = 16
constexpr

A null-terminated string which will contain either the string 'MEB' and the MySQL version if the log file was created by mysqlbackup, or 'MySQL' and the MySQL version that created the redo log file.

◆ LOG_HEADER_CREATOR_END

constexpr os_offset_t LOG_HEADER_CREATOR_END
constexpr
Initial value:
=
constexpr os_offset_t LOG_HEADER_CREATOR
A null-terminated string which will contain either the string 'MEB' and the MySQL version if the log ...
Definition: log0constants.h:190
constexpr size_t LOG_HEADER_CREATOR_MAX_LENGTH
Maximum length of string with creator name (excludes \0).
Definition: log0constants.h:193

End of the log file creator field (we add 1 for \0).

◆ LOG_HEADER_CREATOR_MAX_LENGTH

constexpr size_t LOG_HEADER_CREATOR_MAX_LENGTH = 31
constexpr

Maximum length of string with creator name (excludes \0).

◆ LOG_HEADER_ENCRYPTION_INFO_OFFSET

constexpr os_offset_t LOG_HEADER_ENCRYPTION_INFO_OFFSET
constexpr
Initial value:
=
constexpr os_offset_t LOG_HEADER_CREATOR_END
End of the log file creator field (we add 1 for \0).
Definition: log0constants.h:196

Offset to encryption information in the log encryption header.

◆ LOG_HEADER_FLAG_CRASH_UNSAFE

constexpr uint32_t LOG_HEADER_FLAG_CRASH_UNSAFE = 2
constexpr

Flag at BIT-2 to indicate if server is not recoverable on crash.

This is set only when redo logging is disabled and unset on slow shutdown after all pages are flushed to disk.

◆ LOG_HEADER_FLAG_FILE_FULL

constexpr uint32_t LOG_HEADER_FLAG_FILE_FULL = 4
constexpr

Flag at BIT-4 to mark the redo log file as completely full and closed for any future writes.

◆ LOG_HEADER_FLAG_MAX

constexpr uint32_t LOG_HEADER_FLAG_MAX = LOG_HEADER_FLAG_FILE_FULL
constexpr

Maximum BIT position number.

Should be set to the latest added.

◆ LOG_HEADER_FLAG_NO_LOGGING

constexpr uint32_t LOG_HEADER_FLAG_NO_LOGGING = 1
constexpr

Flag at BIT-1 to indicate if redo logging is disabled or not.

◆ LOG_HEADER_FLAG_NOT_INITIALIZED

constexpr uint32_t LOG_HEADER_FLAG_NOT_INITIALIZED = 3
constexpr

Flag at BIT-3 to indicate if server is not recoverable on crash because data directory still has not been fully initialized.

◆ LOG_HEADER_FLAGS

constexpr os_offset_t LOG_HEADER_FLAGS = LOG_HEADER_CREATOR_END
constexpr

32 BITs flag

◆ LOG_HEADER_FORMAT

constexpr os_offset_t LOG_HEADER_FORMAT = 0
constexpr

Log file header format identifier (32-bit unsigned big-endian integer).

This used to be called LOG_GROUP_ID and always written as 0, because InnoDB never supported more than one copy of the redo log.

◆ LOG_HEADER_LOG_UUID

constexpr uint32_t LOG_HEADER_LOG_UUID = 4
constexpr

Offset within the log file header, to the field which stores the log_uuid.

The log_uuid is chosen after a new data directory is initialized, and allows to detect situation, in which some of log files came from other data directory (detection is performed on startup, before starting recovery).

◆ LOG_HEADER_SIZE

constexpr os_offset_t LOG_HEADER_SIZE = LOG_HEADER_FLAGS + 4
constexpr

Current total size of LOG header.

◆ LOG_HEADER_START_LSN

constexpr os_offset_t LOG_HEADER_START_LSN = 8
constexpr

LSN of the start of data in this log file (with format version 1 and 2).

◆ LOG_MAX_OPEN_FILES

constexpr size_t LOG_MAX_OPEN_FILES = 2
constexpr

Maximum number of handles for opened redo log files (in parallel).

The following handles for opened files have been identified during runtime:

  • protected by the log_writer_mutex and the log_flusher_mutex:
    • log_writer() and log_flusher() use log.m_current_file_handle and this handle represents one file and can only be switched to the next file if both mutexes are acquired,
    • if redo log file is being rewritten, the read_handle for the old file acts on behalf of m_current_file_handle which is closed before the read_handle is opened.
  • protected by the log_files_mutex:
    • log_files_next_checkpoint() uses handle on stack,
    • log_files_prepare_unused_file() uses handle on stack,
    • log_encryption_write_low() uses handle on stack,
    • if redo log file is being rewritten, the write_handle for the new file uses this slot (protected by the files_mutex); it is opened after log_files_prepare_unused_file() closed its handle. During startup - in main thread (recv functions):
  • log_files_find_and_analyze() uses handle on stack,
  • recv_log_recover_pre_8_0_30() uses handle on stack,
  • recv_find_max_checkpoint() uses handle on stack,
  • recv_read_log_seg() uses handle on stack,
  • recv_recovery_from_checkpoint_start() uses handle on stack but after the recv_find_max_checkpoint() is finished and before the recv_read_log_seg() is started. Redo threads are started after the recv_recovery_from_checkpoint_start() is finished, so they don't use handle in parallel with these recv functions.

◆ LOG_N_FILES

constexpr size_t LOG_N_FILES = 32
constexpr

Targeted number of log files.

◆ LOG_N_FILES_MAX_DOWNSIZE_RATIO

constexpr double LOG_N_FILES_MAX_DOWNSIZE_RATIO = 1.0 / 8
constexpr

Determines maximum downsize for maximum redo file size during resize.

If maximum file size is 8G, then 1.0/8 means, that InnoDB needs to first achieve maximum file size equal to 1G before targeting even lower values.

◆ LOG_NEXT_FILE_EARLIER_MARGIN

constexpr double LOG_NEXT_FILE_EARLIER_MARGIN = 10
constexpr

Margin which is used ahead of log.write_lsn to create unused files earlier than the log.write_lsn reaches the m_end_lsn of the log.m_current_file.

This margin is expressed in percentage of the next file size.

◆ LOG_NO_CHECKSUM_MAGIC

constexpr uint32_t LOG_NO_CHECKSUM_MAGIC = 0xDEADBEEFUL
constexpr

Magic value to use instead of log checksums when they are disabled.

◆ LOG_START_LSN

constexpr lsn_t LOG_START_LSN = 16 * OS_FILE_LOG_BLOCK_SIZE
constexpr

The counting of lsn's starts from this value: this must be non-zero.

◆ LOG_WRITE_AHEAD_BUFFER_ALIGNMENT

constexpr size_t LOG_WRITE_AHEAD_BUFFER_ALIGNMENT
constexpr
Initial value:
=
constexpr size_t INNODB_KERNEL_PAGE_SIZE_DEFAULT
Default kernel page size (not assuming huge pages support).
Definition: ut0cpu_cache.h:44

Align the log write-ahead buffer (log_t::write_ahead_buf) to this size.

This increases chance that the write-ahead buffer is spanned over smaller number of memory pages. Please do not use this constant for other buffers.

◆ LSN_MAX

constexpr lsn_t LSN_MAX = (1ULL << 63) - 1
constexpr

Maximum possible lsn value is slightly higher than the maximum sn value, because lsn sequence enumerates also bytes used for headers and footers of all log blocks.

However, still 64-bits are enough to represent the maximum lsn value, because only 63 bits are used to represent sn value.

◆ MLOG_TEST_GROUP_MAX_REC_N

constexpr uint32_t MLOG_TEST_GROUP_MAX_REC_N = 100
constexpr

Maximum number of MLOG_TEST records in single group of log records.

◆ MLOG_TEST_MAX_REC_LEN

constexpr uint32_t MLOG_TEST_MAX_REC_LEN = 100
constexpr

Maximum size of single MLOG_TEST record (in bytes).

◆ MLOG_TEST_REC_OVERHEAD

constexpr uint32_t MLOG_TEST_REC_OVERHEAD = 37
constexpr

Bytes occupied by MLOG_TEST record with an empty payload.

◆ MLOG_TEST_VALUE

constexpr int64_t MLOG_TEST_VALUE = 10000
constexpr

Value to which MLOG_TEST records should sum up within a group.

◆ SN_LOCKED

constexpr sn_t SN_LOCKED = 1ULL << 63
constexpr

The sn bit to express locked state.