MySQL 8.4.2
Source Code Documentation
log0write.h File Reference
#include <atomic>
#include "log0sys.h"
#include "log0types.h"
#include "srv0srv.h"

Go to the source code of this file.

Functions

Log - waiting for redo written to disk.
Wait_stats log_write_up_to (log_t &log, lsn_t lsn, bool flush_to_disk)
 Waits until the redo log is written up to a provided lsn. More...
 
uint64_t log_total_flushes ()
 Total number of redo log flushes (fsyncs) that have been started since the redo log system (log_sys) became initialized (. More...
 
uint64_t log_pending_flushes ()
 Number of currently pending redo log flushes (fsyncs in-progress). More...
 
void log_writer_check_if_exited_extra_margin (log_t &log)
 Checks if the redo log writer exited extra margin. More...
 

Log - the log write threads.

#define log_flusher_mutex_enter(log)   mutex_enter(&((log).flusher_mutex))
 
#define log_flusher_mutex_enter_nowait(log)    mutex_enter_nowait(&((log).flusher_mutex))
 
#define log_flusher_mutex_exit(log)   mutex_exit(&((log).flusher_mutex))
 
#define log_flusher_mutex_own(log)    (mutex_own(&((log).flusher_mutex)) || !log_flusher_is_active())
 
#define log_flush_notifier_mutex_enter(log)    mutex_enter(&((log).flush_notifier_mutex))
 
#define log_flush_notifier_mutex_exit(log)    mutex_exit(&((log).flush_notifier_mutex))
 
#define log_flush_notifier_mutex_own(log)    (mutex_own(&((log).flush_notifier_mutex)) || !log_flush_notifier_is_active())
 
#define log_writer_mutex_enter(log)   mutex_enter(&((log).writer_mutex))
 
#define log_writer_mutex_enter_nowait(log)    mutex_enter_nowait(&((log).writer_mutex))
 
#define log_writer_mutex_exit(log)   mutex_exit(&((log).writer_mutex))
 
#define log_writer_mutex_own(log)    (mutex_own(&((log).writer_mutex)) || !log_writer_is_active())
 
#define log_write_notifier_mutex_enter(log)    mutex_enter(&((log).write_notifier_mutex))
 
#define log_write_notifier_mutex_exit(log)    mutex_exit(&((log).write_notifier_mutex))
 
#define log_write_notifier_mutex_own(log)    (mutex_own(&((log).write_notifier_mutex)) || !log_write_notifier_is_active())
 
void log_control_writer_threads (log_t &log)
 Pause / resume the log writer, the log flusher, the log write notifier and the log flush notifier threads based on innodb_log_writer_threads value. More...
 
void log_writer (log_t *log_ptr)
 The log writer thread routine. More...
 
void log_flusher (log_t *log_ptr)
 The log flusher thread routine. More...
 
void log_flush_notifier (log_t *log_ptr)
 The log flush notifier thread routine. More...
 
void log_write_notifier (log_t *log_ptr)
 The log write notifier thread routine. More...
 
void log_writer_thread_active_validate ()
 Validates that the log writer thread is active. More...
 
void log_background_write_threads_active_validate (const log_t &log)
 Validates that the log writer, flusher threads are active. More...
 
bool log_writer_is_active ()
 Checks if log writer thread is active. More...
 
bool log_write_notifier_is_active ()
 Checks if log write notifier thread is active. More...
 
bool log_flusher_is_active ()
 Checks if log flusher thread is active. More...
 
bool log_flush_notifier_is_active ()
 Checks if log flush notifier thread is active. More...
 
bool log_write_to_file_requests_are_frequent (std::chrono::microseconds interval)
 Checks if requests to write redo log buffer to disk are frequent (which means that there is at least one request per 1ms in average). More...
 
bool log_write_to_file_requests_are_frequent (const log_t &log)
 Checks if requests to write redo log buffer to disk are frequent (which means that there is at least one request per 1ms in average). More...
 

Macro Definition Documentation

◆ log_flush_notifier_mutex_enter

#define log_flush_notifier_mutex_enter (   log)     mutex_enter(&((log).flush_notifier_mutex))

◆ log_flush_notifier_mutex_exit

#define log_flush_notifier_mutex_exit (   log)     mutex_exit(&((log).flush_notifier_mutex))

◆ log_flush_notifier_mutex_own

#define log_flush_notifier_mutex_own (   log)     (mutex_own(&((log).flush_notifier_mutex)) || !log_flush_notifier_is_active())

◆ log_flusher_mutex_enter

#define log_flusher_mutex_enter (   log)    mutex_enter(&((log).flusher_mutex))

◆ log_flusher_mutex_enter_nowait

#define log_flusher_mutex_enter_nowait (   log)     mutex_enter_nowait(&((log).flusher_mutex))

◆ log_flusher_mutex_exit

#define log_flusher_mutex_exit (   log)    mutex_exit(&((log).flusher_mutex))

◆ log_flusher_mutex_own

#define log_flusher_mutex_own (   log)     (mutex_own(&((log).flusher_mutex)) || !log_flusher_is_active())

◆ log_write_notifier_mutex_enter

#define log_write_notifier_mutex_enter (   log)     mutex_enter(&((log).write_notifier_mutex))

◆ log_write_notifier_mutex_exit

#define log_write_notifier_mutex_exit (   log)     mutex_exit(&((log).write_notifier_mutex))

◆ log_write_notifier_mutex_own

#define log_write_notifier_mutex_own (   log)     (mutex_own(&((log).write_notifier_mutex)) || !log_write_notifier_is_active())

◆ log_writer_mutex_enter

#define log_writer_mutex_enter (   log)    mutex_enter(&((log).writer_mutex))

◆ log_writer_mutex_enter_nowait

#define log_writer_mutex_enter_nowait (   log)     mutex_enter_nowait(&((log).writer_mutex))

◆ log_writer_mutex_exit

#define log_writer_mutex_exit (   log)    mutex_exit(&((log).writer_mutex))

◆ log_writer_mutex_own

#define log_writer_mutex_own (   log)     (mutex_own(&((log).writer_mutex)) || !log_writer_is_active())

Function Documentation

◆ log_background_write_threads_active_validate()

void log_background_write_threads_active_validate ( const log_t log)

Validates that the log writer, flusher threads are active.

Used only to assert, that the state is correct.

Parameters
[in]logredo log

◆ log_control_writer_threads()

void log_control_writer_threads ( log_t log)

Pause / resume the log writer, the log flusher, the log write notifier and the log flush notifier threads based on innodb_log_writer_threads value.

Note
Calls to this function should be protected externally by some mutex. The caller innodb_log_writer_threads_update() is protected by LOCK_global_system_variables in mysqld.

◆ log_flush_notifier()

void log_flush_notifier ( log_t log_ptr)

The log flush notifier thread routine.

Parameters
[in,out]log_ptrpointer to redo log

◆ log_flush_notifier_is_active()

bool log_flush_notifier_is_active ( )
inline

Checks if log flush notifier thread is active.

Returns
true if and only if the log flush notifier thread is active

◆ log_flusher()

void log_flusher ( log_t log_ptr)

The log flusher thread routine.

Parameters
[in,out]log_ptrpointer to redo log

◆ log_flusher_is_active()

bool log_flusher_is_active ( )
inline

Checks if log flusher thread is active.

Returns
true if and only if the log flusher thread is active

◆ log_pending_flushes()

uint64_t log_pending_flushes ( )

Number of currently pending redo log flushes (fsyncs in-progress).

Returns
number of pending fsyncs or 0 if the redo log system is uninitialized

◆ log_total_flushes()

uint64_t log_total_flushes ( )

Total number of redo log flushes (fsyncs) that have been started since the redo log system (log_sys) became initialized (.

See also
log_sys_init).
Returns
total number of fsyncs or 0 if the redo log system is uninitialized

◆ log_write_notifier()

void log_write_notifier ( log_t log_ptr)

The log write notifier thread routine.

Parameters
[in,out]log_ptrpointer to redo log

◆ log_write_notifier_is_active()

bool log_write_notifier_is_active ( )
inline

Checks if log write notifier thread is active.

Returns
true if and only if the log write notifier thread is active

◆ log_write_to_file_requests_are_frequent() [1/2]

bool log_write_to_file_requests_are_frequent ( const log_t log)
inline

Checks if requests to write redo log buffer to disk are frequent (which means that there is at least one request per 1ms in average).

Parameters
[in]logredo log
Returns
true iff requests are considered frequent

◆ log_write_to_file_requests_are_frequent() [2/2]

bool log_write_to_file_requests_are_frequent ( std::chrono::microseconds  interval)
inline

Checks if requests to write redo log buffer to disk are frequent (which means that there is at least one request per 1ms in average).

Parameters
[in]intervalhow often in average requests happen
Returns
true iff requests are considered frequent

◆ log_write_up_to()

Wait_stats log_write_up_to ( log_t log,
lsn_t  lsn,
bool  flush_to_disk 
)

Waits until the redo log is written up to a provided lsn.

Parameters
[in]logredo log
[in]lsnlsn to wait for
[in]flush_to_disktrue: wait until it is flushed
Returns
statistics about waiting inside

◆ log_writer()

void log_writer ( log_t log_ptr)

The log writer thread routine.

Parameters
[in,out]log_ptrpointer to redo log

◆ log_writer_check_if_exited_extra_margin()

void log_writer_check_if_exited_extra_margin ( log_t log)

Checks if the redo log writer exited extra margin.

To minimize flipping of log.m_writer_inside_extra_margin, the check assumes the very pessimistic scenario in which a next write of the log_writer thread, would be executed up to the current lsn.

Requirement: log.writer_mutex acquired and log.m_writer_inside_extra_margin is true, before calling this function.

Remarks
This method is supposed to be used by the log_checkpointer thread to detect situation in which the redo log writer has actually exited the extra_margin, because of advanced log.last_checkpoint_lsn, but the log_writer thread didn't notice it because it has not been active since then (e.g. because there is nothing more to write, ie. log.write_lsn == current lsn).
Parameters
[in,out]logredo log

◆ log_writer_is_active()

bool log_writer_is_active ( )
inline

Checks if log writer thread is active.

Returns
true if and only if the log writer thread is active

◆ log_writer_thread_active_validate()

void log_writer_thread_active_validate ( )

Validates that the log writer thread is active.

Used only to assert, that the state is correct.