MySQL 8.0.39
Source Code Documentation
|
Rollback segment. More...
#include "trx0rseg.h"
#include <stddef.h>
#include <algorithm>
#include "clone0clone.h"
#include "fsp0sysspace.h"
#include "fut0lst.h"
#include "log0chkp.h"
#include "srv0mon.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "trx0purge.h"
#include "trx0undo.h"
Functions | |
page_no_t | trx_rseg_header_create (space_id_t space_id, const page_size_t &page_size, page_no_t max_size, ulint rseg_slot, mtr_t *mtr) |
Creates a rollback segment header. More... | |
void | trx_rseg_mem_free (trx_rseg_t *rseg) |
Free an instance of the rollback segment in memory. More... | |
static void | trx_rseg_persist_gtid (trx_rseg_t *rseg, trx_id_t gtid_trx_no) |
static trx_rseg_t * | trx_rseg_mem_initialize (ulint id, space_id_t space_id, page_no_t page_no, const page_size_t &page_size) |
static trx_rseg_t * | trx_rseg_physical_initialize (trx_rseg_t *rseg, purge_pq_t *purge_queue, trx_id_t gtid_trx_no, mtr_t *mtr) |
page_no_t | trx_rseg_get_page_no (space_id_t space_id, ulint rseg_id) |
Return a page number from a slot in the rseg_array page of an undo tablespace. More... | |
void | trx_rseg_init_thread (void *arg, trx_id_t gtid_trx_no) |
Thread to initialize rollback segments in parallel. More... | |
trx_rseg_t * | trx_rseg_mem_create (ulint id, space_id_t space_id, page_no_t page_no, const page_size_t &page_size, trx_id_t gtid_trx_no, purge_pq_t *purge_queue, mtr_t *mtr) |
Create and initialize a rollback segment object. More... | |
void | trx_rsegs_init_start (purge_pq_t *purge_queue) |
Read each rollback segment slot in the TRX_SYS page and the RSEG_ARRAY page of each undo tablespace. More... | |
void | trx_rsegs_init_end () |
void | trx_rsegs_parallel_init (purge_pq_t *purge_queue) |
Initialize rollback segments in parallel. More... | |
void | trx_rsegs_init (purge_pq_t *purge_queue) |
Read each rollback segment slot in the TRX_SYS page and the RSEG_ARRAY page of each undo tablespace. More... | |
page_no_t | trx_rseg_create (space_id_t space_id, ulint rseg_id) |
Create a rollback segment in the given tablespace. More... | |
bool | trx_rseg_add_rollback_segments (space_id_t space_id, ulong target_rsegs, Rsegs *rsegs, ulint *const n_total_created) |
This does two things to the target tablespace. More... | |
bool | trx_rseg_adjust_rollback_segments (ulong target_rollback_segments) |
Add more rsegs to the rseg list in each tablespace until there are srv_rollback_segments of them. More... | |
bool | trx_rseg_init_rollback_segments (space_id_t space_id, ulong target_rollback_segments) |
Create the requested number of Rollback Segments in a newly created undo tablespace and add them to the Rsegs object. More... | |
void | trx_rseg_get_n_undo_tablespaces (Space_Ids *spaces_to_open) |
Build a list of unique undo tablespaces found in the TRX_SYS page. More... | |
void | trx_rseg_upgrade_undo_tablespaces () |
Upgrade the TRX_SYS page so that it no longer tracks rsegs in undo tablespaces. More... | |
void | trx_rseg_array_create (space_id_t space_id, mtr_t *mtr) |
Create the file page for the rollback segment directory in an undo tablespace. More... | |
Variables | |
static std::atomic< uint32_t > | active_rseg_init_threads {1} |
Rollback segment.
Created 3/26/1996 Heikki Tuuri
bool trx_rseg_add_rollback_segments | ( | space_id_t | space_id, |
ulong | target_rsegs, | ||
Rsegs * | rsegs, | ||
ulint *const | n_total_created | ||
) |
This does two things to the target tablespace.
[in] | space_id | tablespace ID that should contain rollback segments |
[in] | target_rsegs | target number of rollback segments per tablespace |
[in] | rsegs | list of rsegs to add to |
[in,out] | n_total_created | A running total of rollback segment created in undo tablespaces |
bool trx_rseg_adjust_rollback_segments | ( | ulong | target_rollback_segments | ) |
Add more rsegs to the rseg list in each tablespace until there are srv_rollback_segments of them.
Use any rollback segment that already exists so that the purge_queue can be filled and processed with any existing undo log. If the rollback segments do not exist in this tablespace and we need them according to target_rollback_segments, then build them in the tablespace.
[in] | target_rollback_segments | new number of rollback segments per space |
The number of rollback segments created in the datafile.
void trx_rseg_array_create | ( | space_id_t | space_id, |
mtr_t * | mtr | ||
) |
Create the file page for the rollback segment directory in an undo tablespace.
This function is called just after an undo tablespace is created so the next page created here should by FSP_FSEG_DIR_PAGE_NUM.
[in] | space_id | Undo Tablespace ID |
[in] | mtr | mtr |
page_no_t trx_rseg_create | ( | space_id_t | space_id, |
ulint | rseg_id | ||
) |
Create a rollback segment in the given tablespace.
This could be either the system tablespace, the temporary tablespace, or an undo tablespace.
[in] | space_id | tablespace to get the rollback segment |
[in] | rseg_id | slot number of the rseg within this tablespace |
void trx_rseg_get_n_undo_tablespaces | ( | Space_Ids * | spaces_to_open | ) |
Build a list of unique undo tablespaces found in the TRX_SYS page.
Do not count the system tablespace. The vector will be sorted on space id.
[in,out] | spaces_to_open | list of undo tablespaces found. |
page_no_t trx_rseg_get_page_no | ( | space_id_t | space_id, |
ulint | rseg_id | ||
) |
Return a page number from a slot in the rseg_array page of an undo tablespace.
[in] | space_id | undo tablespace ID |
[in] | rseg_id | rollback segment ID |
page_no_t trx_rseg_header_create | ( | space_id_t | space_id, |
const page_size_t & | page_size, | ||
page_no_t | max_size, | ||
ulint | rseg_slot, | ||
mtr_t * | mtr | ||
) |
Creates a rollback segment header.
This function is called only when a new rollback segment is created in the database.
[in] | space_id | Space id |
[in] | page_size | Page size |
[in] | max_size | Max size in pages |
[in] | rseg_slot | Rseg id == slot number in RSEG_ARRAY |
[in,out] | mtr | Mini-transaction |
bool trx_rseg_init_rollback_segments | ( | space_id_t | space_id, |
ulong | target_rollback_segments | ||
) |
Create the requested number of Rollback Segments in a newly created undo tablespace and add them to the Rsegs object.
[in] | space_id | undo tablespace ID |
[in] | target_rollback_segments | number of rollback segments per space |
The number of rollback segments created in the datafile.
void trx_rseg_init_thread | ( | void * | arg, |
trx_id_t | gtid_trx_no | ||
) |
Thread to initialize rollback segments in parallel.
[in] | arg | purge queue |
[in] | gtid_trx_no | GTID to be set in the rollback segment |
trx_rseg_t * trx_rseg_mem_create | ( | ulint | id, |
space_id_t | space_id, | ||
page_no_t | page_no, | ||
const page_size_t & | page_size, | ||
trx_id_t | gtid_trx_no, | ||
purge_pq_t * | purge_queue, | ||
mtr_t * | mtr | ||
) |
Create and initialize a rollback segment object.
Some of the values for the fields are read from the segment header page. The caller must insert it into the correct list.
[in] | id | Rollback segment id |
[in] | space_id | Space where the segment is placed |
[in] | page_no | Page number of the segment header |
[in] | page_size | Page size |
[in] | gtid_trx_no | Trx number up to which GTID is persisted |
[in,out] | purge_queue | Rseg queue |
[in,out] | mtr | Mini-transaction |
void trx_rseg_mem_free | ( | trx_rseg_t * | rseg | ) |
Free an instance of the rollback segment in memory.
[in] | rseg | pointer to an rseg to free |
|
static |
|
static |
|
static |
void trx_rseg_upgrade_undo_tablespaces | ( | ) |
Upgrade the TRX_SYS page so that it no longer tracks rsegs in undo tablespaces.
Upgrade the TRX_SYS page so that it no longer tracks rsegs in undo tablespaces other than the system tablespace.
It should only track rollback segments in the system tablespace. Put FIL_NULL in the slots in TRX_SYS. Latch protection is not needed since this is during single-threaded startup.
void trx_rsegs_init | ( | purge_pq_t * | purge_queue | ) |
Read each rollback segment slot in the TRX_SYS page and the RSEG_ARRAY page of each undo tablespace.
Create trx_rseg_t objects for all rollback segments found. This runs at database startup and initializes the in-memory lists of trx_rseg_t objects. We need to look at all slots in TRX_SYS and each RSEG_ARRAY page because we need to look for any existing undo log that may need to be recovered by purge. No latch is needed since this is still single-threaded startup. If we find existing rseg slots in TRX_SYS page that reference undo tablespaces and have active undo logs, then quit. They require an upgrade of undo tablespaces and that cannot happen with active undo logs.
[in] | purge_queue | queue of rsegs to purge |
void trx_rsegs_init_end | ( | ) |
void trx_rsegs_init_start | ( | purge_pq_t * | purge_queue | ) |
Read each rollback segment slot in the TRX_SYS page and the RSEG_ARRAY page of each undo tablespace.
Create trx_rseg_t objects for all rollback segments found. This runs at database startup and initializes the in-memory lists of trx_rseg_t objects. We need to look at all slots in TRX_SYS and each RSEG_ARRAY page because we need to look for any existing undo log that may need to be recovered by purge. No latch is needed since this is still single-threaded startup.If we find existing rseg slots in TRX_SYS page that reference undo tablespaces and have active undo logs, then quit. They require an upgrade of undo tablespaces and that cannot happen with active undo logs.
[in] | purge_queue | queue of rsegs to purge |
void trx_rsegs_parallel_init | ( | purge_pq_t * | purge_queue | ) |
Initialize rollback segments in parallel.
[in] | purge_queue | queue of rsegs to purge |
purge_queue | in: rseg queue |
|
static |