MySQL 9.1.0
Source Code Documentation
log_t Struct Reference

Redo log - single data structure with state of the redo log system. More...

#include <log0sys.h>

Public Attributes

Users writing to log buffer
os_event_t sn_lock_event
 Event used for locking sn. More...
 
rw_lock_tsn_lock_inst
 The rw_lock instance only for the debug info list. More...
 
atomic_sn_t sn
 Current sn value. More...
 
atomic_sn_t sn_locked
 Intended sn value while x-locked. More...
 
ib_mutex_t sn_x_lock_mutex
 Mutex which can be used for x-lock sn value. More...
 
ut::aligned_array_pointer< byte, LOG_BUFFER_ALIGNMENTbuf
 Aligned log buffer. More...
 
atomic_sn_t buf_size_sn
 Size of the log buffer expressed in number of data bytes, that is excluding bytes for headers and footers of log blocks. More...
 
size_t buf_size
 Size of the log buffer expressed in number of total bytes, that is including bytes for headers and footers of log blocks. More...
 
struct PSI_rwlockpfs_psi
 The instrumentation hook. More...
 
Link_buf< lsn_trecent_written
 The recent written buffer. More...
 
std::atomic_bool writer_threads_paused
 Used for pausing the log writer threads. More...
 
Users <=> writer
atomic_sn_t buf_limit_sn
 Maximum sn up to which there is free space in both the log buffer and the log files. More...
 
atomic_lsn_t write_lsn
 Up to this lsn, data has been written to disk (fsync not required). More...
 
os_event_twrite_events
 Unaligned pointer to array with events, which are used for notifications sent from the log write notifier thread to user threads. More...
 
size_t write_events_size
 Number of entries in the array with writer_events. More...
 
std::atomic< uint64_t > write_to_file_requests_total
 Approx. More...
 
std::atomic< std::chrono::microseconds > write_to_file_requests_interval
 How often redo write/flush is requested in average. More...
 
Users <=> flusher
os_event_tflush_events
 Unaligned pointer to array with events, which are used for notifications sent from the log flush notifier thread to user threads. More...
 
size_t flush_events_size
 Number of entries in the array with events. More...
 
os_event_t old_flush_event
 This event is in the reset state when a flush is running; a thread should wait for this without owning any of redo mutexes, but NOTE that to reset this event, the thread MUST own the writer_mutex. More...
 
atomic_lsn_t flushed_to_disk_lsn
 Up to this lsn data has been flushed to disk (fsynced). More...
 
Log flusher thread
Log_clock_point last_flush_start_time
 Last flush start time. More...
 
Log_clock_point last_flush_end_time
 Last flush end time. More...
 
double flush_avg_time
 Flushing average time (in microseconds). More...
 
ib_mutex_t flusher_mutex
 Mutex which can be used to pause log flusher thread. More...
 
os_event_t flusher_event
 
Log writer thread
uint32_t write_ahead_buf_size
 Size of buffer used for the write-ahead (in bytes). More...
 
ut::aligned_array_pointer< byte, LOG_WRITE_AHEAD_BUFFER_ALIGNMENTwrite_ahead_buf
 Aligned buffer used for some of redo log writes. More...
 
os_offset_t write_ahead_end_offset
 Up to this file offset in the log files, the write-ahead has been done or is not required (for any other reason). More...
 
Log_file m_current_file {m_files_ctx, m_encryption_metadata}
 File within which write_lsn is located, so the newest file in m_files in the same time - updates are protected by the m_files_mutex. More...
 
Log_file_handle m_current_file_handle {m_encryption_metadata}
 Handle for the opened m_current_file. More...
 
bool m_writer_inside_extra_margin
 True iff the log writer has entered extra writer margin and still hasn't exited since then. More...
 
uint64_t n_log_ios
 Number of performed IO operations (only for printing stats). More...
 
ib_mutex_t writer_mutex
 Mutex which can be used to pause log writer thread. More...
 
THDm_writer_thd
 THD used by the log_writer thread. More...
 
os_event_t writer_event
 
lsn_t m_oldest_need_lsn_lowerbound
 A recently seen value of log_consumer_get_oldest()->get_consumed_lsn(). More...
 
Log closing
os_event_t closer_event
 Event used by threads to wait for recent_written.tail() to advance. More...
 
ib_mutex_t closer_mutex
 Mutex protecting closer_event, current_ready_waiting_lsn, and current_ready_waiting_sig_count. More...
 
lsn_t current_ready_waiting_lsn
 Some threads waiting for the ready for write lsn by closer_event. More...
 
int64_t current_ready_waiting_sig_count
 current_ready_waiting_lsn is waited using this sig_count. More...
 
Log flusher <=> flush_notifier
os_event_t flush_notifier_event
 Event used by the log flusher thread to notify the log flush notifier thread, that it should proceed with notifying user threads waiting for the advanced flushed_to_disk_lsn (because it has been advanced). More...
 
int64_t current_flush_sig_count
 The next flushed_to_disk_lsn can be waited using this sig_count. More...
 
ib_mutex_t flush_notifier_mutex
 Mutex which can be used to pause log flush notifier thread. More...
 
Log writer <=> write_notifier
ib_mutex_t write_notifier_mutex
 Mutex which can be used to pause log write notifier thread. More...
 
os_event_t write_notifier_event
 Event used by the log writer thread to notify the log write notifier thread, that it should proceed with notifying user threads waiting for the advanced write_lsn (because it has been advanced). More...
 
Log files management
ib_mutex_t m_files_mutex
 Mutex protecting set of existing log files and their meta data. More...
 
Log_files_context m_files_ctx
 Context for all operations on redo log files from log0files_io.h. More...
 
Log_files_dict m_files {m_files_ctx}
 The in-memory dictionary of log files. More...
 
size_t m_unused_files_count
 Number of existing unused files (those with _tmp suffix). More...
 
os_offset_t m_unused_file_size
 Size of each unused redo log file, to which recently all unused redo log files became resized. More...
 
Log_files_capacity m_capacity
 Capacity limits for the redo log. More...
 
bool m_requested_files_consumption
 True iff log_writer is waiting for a next log file available. More...
 
Log_files_stats m_files_stats
 Statistics related to redo log files consumption and creation. More...
 
os_event_t m_files_governor_event
 Event used by log files governor thread to wait. More...
 
ib_mutex_t governor_iteration_mutex
 Mutex which can be used to pause log governor thread. More...
 
os_event_t m_files_governor_iteration_event
 Event used by other threads to wait until log files governor finished its next iteration. More...
 
std::atomic_bool m_no_more_dummy_records_requested
 False if log files governor thread is allowed to add new redo records. More...
 
std::atomic_bool m_no_more_dummy_records_promised
 False if the log files governor thread is allowed to add new dummy redo records. More...
 
THDm_files_governor_thd
 THD used by the log_files_governor thread. More...
 
os_event_t m_file_removed_event
 Event used for waiting on next file available. More...
 
byte m_encryption_buf [OS_FILE_LOG_BLOCK_SIZE]
 Buffer that contains encryption meta data encrypted with master key. More...
 
Encryption_metadata m_encryption_metadata
 Encryption metadata. More...
 
Consumers
ut::unordered_set< Log_consumer * > m_consumers
 Set of registered redo log consumers. More...
 
Maintenance
std::atomic_bool should_stop_threads
 Used for stopping the log background threads. More...
 
os_event_t writer_threads_resume_event
 Event used for pausing the log writer threads. More...
 
atomic_lsn_t write_notifier_resume_lsn
 Used for resuming write notifier thread. More...
 
atomic_lsn_t flush_notifier_resume_lsn
 Used for resuming flush notifier thread. More...
 
uint64_t n_log_ios_old
 Number of total I/O operations performed when we printed the statistics last time. More...
 
time_t last_printout_time
 Wall time when we printed the statistics last time. More...
 
Recovery
lsn_t recovered_lsn
 Lsn from which recovery has been started. More...
 
Log_format m_format
 Format of the redo log: e.g., Log_format::CURRENT. More...
 
std::string m_creator_name
 Log creator name. More...
 
Log_flags m_log_flags
 Log flags. More...
 
Log_uuid m_log_uuid
 Log UUID. More...
 
lsn_t m_scanned_lsn
 Used only in recovery: recovery scan succeeded up to this lsn. More...
 
bool disable_redo_writes
 When this is set, writing to the redo log should be disabled. More...
 
Fields protected by the log_limits_mutex.

Related to free space in the redo log.

ib_mutex_t limits_mutex
 Mutex which protects fields: available_for_checkpoint_lsn, requested_checkpoint_lsn. More...
 
lsn_t available_for_checkpoint_lsn
 A new checkpoint could be written for this lsn value. More...
 
lsn_t requested_checkpoint_lsn
 When this is larger than the latest checkpoint, the log checkpointer thread will be forced to write a new checkpoint (unless the new latest checkpoint lsn would still be smaller than this value). More...
 
lsn_t dict_max_allowed_checkpoint_lsn
 Maximum lsn allowed for checkpoint by dict_persist or zero. More...
 
bool periodical_checkpoints_enabled
 If should perform checkpoints every innodb_log_checkpoint_every ms. More...
 
std::atomic_bool m_allow_checkpoints
 If checkpoints are allowed. More...
 
atomic_lsn_t free_check_limit_lsn
 Maximum lsn up to which there is free space in the redo log. More...
 
atomic_sn_t concurrency_margin
 Margin used in calculation of. More...
 
std::atomic< bool > concurrency_margin_is_safe
 True iff current concurrency_margin isn't truncated because of too small redo log capacity. More...
 
atomic_sn_t dict_persist_margin
 Margin used in calculation of. More...
 
Log checkpointer thread
os_event_t checkpointer_event
 Event used by the log checkpointer thread to wait for requests. More...
 
ib_mutex_t checkpointer_mutex
 Mutex which can be used to pause log checkpointer thread. More...
 
atomic_lsn_t last_checkpoint_lsn
 Latest checkpoint lsn. More...
 
Log_checkpoint_header_no next_checkpoint_header_no
 Next checkpoint header to use. More...
 
os_event_t next_checkpoint_event
 Event signaled when last_checkpoint_lsn is advanced by the log_checkpointer thread. More...
 
Log_clock_point last_checkpoint_time
 Latest checkpoint wall time. More...
 
Log_checkpoint_consumer m_checkpoint_consumer {*this}
 Redo log consumer which is always registered and which is responsible for protecting redo log records at lsn >= last_checkpoint_lsn. More...
 
THDm_checkpointer_thd
 THD used by the log_checkpointer thread. More...
 

Detailed Description

Redo log - single data structure with state of the redo log system.

In future, one could consider splitting this to multiple data structures.

Member Data Documentation

◆ available_for_checkpoint_lsn

lsn_t log_t::available_for_checkpoint_lsn

A new checkpoint could be written for this lsn value.

Up to this lsn value, all dirty pages have been added to flush lists and flushed. Updated in the log checkpointer thread by taking minimum oldest_modification out of the last dirty pages from each flush list minus buf_flush_list_added->order_lag(). However it will not be bigger than the current value of buf_flush_list_added->smallest_not_added_lsn(). Read by: user threads when requesting fuzzy checkpoint Read by: log_print() (printing status of redo) Updated by: log_checkpointer Protected by: limits_mutex.

◆ buf

Aligned log buffer.

Committing mini-transactions write there redo records, and the log_writer thread writes the log buffer to disk in background. Protected by: locking sn not to add.

◆ buf_limit_sn

atomic_sn_t log_t::buf_limit_sn

Maximum sn up to which there is free space in both the log buffer and the log files.

This is limitation for the end of any write to the log buffer. Threads, which are limited need to wait, and possibly they hold latches of dirty pages making a deadlock possible. Protected by: writer_mutex (writes).

◆ buf_size

size_t log_t::buf_size

Size of the log buffer expressed in number of total bytes, that is including bytes for headers and footers of log blocks.

◆ buf_size_sn

atomic_sn_t log_t::buf_size_sn

Size of the log buffer expressed in number of data bytes, that is excluding bytes for headers and footers of log blocks.

◆ checkpointer_event

os_event_t log_t::checkpointer_event

Event used by the log checkpointer thread to wait for requests.

◆ checkpointer_mutex

ib_mutex_t log_t::checkpointer_mutex
mutable

Mutex which can be used to pause log checkpointer thread.

This is used by log_position_lock() together with log_buffer_x_lock(), to pause any changes to current_lsn or last_checkpoint_lsn.

◆ closer_event

os_event_t log_t::closer_event

Event used by threads to wait for recent_written.tail() to advance.

Protected by: closer_mutex.

◆ closer_mutex

ib_mutex_t log_t::closer_mutex
mutable

Mutex protecting closer_event, current_ready_waiting_lsn, and current_ready_waiting_sig_count.

◆ concurrency_margin

atomic_sn_t log_t::concurrency_margin

Margin used in calculation of.

See also
free_check_limit_lsn. Protected by (updates only): limits_mutex.

◆ concurrency_margin_is_safe

std::atomic<bool> log_t::concurrency_margin_is_safe

True iff current concurrency_margin isn't truncated because of too small redo log capacity.

Protected by (updates only): limits_mutex.

◆ current_flush_sig_count

int64_t log_t::current_flush_sig_count

The next flushed_to_disk_lsn can be waited using this sig_count.

◆ current_ready_waiting_lsn

lsn_t log_t::current_ready_waiting_lsn

Some threads waiting for the ready for write lsn by closer_event.

Protected by: closer_mutex.

◆ current_ready_waiting_sig_count

int64_t log_t::current_ready_waiting_sig_count

current_ready_waiting_lsn is waited using this sig_count.

Protected by: closer_mutex.

◆ dict_max_allowed_checkpoint_lsn

lsn_t log_t::dict_max_allowed_checkpoint_lsn

Maximum lsn allowed for checkpoint by dict_persist or zero.

This will be set by dict_persist_to_dd_table_buffer(), which should be always called before really making a checkpoint. If non-zero, up to this lsn value, dynamic metadata changes have been written back to mysql.innodb_dynamic_metadata under dict_persist->mutex protection. All dynamic metadata changes after this lsn have to be kept in redo logs, but not discarded. If zero, just ignore it. Updated by: DD (when persisting dynamic meta data) Updated by: log_checkpointer (reset when checkpoint is written) Protected by: limits_mutex.

◆ dict_persist_margin

atomic_sn_t log_t::dict_persist_margin

Margin used in calculation of.

See also
free_check_limit_lsn. Read by: page_cleaners, log_checkpointer Updated by: DD Protected by (updates only): limits_mutex.

◆ disable_redo_writes

bool log_t::disable_redo_writes

When this is set, writing to the redo log should be disabled.

We check for this in functions that write to the redo log.

◆ flush_avg_time

double log_t::flush_avg_time

Flushing average time (in microseconds).

◆ flush_events

os_event_t* log_t::flush_events

Unaligned pointer to array with events, which are used for notifications sent from the log flush notifier thread to user threads.

The notifications are sent when flushed_to_disk_lsn is advanced. User threads wait for flushed_to_disk_lsn >= lsn, for some lsn. Log flusher advances the flushed_to_disk_lsn and notifies the log flush notifier, which notifies all users interested in nearby lsn values (lsn belonging to the same log block). Note that false wake-ups are possible, in which case user threads simply retry waiting.

◆ flush_events_size

size_t log_t::flush_events_size

Number of entries in the array with events.

◆ flush_notifier_event

os_event_t log_t::flush_notifier_event

Event used by the log flusher thread to notify the log flush notifier thread, that it should proceed with notifying user threads waiting for the advanced flushed_to_disk_lsn (because it has been advanced).

◆ flush_notifier_mutex

ib_mutex_t log_t::flush_notifier_mutex
mutable

Mutex which can be used to pause log flush notifier thread.

◆ flush_notifier_resume_lsn

atomic_lsn_t log_t::flush_notifier_resume_lsn

Used for resuming flush notifier thread.

◆ flushed_to_disk_lsn

atomic_lsn_t log_t::flushed_to_disk_lsn

Up to this lsn data has been flushed to disk (fsynced).

◆ flusher_event

os_event_t log_t::flusher_event

◆ flusher_mutex

ib_mutex_t log_t::flusher_mutex
mutable

Mutex which can be used to pause log flusher thread.

◆ free_check_limit_lsn

atomic_lsn_t log_t::free_check_limit_lsn

Maximum lsn up to which there is free space in the redo log.

Threads check this limit and compare to current lsn, when they are outside mini-transactions and hold no latches. The formula used to compute the limitation takes into account maximum size of mtr and thread concurrency to include proper margins and avoid issues with race condition (in which all threads check the limitation and then all proceed with their mini-transactions). Also extra margin is there for dd table buffer cache (dict_persist_margin). Read by: user threads (log_free_check()) Updated by: log_checkpointer (after update of checkpoint_lsn) Updated by: log_writer (after pausing/resuming user threads) Updated by: DD (after update of dict_persist_margin) Protected by (updates only): limits_mutex.

◆ governor_iteration_mutex

ib_mutex_t log_t::governor_iteration_mutex
mutable

Mutex which can be used to pause log governor thread.

◆ last_checkpoint_lsn

atomic_lsn_t log_t::last_checkpoint_lsn

Latest checkpoint lsn.

Read by: user threads, log_print (no protection) Read by: log_writer (under writer_mutex) Updated by: log_checkpointer (under both mutexes) Protected by (updates only): checkpointer_mutex + writer_mutex.

◆ last_checkpoint_time

Log_clock_point log_t::last_checkpoint_time

Latest checkpoint wall time.

Used by (private): log_checkpointer.

◆ last_flush_end_time

Log_clock_point log_t::last_flush_end_time

Last flush end time.

Updated just after fsync is finished. If smaller than start time, then flush operation is pending.

◆ last_flush_start_time

Log_clock_point log_t::last_flush_start_time

Last flush start time.

Updated just before fsync starts.

◆ last_printout_time

time_t log_t::last_printout_time
mutable

Wall time when we printed the statistics last time.

◆ limits_mutex

ib_mutex_t log_t::limits_mutex
mutable

Mutex which protects fields: available_for_checkpoint_lsn, requested_checkpoint_lsn.

It also synchronizes updates of: free_check_limit_lsn, concurrency_margin, dict_persist_margin. It protects reads and writes of m_writer_inside_extra_margin. It also protects the srv_checkpoint_disabled (together with the checkpointer_mutex).

◆ m_allow_checkpoints

std::atomic_bool log_t::m_allow_checkpoints

If checkpoints are allowed.

When this is set to false, neither new checkpoints might be written nor lsn available for checkpoint might be updated. This is useful in recovery period, when neither flush lists can be trusted nor DD dynamic metadata redo records might be reclaimed. This is never set from true to false after log_start().

◆ m_capacity

Log_files_capacity log_t::m_capacity

Capacity limits for the redo log.

Responsible for resize. Mutex protection is decided per each Log_files_capacity method.

◆ m_checkpoint_consumer

Log_checkpoint_consumer log_t::m_checkpoint_consumer {*this}

Redo log consumer which is always registered and which is responsible for protecting redo log records at lsn >= last_checkpoint_lsn.

◆ m_checkpointer_thd

THD* log_t::m_checkpointer_thd

THD used by the log_checkpointer thread.

◆ m_consumers

ut::unordered_set<Log_consumer *> log_t::m_consumers

Set of registered redo log consumers.

Note, that this object is not responsible for freeing them (does not claim to be owner). If you wanted to register or unregister a redo log consumer, then please use following functions:

See also
log_consumer_register() and
log_consumer_unregister(). The details of implementation related to redo log consumers can be found in log0consumer.cc. Protected by: m_files_mutex (unless it is the startup phase or the shutdown phase).

◆ m_creator_name

std::string log_t::m_creator_name

Log creator name.

◆ m_current_file

Log_file log_t::m_current_file {m_files_ctx, m_encryption_metadata}

File within which write_lsn is located, so the newest file in m_files in the same time - updates are protected by the m_files_mutex.

This field exists, because the log_writer thread needs to locate offsets each time it writes data blocks to disk, but we do not want to acquire and release the m_files_mutex for each such write, because that would slow down the log_writer thread a lot. Instead of that, the log_writer uses this object to locate the offsets.

Updates of this field require two mutexes: writer_mutex and m_files_mutex. Its m_id is updated only when the write_lsn moves to the next log file.

◆ m_current_file_handle

Log_file_handle log_t::m_current_file_handle {m_encryption_metadata}

Handle for the opened m_current_file.

The log_writer uses this handle to do writes (protected by writer_mutex). The log_flusher uses this handle to do fsyncs (protected by flusher_mutex). Both these threads might use this handle in parallel. The required synchronization between writes and fsyncs will happen on the OS side. When m_current_file is re-pointed to other file, this field is also updated, in the same critical section. Updates of this field are protected by: writer_mutex, m_files_mutex and flusher_mutex acquired all together. The reason for flusher_mutex is to avoid a need to acquire / release m_files_mutex in the log_flusher thread for each fsync. Instead of that, the log_flusher thread keeps the log_flusher_mutex, which is released less often, but still prevents from updates of this field.

◆ m_encryption_buf

byte log_t::m_encryption_buf[OS_FILE_LOG_BLOCK_SIZE]

Buffer that contains encryption meta data encrypted with master key.

Protected by: m_files_mutex

◆ m_encryption_metadata

Encryption_metadata log_t::m_encryption_metadata

Encryption metadata.

This member is passed to Log_file_handle objects created for redo log files. In particular, the m_current_file_handle has a reference to this field. When encryption metadata is updated, it needs to be written to the redo log file's header. Also, each write performed by the log_writer thread needs to use m_encryption_metadata (it's passed by reference to the m_current_file_handle) and the log_writer does not acquire m_files_mutex for its writes (it is a hot path and it's better to keep it shorter). Therefore it's been decided that updates of this field require both m_files_mutex and writer_mutex. Protected by: m_files_mutex, writer_mutex

◆ m_file_removed_event

os_event_t log_t::m_file_removed_event

Event used for waiting on next file available.

Used by log writer thread to wait when it needs to produce a next log file but there are no free (consumed) log files available.

◆ m_files

Log_files_dict log_t::m_files {m_files_ctx}

The in-memory dictionary of log files.

Protected by: m_files_mutex.

◆ m_files_ctx

Log_files_context log_t::m_files_ctx

Context for all operations on redo log files from log0files_io.h.

◆ m_files_governor_event

os_event_t log_t::m_files_governor_event

Event used by log files governor thread to wait.

◆ m_files_governor_iteration_event

os_event_t log_t::m_files_governor_iteration_event

Event used by other threads to wait until log files governor finished its next iteration.

This is useful when some sys_var gets changed to wait until log files governor re-computed everything and then check if the concurrency_margin is safe to emit warning if needed (the warning would still belong to the sys_var's SET GLOBAL statement then).

◆ m_files_governor_thd

THD* log_t::m_files_governor_thd

THD used by the log_files_governor thread.

◆ m_files_mutex

ib_mutex_t log_t::m_files_mutex
mutable

Mutex protecting set of existing log files and their meta data.

◆ m_files_stats

Log_files_stats log_t::m_files_stats

Statistics related to redo log files consumption and creation.

Protected by: m_files_mutex.

◆ m_format

Log_format log_t::m_format

Format of the redo log: e.g., Log_format::CURRENT.

◆ m_log_flags

Log_flags log_t::m_log_flags

Log flags.

◆ m_log_uuid

Log_uuid log_t::m_log_uuid

Log UUID.

◆ m_no_more_dummy_records_promised

std::atomic_bool log_t::m_no_more_dummy_records_promised

False if the log files governor thread is allowed to add new dummy redo records.

This is set to true only by the log_files_governor thread, and after it observed

See also
m_no_more_dummy_records_requested being true. It can be used to wait until the log files governor thread promises not to generate any more dummy redo records.

◆ m_no_more_dummy_records_requested

std::atomic_bool log_t::m_no_more_dummy_records_requested

False if log files governor thread is allowed to add new redo records.

This is set as intention, to tell the log files governor about what it is allowed to do. To ensure that the log_files_governor is aware of what has been told, user needs to wait on

See also
m_no_more_dummy_records_promised.

◆ m_oldest_need_lsn_lowerbound

lsn_t log_t::m_oldest_need_lsn_lowerbound

A recently seen value of log_consumer_get_oldest()->get_consumed_lsn().

It serves as a lower bound for future values of this expression, because it is guaranteed to be monotonic in time: each individual consumer can only go forward, and new consumers must start at least from checkpoint lsn, and the checkpointer is always one of the consumers. Protected by: writer_mutex.

◆ m_requested_files_consumption

bool log_t::m_requested_files_consumption

True iff log_writer is waiting for a next log file available.

Protected by: m_files_mutex.

◆ m_scanned_lsn

lsn_t log_t::m_scanned_lsn

Used only in recovery: recovery scan succeeded up to this lsn.

◆ m_unused_file_size

os_offset_t log_t::m_unused_file_size

Size of each unused redo log file, to which recently all unused redo log files became resized.

Expressed in bytes.

◆ m_unused_files_count

size_t log_t::m_unused_files_count

Number of existing unused files (those with _tmp suffix).

Protected by: m_files_mutex.

◆ m_writer_inside_extra_margin

bool log_t::m_writer_inside_extra_margin

True iff the log writer has entered extra writer margin and still hasn't exited since then.

Each time the log_writer enters that margin, it pauses all user threads at log_free_check() calls and emits warning to the log. When the writer exits the extra margin, notice is emitted. Protected by: log_limits_mutex and writer_mutex.

◆ m_writer_thd

THD* log_t::m_writer_thd

THD used by the log_writer thread.

◆ n_log_ios

uint64_t log_t::n_log_ios

Number of performed IO operations (only for printing stats).

◆ n_log_ios_old

uint64_t log_t::n_log_ios_old
mutable

Number of total I/O operations performed when we printed the statistics last time.

◆ next_checkpoint_event

os_event_t log_t::next_checkpoint_event

Event signaled when last_checkpoint_lsn is advanced by the log_checkpointer thread.

◆ next_checkpoint_header_no

Log_checkpoint_header_no log_t::next_checkpoint_header_no

Next checkpoint header to use.

Updated by: log_checkpointer Protected by: checkpointer_mutex

◆ old_flush_event

os_event_t log_t::old_flush_event

This event is in the reset state when a flush is running; a thread should wait for this without owning any of redo mutexes, but NOTE that to reset this event, the thread MUST own the writer_mutex.

◆ periodical_checkpoints_enabled

bool log_t::periodical_checkpoints_enabled

If should perform checkpoints every innodb_log_checkpoint_every ms.

Disabled during startup / shutdown. Enabled in srv_start_threads. Updated by: starting thread (srv_start_threads) Read by: log_checkpointer

◆ pfs_psi

struct PSI_rwlock* log_t::pfs_psi

The instrumentation hook.

Remarks
This field is rarely modified, so can not be the cause of frequent cache line invalidations. However, user threads read it only during mtr.commit(), which in some scenarios happens rarely enough, that the cache line containing pfs_psi is evicted between mtr.commit()s causing a cache miss, a stall and in consequence MACHINE_CLEARS during mtr.commit(). As this miss seems inevitable, we at least want to make it really worth it. So, we put the pfs_psi in the same cache line which contains buf, buf_size_sn and buf_size, which are also needed during mtr.commit(). This way instead of two separate cache misses, we have just one. TBD: We could additionally use lfence to limit MACHINE_CLEARS.

◆ recent_written

Link_buf<lsn_t> log_t::recent_written

The recent written buffer.

Protected by: locking sn not to add.

◆ recovered_lsn

lsn_t log_t::recovered_lsn

Lsn from which recovery has been started.

◆ requested_checkpoint_lsn

lsn_t log_t::requested_checkpoint_lsn

When this is larger than the latest checkpoint, the log checkpointer thread will be forced to write a new checkpoint (unless the new latest checkpoint lsn would still be smaller than this value).

Read by: log_checkpointer Updated by: user threads (log_free_check() or for sharp checkpoint) Protected by: limits_mutex.

◆ should_stop_threads

std::atomic_bool log_t::should_stop_threads

Used for stopping the log background threads.

◆ sn

atomic_sn_t log_t::sn

Current sn value.

Used to reserve space in the redo log, and used to acquire an exclusive access to the log buffer. Represents number of data bytes that have ever been reserved. Bytes of headers and footers of log blocks are not included. Its highest bit is used for locking the access to the log buffer.

◆ sn_lock_event

os_event_t log_t::sn_lock_event

Event used for locking sn.

◆ sn_lock_inst

rw_lock_t* log_t::sn_lock_inst

The rw_lock instance only for the debug info list.

◆ sn_locked

atomic_sn_t log_t::sn_locked

Intended sn value while x-locked.

◆ sn_x_lock_mutex

ib_mutex_t log_t::sn_x_lock_mutex
mutable

Mutex which can be used for x-lock sn value.

◆ write_ahead_buf

Aligned buffer used for some of redo log writes.

Data is copied there from the log buffer and written to disk, in following cases:

  • when writing ahead full kernel page to avoid read-on-write issue,
  • to copy, prepare and write the incomplete block of the log buffer (because mini-transactions might be writing new redo records to the block in parallel, when the block is being written to disk)

◆ write_ahead_buf_size

uint32_t log_t::write_ahead_buf_size

Size of buffer used for the write-ahead (in bytes).

◆ write_ahead_end_offset

os_offset_t log_t::write_ahead_end_offset

Up to this file offset in the log files, the write-ahead has been done or is not required (for any other reason).

◆ write_events

os_event_t* log_t::write_events

Unaligned pointer to array with events, which are used for notifications sent from the log write notifier thread to user threads.

The notifications are sent when write_lsn is advanced. User threads wait for write_lsn >= lsn, for some lsn. Log writer advances the write_lsn and notifies the log write notifier, which notifies all users interested in nearby lsn values (lsn belonging to the same log block). Note that false wake-ups are possible, in which case user threads simply retry waiting.

◆ write_events_size

size_t log_t::write_events_size

Number of entries in the array with writer_events.

◆ write_lsn

atomic_lsn_t log_t::write_lsn

Up to this lsn, data has been written to disk (fsync not required).

Protected by: writer_mutex (writes).

◆ write_notifier_event

os_event_t log_t::write_notifier_event

Event used by the log writer thread to notify the log write notifier thread, that it should proceed with notifying user threads waiting for the advanced write_lsn (because it has been advanced).

◆ write_notifier_mutex

ib_mutex_t log_t::write_notifier_mutex
mutable

Mutex which can be used to pause log write notifier thread.

◆ write_notifier_resume_lsn

atomic_lsn_t log_t::write_notifier_resume_lsn

Used for resuming write notifier thread.

◆ write_to_file_requests_interval

std::atomic<std::chrono::microseconds> log_t::write_to_file_requests_interval

How often redo write/flush is requested in average.

Measures in microseconds. Log threads do not spin when the write/flush requests are not frequent.

◆ write_to_file_requests_total

std::atomic<uint64_t> log_t::write_to_file_requests_total

Approx.

number of requests to write/flush redo since startup.

◆ writer_event

os_event_t log_t::writer_event

◆ writer_mutex

ib_mutex_t log_t::writer_mutex
mutable

Mutex which can be used to pause log writer thread.

◆ writer_threads_paused

std::atomic_bool log_t::writer_threads_paused

Used for pausing the log writer threads.

When paused, each user thread should write log as in the former version.

◆ writer_threads_resume_event

os_event_t log_t::writer_threads_resume_event

Event used for pausing the log writer threads.


The documentation for this struct was generated from the following file: