79#define LSN_PF UINT64PF
128typedef std::atomic<uint32_t (*)(
const byte *log_block)>
206 const std::string &root_path =
"",
565 constexpr Log_file_id MAX_FILE_ID = std::numeric_limits<Log_file_id>::max();
573struct alignas(ut::INNODB_CACHE_LINE_SIZE)
log_t;
The IO Context that is passed down to the low level IO code.
Definition: os0file.h:265
Handle which allows to do reads / writes for the opened file.
Definition: log0types.h:309
static uint64_t fsyncs_in_progress()
Definition: log0types.h:354
Log_file_id m_file_id
Id of the redo log file (part of its file name)
Definition: log0types.h:417
Log_file_handle(Encryption_metadata &encryption_metadata)
Definition: log0files_io.cc:176
static Log_file_io_callback s_on_before_read
Callback called on each read operation.
Definition: log0types.h:361
Log_file_access_mode m_access_mode
Access mode allowed for this handle (if not yet closed).
Definition: log0types.h:420
os_offset_t file_size() const
Definition: log0files_io.cc:315
os_offset_t m_file_size
Size of file in bytes (if opened)
Definition: log0types.h:450
dberr_t write(os_offset_t write_offset, os_offset_t write_size, const byte *buf)
Writes the provided buffer to the log file at the given offset.
Definition: log0files_io.cc:363
os_offset_t m_block_size
Size of single physical block (if opened)
Definition: log0types.h:447
bool is_open() const
Definition: log0files_io.cc:294
dberr_t open()
Open the log file with the configured access mode.
Definition: log0files_io.cc:255
IORequest prepare_io_request(int req_type, os_offset_t offset, os_offset_t size, bool can_use_encryption)
Creates and configures an io request object according to currently configured encryption metadata (m_...
Definition: log0files_io.cc:317
static std::atomic< size_t > s_n_open
Number of all opened Log_file_handle existing currently.
Definition: log0types.h:406
std::string m_file_path
File name.
Definition: log0types.h:441
pfs_os_file_t m_raw_handle
OS handle for file (if opened)
Definition: log0types.h:444
Log_file_handle(const Log_file_handle &other)=delete
static uint64_t total_fsyncs()
Definition: log0types.h:358
static bool s_skip_fsyncs
True iff all fsyncs should be no-op.
Definition: log0types.h:367
bool m_is_open
Whether file is opened.
Definition: log0types.h:435
dberr_t read(os_offset_t read_offset, os_offset_t read_size, byte *buf)
Reads from the log file at the given offset (to the provided buffer).
Definition: log0files_io.cc:346
Encryption_metadata & m_encryption_metadata
Encryption metadata to be used for all IO operations on this file except those related to the first L...
Definition: log0types.h:429
Log_file_handle & operator=(const Log_file_handle &rhs)=delete
void close()
Closes file represented by this handle (must be opened).
Definition: log0files_io.cc:282
static std::atomic< uint64_t > s_fsyncs_in_progress
Number of fsyncs in-progress.
Definition: log0types.h:410
Log_file_type m_file_type
Type of redo log file.
Definition: log0types.h:432
~Log_file_handle()
Closes handle if was opened (calling fsync if was modified).
Definition: log0files_io.cc:247
static std::atomic< uint64_t > s_total_fsyncs
Total number of fsyncs that have been started since the server has started.
Definition: log0types.h:414
Log_file_handle & operator=(Log_file_handle &&rhs)
Definition: log0files_io.cc:204
const std::string & file_path() const
Definition: log0files_io.cc:253
Log_file_id file_id() const
Definition: log0files_io.cc:313
bool m_is_modified
Whether file has been modified using this handle since it was opened.
Definition: log0types.h:438
void fsync()
Executes fsync operation for this redo log file.
Definition: log0files_io.cc:296
static Log_file_io_callback s_on_before_write
Callback called on each write operation.
Definition: log0types.h:364
dberr_t
Definition: db0err.h:39
Redo log constant values.
constexpr lsn_t LOG_START_LSN
The counting of lsn's starts from this value: this must be non-zero.
Definition: log0constants.h:153
constexpr os_offset_t LOG_FILE_HDR_SIZE
Size of log file's header.
Definition: log0constants.h:176
size_t Log_file_id
Log file id (0 for ib_redo0)
Definition: log0types.h:66
Log_file_access_mode
Type of access allowed for the opened redo log file.
Definition: log0types.h:294
@ READ_ONLY
The opened file can be only read.
@ READ_WRITE
The opened file can be both read and written.
@ WRITE_ONLY
The opened file can be only written.
Log_checkpoint_header_no
Enumerates checkpoint headers in the redo log file.
Definition: log0types.h:95
@ HEADER_2
The second checkpoint header.
@ HEADER_1
The first checkpoint header.
std::chrono::time_point< Log_clock > Log_clock_point
Time point defined by the Log_clock.
Definition: log0types.h:135
uint32_t Log_uuid
Number which tries to uniquely identify a created set of redo log files.
Definition: log0types.h:76
std::atomic< uint32_t(*)(const byte *log_block)> Log_checksum_algorithm_atomic_ptr
Function used to calculate checksums of log blocks.
Definition: log0types.h:129
Log_resize_mode
Direction of resize operation.
Definition: log0types.h:193
@ RESIZING_DOWN
Resizing down.
uint64_t sn_t
Type used for sn values, which enumerate bytes of data stored in the log.
Definition: log0types.h:86
Log_format
Supported redo log formats.
Definition: log0types.h:138
@ LEGACY
Unknown format of redo file.
@ VERSION_8_0_1
Remove MLOG_FILE_NAME and MLOG_CHECKPOINT, introduce MLOG_FILE_OPEN redo log record.
@ VERSION_8_0_3
Allow checkpoint_lsn to point any data byte within redo log (before it had to point the beginning of ...
@ VERSION_8_0_19
Expand ulint compressed form.
@ VERSION_8_0_28
Row versioning header.
@ VERSION_5_7_9
The MySQL 5.7.9 redo log format identifier.
@ VERSION_8_0_30
Introduced with innodb_redo_log_capacity:
Log_file_type
Type of redo log file.
Definition: log0types.h:108
@ NORMAL
Usual redo log file, most likely with important redo data.
@ UNUSED
Unused redo log file, might always be removed.
std::chrono::high_resolution_clock Log_clock
Clock used to measure time spent in redo log (e.g.
Definition: log0types.h:132
Log_files_ruleset
Ruleset defining how redo log files are named, where they are stored, when they are created and what ...
Definition: log0types.h:172
@ CURRENT
Redo log files are named ib_redo0, ib_redo1, ... and no longer wrapped.
@ PRE_8_0_30
Redo log files were named ib_logfile0, ib_logfile1, ... ib_logfile99.
std::atomic< int64_t > log_flushes_t
Type used for counters in log_t: flushes_requested and flushes_expected.
Definition: log0types.h:105
std::atomic< lsn_t > atomic_lsn_t
Alias for atomic based on lsn_t.
Definition: log0types.h:82
uint64_t lsn_t
Type used for all log sequence number storage and arithmetic.
Definition: log0types.h:63
std::atomic< sn_t > atomic_sn_t
Alias for atomic based on sn_t.
Definition: log0types.h:89
uint32_t Log_flags
Log flags (stored in file header of log file).
Definition: log0types.h:69
std::function< void(Log_file_id file_id, Log_file_type file_type, os_offset_t offset, os_offset_t size)> Log_file_io_callback
Callback called on each read or write operation on a redo log file.
Definition: log0types.h:125
Type inc(Shards< COUNT > &shards, size_t id)
Increment the counter of a shard by 1.
Definition: ut0counter.h:293
Definition: buf0block_hint.cc:30
size_t size(const char *const c)
Definition: base64.h:46
The interface to the operating system file io.
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
uint64_t os_offset_t
File offset in bytes.
Definition: os0file.h:87
Pair of: log file id and log file header.
Definition: log0types.h:280
Log_file_id_and_header(Log_file_id id, Log_file_header header)
Definition: log0types.h:283
Log_file_id m_id
Id of the file.
Definition: log0types.h:287
Log_file_id_and_header()=default
Log_file_header m_header
Main header of the file.
Definition: log0types.h:290
Pair of: log file id and log file size (expressed in bytes).
Definition: log0types.h:266
Log_file_id m_id
Id of the file.
Definition: log0types.h:273
Log_file_id_and_size(Log_file_id id, os_offset_t size)
Definition: log0types.h:269
Log_file_id_and_size()=default
os_offset_t m_size_in_bytes
Size of file, expressed in bytes.
Definition: log0types.h:276
Meta information about single log file.
Definition: log0types.h:454
bool contains(lsn_t lsn) const
Checks if a given lsn belongs to [m_start_lsn, m_end_lsn).
Definition: log0types.h:514
Log_file_id m_id
ID of the file.
Definition: log0types.h:470
Log_file & operator=(const Log_file &other)
Definition: log0files_io.cc:420
Log_file(const Log_file &other)=default
Log_file_id next_id() const
Computes id of the next log file.
Definition: log0types.h:538
bool m_consumed
Set to true when file becomes consumed.
Definition: log0types.h:473
static Log_file_id next_id(Log_file_id id, size_t inc=1)
Computes id + inc, asserting it does not overflow the maximum value.
Definition: log0types.h:564
bool operator==(const Log_file &rhs) const
Checks if this object is equal to a given another object.
Definition: log0types.h:496
bool m_full
Set to true when file became full and next file exists.
Definition: log0types.h:476
lsn_t m_start_lsn
LSN of the first byte within the file, aligned to OS_FILE_LOG_BLOCK_SIZE.
Definition: log0types.h:483
const Log_files_context & m_files_ctx
Context within which this file exists.
Definition: log0types.h:467
static os_offset_t offset(lsn_t lsn, lsn_t file_start_lsn)
Provides offset for the given LSN and log file with the given start_lsn (offset from the beginning of...
Definition: log0types.h:532
void lsn_validate() const
Validates that lsn fields seem correct (m_start_lsn, m_end_lsn)
Definition: log0types.h:503
Log_file(const Log_files_context &files_ctx, Encryption_metadata &encryption_metadata)
Definition: log0files_io.cc:396
lsn_t m_end_lsn
LSN of the first byte after the file, aligned to OS_FILE_LOG_BLOCK_SIZE.
Definition: log0types.h:487
os_offset_t m_size_in_bytes
Size, expressed in bytes, including LOG_FILE_HDR_SIZE.
Definition: log0types.h:479
Log_file_handle open(Log_file_access_mode access_mode) const
Opens this file and provides handle that allows to read from this file and / or write to this file (d...
Definition: log0files_io.cc:382
os_offset_t offset(lsn_t lsn) const
Provides offset for the given LSN (from the beginning of the log file).
Definition: log0types.h:521
Encryption_metadata & m_encryption_metadata
Encryption metadata passed to opened file handles.
Definition: log0types.h:491
Configures path to the root directory, where redo subdirectory might be located (or redo log files if...
Definition: log0types.h:204
Log_files_context(const std::string &root_path="", Log_files_ruleset files_ruleset=Log_files_ruleset::CURRENT)
Definition: log0files_io.cc:1202
Log_files_ruleset m_files_ruleset
Ruleset determining how file paths are built.
Definition: log0types.h:213
std::string m_root_path
Path to the root directory.
Definition: log0types.h:210
Runtime statistics related to redo log files management.
Definition: log0types.h:577
Log_clock_point m_last_update_time
Last time stats were updated (last successful call to.
Definition: log0types.h:579
lsn_t m_newest_lsn_on_update
Newest LSN returned by log_files_newest_needed_lsn() during last successful call to.
Definition: log0types.h:597
lsn_t m_lsn_production_per_1s
LSN difference by which result of log_files_newest_needed_lsn() advanced during last second.
Definition: log0types.h:589
void update(const log_t &log)
Tries to update stats.
Definition: log0files_governor.cc:1181
lsn_t m_oldest_lsn_on_update
Oldest LSN returned by log_files_oldest_needed_lsn() during last successful call to.
Definition: log0types.h:593
lsn_t m_lsn_consumption_per_1s
LSN difference by which result of log_files_oldest_needed_lsn() advanced during last second.
Definition: log0types.h:584
Redo log - single data structure with state of the redo log system.
Definition: log0sys.h:77
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:172
Version control for database, common definitions, and include files.
Utilities related to CPU cache.
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
static uint64_t lsn
Definition: xcom_base.cc:446
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:510