MySQL 26.7.0
Source Code Documentation
log0chkp.h File Reference
#include "fil0pages_persistence_interface.h"
#include "log0log.h"
#include "log0sys.h"
#include "log0types.h"
#include "srv0srv.h"
#include "sync0debug.h"
#include "sync0types.h"
#include "ut0new.h"

Go to the source code of this file.

Classes

class  Log_checkpointing
 

Macros

Log - checkpointer mutex
#define log_checkpointer_mutex_enter()    mutex_enter(&(log_checkpointing->checkpoint_mutex))
 
#define log_checkpointer_mutex_exit()    mutex_exit(&(log_checkpointing->checkpoint_mutex))
 
#define log_checkpointer_mutex_own()
 
Log - limits mutex
#define log_limits_mutex_enter()   mutex_enter(&(log_checkpointing->limits_mutex))
 
#define log_limits_mutex_exit()   mutex_exit(&(log_checkpointing->limits_mutex))
 
#define log_limits_mutex_own()   mutex_own(&(log_checkpointing->limits_mutex))
 

Functions

lsn_t log_get_checkpoint_age ()
 Calculates age of current checkpoint as number of bytes since last checkpoint. More...
 
void log_update_exported_lsns ()
 Updates: More...
 
Log - checkpointer thread

Redo log functions related to checkpointing and log free check.

bool log_checkpointer_is_active ()
 Checks if log checkpointer thread is active. More...
 
Log - basic information about checkpoints.
Log_checkpoint_header_no log_next_checkpoint_header (Log_checkpoint_header_no checkpoint_header_no)
 Provides opposite checkpoint header number to the given checkpoint header number. More...
 
Log - other functions related to checkpoints.
dberr_t log_files_write_checkpoint_low (log_t &log, Log_file_handle &checkpoint_file_handle, Log_checkpoint_header_no checkpoint_header_no, lsn_t next_checkpoint_lsn)
 Writes checkpoint to the file containing the written checkpoint_lsn. More...
 
dberr_t log_files_write_first_data_block_low (log_t &log, Log_file_handle &file_handle, lsn_t checkpoint_lsn, lsn_t file_start_lsn)
 Writes the first data block to the log file using the provided handle to the opened log file. More...
 
dberr_t log_files_next_checkpoint (log_t &log, lsn_t lsn)
 Writes the next checkpoint to the log file, by writing a single checkpoint header with the checkpoint lsn. More...
 

Variables

Log_checkpointinglog_checkpointing
 Redo log checkpointing. More...
 

Macro Definition Documentation

◆ log_checkpointer_mutex_enter

#define log_checkpointer_mutex_enter ( )     mutex_enter(&(log_checkpointing->checkpoint_mutex))

◆ log_checkpointer_mutex_exit

#define log_checkpointer_mutex_exit ( )     mutex_exit(&(log_checkpointing->checkpoint_mutex))

◆ log_checkpointer_mutex_own

#define log_checkpointer_mutex_own ( )
Value:
ib_mutex_t checkpoint_mutex
Mutex which can be used to pause log checkpointer thread.
Definition: log0chkp.h:388
Log_checkpointing * log_checkpointing
Redo log checkpointing.
Definition: log0chkp.cc:113
bool log_checkpointer_is_active()
Checks if log checkpointer thread is active.
Definition: log0chkp.h:68
#define mutex_own(M)
Checks that the current thread owns the mutex.
Definition: ut0mutex.h:166

◆ log_limits_mutex_enter

#define log_limits_mutex_enter ( )    mutex_enter(&(log_checkpointing->limits_mutex))

◆ log_limits_mutex_exit

#define log_limits_mutex_exit ( )    mutex_exit(&(log_checkpointing->limits_mutex))

◆ log_limits_mutex_own

#define log_limits_mutex_own ( )    mutex_own(&(log_checkpointing->limits_mutex))

Function Documentation

◆ log_checkpointer_is_active()

bool log_checkpointer_is_active ( )
inline

Checks if log checkpointer thread is active.

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

◆ log_files_next_checkpoint()

dberr_t log_files_next_checkpoint ( log_t log,
lsn_t  lsn 
)

Writes the next checkpoint to the log file, by writing a single checkpoint header with the checkpoint lsn.

Flushes the file after the write and updates the log.last_checkpoint_lsn.

Remarks
Note that two checkpoint headers are used alternately for consecutive checkpoints. If InnoDB crashed during the write, it would still have the previous checkpoint info and recovery would work.
Parameters
[in,out]logredo log
[in]lsnwrites checkpoint at this lsn
Returns
DB_SUCCESS or error

◆ log_files_write_checkpoint_low()

dberr_t log_files_write_checkpoint_low ( log_t log,
Log_file_handle checkpoint_file_handle,
Log_checkpoint_header_no  checkpoint_header_no,
lsn_t  next_checkpoint_lsn 
)

Writes checkpoint to the file containing the written checkpoint_lsn.

The checkpoint is written to the given checkpoint header. Unless InnoDB is starting: checkpointer, writer and files mutexes must be acquired before calling this function.

Parameters
[in,out]logredo log
[in]checkpoint_file_handlehandle to opened file
[in]checkpoint_header_nocheckpoint header to be written
[in]next_checkpoint_lsnthe checkpoint lsn to write
Returns
DB_SUCCESS or error

◆ log_files_write_first_data_block_low()

dberr_t log_files_write_first_data_block_low ( log_t log,
Log_file_handle file_handle,
lsn_t  checkpoint_lsn,
lsn_t  file_start_lsn 
)

Writes the first data block to the log file using the provided handle to the opened log file.

The block is addressed by the given checkpoint_lsn, filled with 0x00 and its data length points to checkpoint_lsn inside, making the block logically empty.

Remarks
This is used only during creation of new log files.
Parameters
[in,out]logredo log
[in]file_handlehandle to the opened log file
[in]checkpoint_lsnthe checkpoint lsn
[in]file_start_lsnstart_lsn of the file
Returns
DB_SUCCESS or error

◆ log_get_checkpoint_age()

lsn_t log_get_checkpoint_age ( )
inline

Calculates age of current checkpoint as number of bytes since last checkpoint.

This includes bytes for headers and footers of all log blocks. The calculation is based on the latest written checkpoint lsn, and the current lsn, which points to the first non reserved data byte. Note that the current lsn could not fit the free space in the log files. This means that the checkpoint age could potentially be larger than capacity of the log files. However we do the best effort to avoid such situations, and if they happen, user threads wait until the space is reclaimed.

Returns
checkpoint age as number of bytes

◆ log_next_checkpoint_header()

Log_checkpoint_header_no log_next_checkpoint_header ( Log_checkpoint_header_no  checkpoint_header_no)

Provides opposite checkpoint header number to the given checkpoint header number.

Parameters
[in]checkpoint_header_nothe given checkpoint header number
Returns
the opposite checkpoint header number

◆ log_update_exported_lsns()

void log_update_exported_lsns ( )

Updates:

  • Innodb_redo_log_checkpoint_lsn,
  • Innodb_redo_log_current_lsn,
  • Innodb_redo_log_flushed_to_disk_lsn. They should be updated "together", to present a consistent state to the user, that is one in which checkpoint_lsn <= flushed_to_disk_lsn <= current_lsn. Calls are protected by log_checkpointer->limits_mutex, which is to avoid torn writes to these exposed fields, but otherwise does not enforce above inequalities. Instead they follow from loading atomics in the order from the conceptually smallest to the largest - a load synchronizes with the store, which in turn should happen after the conceptually larger atomic already was at least equal to the stored value, so can be only larger now.

Variable Documentation

◆ log_checkpointing

Log_checkpointing* log_checkpointing
extern

Redo log checkpointing.