MySQL 26.7.0
Source Code Documentation
undo_truncate Namespace Reference

Classes

class  Inject_failure_once
 Inject a failure in the undo truncation debug compiled code at various places so that it fails the first time it hits and succeeds after that. More...
 
class  Space_id_bank
 A bank of UNDO space ids which is a lock free repository for information about the space IDs used for undo tablespaces. More...
 
struct  Tablespace
 An undo_truncate::Tablespace object is used to easily convert between undo_space_id and undo_space_num and to create the automatic file_name and space name. More...
 
class  Tablespaces
 List of undo tablespaces, each containing a list of rollback segments. More...
 
class  Truncate
 Track an UNDO tablespace marked for truncate. More...
 
class  Undo_num2id_map
 Map from undo tablespace number to space id to allow a reserved undo space ID to be found quickly. More...
 

Functions

bool is_active_truncate_log_present (space_id_t space_num)
 Check if TRUNCATE_DDL_LOG file exist. More...
 
void remove_truncate_log_file (space_id_t space_num)
 Remove TRUNCATE_DDL_LOG file if it exists. More...
 
char * make_space_name (space_id_t space_id)
 Build a standard undo tablespace name from a space_id. More...
 
char * make_file_name (space_id_t space_id)
 Build a standard undo tablespace file name from a space_id. More...
 
bool is_reserved (space_id_t space_id)
 Check if the space_id is an undo space ID in the reserved range. More...
 
space_id_t num2id (space_id_t space_num, size_t ndx)
 Convert an undo space number (from 1 to 127) into the undo space_id, given an index indicating which space_id from the pool assigned to that undo number. More...
 
space_id_t num2id (space_id_t space_num)
 Convert an undo space number (from 1 to 127) into an undo space_id. More...
 
space_id_t id2num (space_id_t space_id)
 Get the corresponding UNDO space number for a given UNDO space id. More...
 
space_id_t id2next_id (space_id_t space_id)
 
void set_active (space_id_t space_id)
 Set an undo tablespace active. More...
 
void use_space_id (space_id_t space_id)
 Note that the undo space number for a space ID is being used. More...
 
space_id_t use_next_space_id (space_id_t space_num)
 Mark that the given undo space number is being used and return the next available space_id for that space number. More...
 
space_id_t next_space_id (space_id_t space_id)
 Given a valid undo space_id, return the next space_id for that space number. More...
 
space_id_t next_space_id (space_id_t space_id, space_id_t space_num)
 Given a valid undo space_id or SPACE_UNKNOWN, return the next space_id for the given space number. More...
 
void unuse_space_id (space_id_t space_id)
 Mark an undo number associated with a given space_id as unused and available to be reused. More...
 
space_id_t get_next_available_space_id ()
 Return the next available undo space ID to be used for a new explicit undo tablespaces. More...
 
void mark_undo_tablespace_unusable (space_id_t space_id, mtr_t *mtr)
 Set the FSP_FLAGS_MASK_UNDO_UNUSABLE flag in the undo tablespace header to indicate that the undo file is not usable. More...
 
void mark_undo_tablespace_usable (space_id_t space_id, mtr_t *mtr)
 Unset the FSP_FLAGS_MASK_UNDO_UNUSABLE in the undo tablespace header to indicate that the undo file is now usable. More...
 
void inject_crash (const char *injection_point_name)
 Inject a crash if a certain SET GLOBAL DEBUG has been set. More...
 

Variables

static constexpr char s_log_prefix [] = "undo_"
 Truncate Log file Prefix. More...
 
static constexpr char s_log_ext [] = "trunc.log"
 Truncate Log file Extension. More...
 
ib_mutex_t ddl_mutex
 Mutex for serializing undo tablespace related DDL. More...
 
ut::unique_ptr< Undo_num2id_mapnum2id_map
 
Tablespacesspaces
 A global object that contains a vector of undo_truncate::Tablespace structs. More...
 
constexpr ulint TRUNCATE_FREQUENCY = 128
 
static Space_id_bank space_id_bank
 

Function Documentation

◆ get_next_available_space_id()

space_id_t undo_truncate::get_next_available_space_id ( )

Return the next available undo space ID to be used for a new explicit undo tablespaces.

The slot will be marked as in-use.

Returns
next available undo space number if successful.
SPACE_UNKNOWN if failed

◆ id2next_id()

space_id_t undo_truncate::id2next_id ( space_id_t  space_id)

◆ id2num()

space_id_t undo_truncate::id2num ( space_id_t  space_id)

Get the corresponding UNDO space number for a given UNDO space id.

Parameters
[in]space_idundo tablespace ID
Returns
space number of the undo tablespace

◆ inject_crash()

void undo_truncate::inject_crash ( const char *  injection_point_name)

Inject a crash if a certain SET GLOBAL DEBUG has been set.

Before DBUG_SUICIDE(), write an entry about this crash to the error log and flush the redo log.

◆ is_active_truncate_log_present()

bool undo_truncate::is_active_truncate_log_present ( space_id_t  space_num)

Check if TRUNCATE_DDL_LOG file exist.

Parameters
[in]space_numundo tablespace number
Returns
true if exist else false.

◆ is_reserved()

bool undo_truncate::is_reserved ( space_id_t  space_id)
inline

Check if the space_id is an undo space ID in the reserved range.

Parameters
[in]space_idundo tablespace ID
Returns
true if it is in the reserved undo space ID range.

◆ make_file_name()

char * undo_truncate::make_file_name ( space_id_t  space_id)

Build a standard undo tablespace file name from a space_id.

This will create a name like 'undo_001' if the space_id is in the reserved range, else it will be like 'undo001'. This caller is responsible for freeing the returned value using ut::free

Parameters
[in]space_idid of the undo tablespace.
Returns
file_name of the undo tablespace file

◆ make_space_name()

char * undo_truncate::make_space_name ( space_id_t  space_id)

Build a standard undo tablespace name from a space_id.

This caller is responsible for freeing the returned value using ut::free

Parameters
[in]space_idid of the undo tablespace.
Returns
tablespace name of the undo tablespace file

◆ mark_undo_tablespace_unusable()

void undo_truncate::mark_undo_tablespace_unusable ( space_id_t  space_id,
mtr_t mtr 
)

Set the FSP_FLAGS_MASK_UNDO_UNUSABLE flag in the undo tablespace header to indicate that the undo file is not usable.

This is mainly done during the truncate operation of undo tablespace.

Parameters
[in]space_idundo tablespace id
[in]mtrMini-transaction

◆ mark_undo_tablespace_usable()

void undo_truncate::mark_undo_tablespace_usable ( space_id_t  space_id,
mtr_t mtr 
)

Unset the FSP_FLAGS_MASK_UNDO_UNUSABLE in the undo tablespace header to indicate that the undo file is now usable.

Parameters
[in]space_idundo tablespace id
[in]mtrMini-transaction

◆ next_space_id() [1/2]

space_id_t undo_truncate::next_space_id ( space_id_t  space_id)

Given a valid undo space_id, return the next space_id for that space number.

Parameters
[in]space_idundo tablespace ID
Returns
the next tablespace ID to use

◆ next_space_id() [2/2]

space_id_t undo_truncate::next_space_id ( space_id_t  space_id,
space_id_t  space_num 
)

Given a valid undo space_id or SPACE_UNKNOWN, return the next space_id for the given space number.

Parameters
[in]space_idundo tablespace ID
[in]space_numundo tablespace number
Returns
the next tablespace ID to use

◆ num2id() [1/2]

space_id_t undo_truncate::num2id ( space_id_t  space_num)

Convert an undo space number (from 1 to 127) into an undo space_id.

Use the undo_truncate::space_id_bank to return the current space_id assigned to that undo number.

Parameters
[in]space_numundo tablespace number
Returns
space_id of the undo tablespace

◆ num2id() [2/2]

space_id_t undo_truncate::num2id ( space_id_t  space_num,
size_t  ndx 
)

Convert an undo space number (from 1 to 127) into the undo space_id, given an index indicating which space_id from the pool assigned to that undo number.

Parameters
[in]space_numundo tablespace number
[in]ndxindex of the space_id within that undo number
Returns
space_id of the undo tablespace

◆ remove_truncate_log_file()

void undo_truncate::remove_truncate_log_file ( space_id_t  space_num)

Remove TRUNCATE_DDL_LOG file if it exists.

Parameters
[in]space_numundo tablespace number

◆ set_active()

void undo_truncate::set_active ( space_id_t  space_id)

Set an undo tablespace active.

◆ unuse_space_id()

void undo_truncate::unuse_space_id ( space_id_t  space_id)

Mark an undo number associated with a given space_id as unused and available to be reused.

This happens when the fil_space_t is closed associated with a drop undo tablespace.

Parameters
[in]space_idUndo Tablespace ID

◆ use_next_space_id()

space_id_t undo_truncate::use_next_space_id ( space_id_t  space_num)

Mark that the given undo space number is being used and return the next available space_id for that space number.

Parameters
[in]space_numundo tablespace number
Returns
the next tablespace ID to use

◆ use_space_id()

void undo_truncate::use_space_id ( space_id_t  space_id)

Note that the undo space number for a space ID is being used.

Put that space_id into the space_id_bank.

Parameters
[in]space_idundo tablespace number

Variable Documentation

◆ ddl_mutex

ib_mutex_t undo_truncate::ddl_mutex

Mutex for serializing undo tablespace related DDL.

These have to do with creating and dropping undo tablespaces.

◆ num2id_map

ut::unique_ptr< Undo_num2id_map > undo_truncate::num2id_map

◆ s_log_ext

constexpr char undo_truncate::s_log_ext[] = "trunc.log"
staticconstexpr

Truncate Log file Extension.

◆ s_log_prefix

constexpr char undo_truncate::s_log_prefix[] = "undo_"
staticconstexpr

Truncate Log file Prefix.

◆ space_id_bank

Space_id_bank undo_truncate::space_id_bank
static

◆ spaces

Tablespaces * undo_truncate::spaces

A global object that contains a vector of undo_truncate::Tablespace structs.

◆ TRUNCATE_FREQUENCY

constexpr ulint undo_truncate::TRUNCATE_FREQUENCY = 128
constexpr