MySQL 8.4.2
Source Code Documentation
|
Rollback segment. More...
#include <vector>
#include "fut0lst.h"
#include "trx0sys.h"
#include "trx0types.h"
#include "univ.i"
#include "trx0rseg.ic"
Go to the source code of this file.
Macros | |
#define | TRX_RSEG_N_SLOTS (UNIV_PAGE_SIZE / 16) |
Number of undo log slots in a rollback segment file copy. More... | |
#define | TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2) |
Maximum number of transactions supported by a single rollback segment. More... | |
#define | TRX_RSEG_SLOT_END (TRX_RSEG_UNDO_SLOTS + TRX_RSEG_SLOT_SIZE * TRX_RSEG_N_SLOTS) |
End of undo slots in rollback segment page. More... | |
#define | TRX_RSEG_MAX_TRX_NO TRX_RSEG_SLOT_END |
Functions | |
static trx_rsegf_t * | trx_rsegf_get (space_id_t space, page_no_t page_no, const page_size_t &page_size, mtr_t *mtr) |
Gets a rollback segment header. More... | |
static trx_rsegf_t * | trx_rsegf_get_new (space_id_t space, page_no_t page_no, const page_size_t &page_size, mtr_t *mtr) |
Gets a newly created rollback segment header. More... | |
static page_no_t | trx_rsegf_get_nth_undo (trx_rsegf_t *rsegf, ulint n, mtr_t *mtr) |
Gets the file page number of the nth undo log slot. More... | |
static void | trx_rsegf_set_nth_undo (trx_rsegf_t *rsegf, ulint n, page_no_t page_no, mtr_t *mtr) |
Sets the file page number of the nth undo log slot. More... | |
static ulint | trx_rsegf_undo_find_free (trx_rsegf_t *rsegf, mtr_t *mtr) |
Looks for a free slot for an undo log segment. More... | |
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... | |
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_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... | |
void | trx_rsegs_parallel_init (purge_pq_t *purge_queue) |
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... | |
page_no_t | trx_rseg_create (space_id_t space_id, ulint rseg_id) |
Create a rollback segment in the given tablespace. 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 other than the system tablespace. 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... | |
static void | trx_rsegsf_set_page_no (trx_rsegsf_t *rsegs_header, ulint slot, page_no_t page_no, mtr_t *mtr) |
Sets the page number of the nth rollback segment slot in the independent undo tablespace. More... | |
Variables | |
constexpr uint32_t | TRX_RSEG_SLOT_PAGE_NO = 0 |
Page number of the header page of an undo log segment. More... | |
constexpr uint32_t | TRX_RSEG_SLOT_SIZE = 4 |
Slot size. More... | |
constexpr uint32_t | TRX_RSEG = FSEG_PAGE_DATA |
The offset of the rollback segment header on its page. More... | |
constexpr uint32_t | TRX_RSEG_MAX_SIZE = 0 |
Maximum allowed size for rollback segment in pages. More... | |
constexpr uint32_t | TRX_RSEG_HISTORY_SIZE = 4 |
Number of file pages occupied by the logs in the history list. More... | |
constexpr uint32_t | TRX_RSEG_HISTORY = 8 |
constexpr uint32_t | TRX_RSEG_FSEG_HEADER = 8 + FLST_BASE_NODE_SIZE |
constexpr uint32_t | TRX_RSEG_UNDO_SLOTS |
Undo log segment slots. More... | |
constexpr uint32_t | RSEG_ARRAY_HEADER = FSEG_PAGE_DATA |
The offset of the Rollback Segment Directory header on an RSEG_ARRAY page. More... | |
constexpr uint32_t | RSEG_ARRAY_VERSION = 0x52534547 + 1 |
Rollback Segment Array Header. More... | |
constexpr uint32_t | RSEG_ARRAY_VERSION_OFFSET = 0 |
The RSEG ARRAY version offset in the header. More... | |
constexpr uint32_t | RSEG_ARRAY_SIZE_OFFSET = 4 |
The current number of rollback segments being tracked in this array. More... | |
constexpr uint32_t | RSEG_ARRAY_FSEG_HEADER_OFFSET = 8 |
This is the pointer to the file segment inode that tracks this rseg array page. More... | |
constexpr uint32_t | RSEG_ARRAY_PAGES_OFFSET = 8 + FSEG_HEADER_SIZE |
The start of the array of rollback segment header page numbers for this undo tablespace. More... | |
constexpr uint32_t | RSEG_ARRAY_RESERVED_BYTES = 200 |
Reserved space at the end of an RSEG_ARRAY page reserved for future use. More... | |
constexpr uint32_t | RSEG_ARRAY_SLOT_SIZE = 4 |
Rollback segment.
Created 3/26/1996 Heikki Tuuri
#define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2) |
Maximum number of transactions supported by a single rollback segment.
#define TRX_RSEG_MAX_TRX_NO TRX_RSEG_SLOT_END |
#define TRX_RSEG_N_SLOTS (UNIV_PAGE_SIZE / 16) |
Number of undo log slots in a rollback segment file copy.
#define TRX_RSEG_SLOT_END (TRX_RSEG_UNDO_SLOTS + TRX_RSEG_SLOT_SIZE * TRX_RSEG_N_SLOTS) |
End of undo slots in rollback segment page.
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_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.
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_upgrade_undo_tablespaces | ( | ) |
Upgrade the TRX_SYS page so that it no longer tracks rsegs in undo tablespaces other than the system tablespace.
Add these tablespaces to undo::spaces and put FIL_NULL in the slots in TRX_SYS.
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.
|
inlinestatic |
Gets a rollback segment header.
[in] | space | Space where placed |
[in] | page_no | Page number of the header |
[in] | page_size | Page size |
[in,out] | mtr | Mini-transaction |
|
inlinestatic |
Gets a newly created rollback segment header.
[in] | space | Space where placed |
[in] | page_no | Page number of the header |
[in] | page_size | Page size |
[in,out] | mtr | Mini-transaction |
|
inlinestatic |
Gets the file page number of the nth undo log slot.
[in] | rsegf | rollback segment header |
[in] | n | index of slot |
[in] | mtr | mtr |
|
inlinestatic |
Sets the file page number of the nth undo log slot.
[in] | rsegf | rollback segment header |
[in] | n | index of slot |
[in] | page_no | page number of the undo log segment |
[in] | mtr | mtr |
|
inlinestatic |
Looks for a free slot for an undo log segment.
[in] | rsegf | rollback segment header |
[in] | mtr | mtr |
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_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 |
|
inlinestatic |
Sets the page number of the nth rollback segment slot in the independent undo tablespace.
[in] | rsegs_header | rollback segment array page header |
[in] | slot | slot number on page == rseg id |
[in] | page_no | rollback regment header page number |
[in] | mtr | mtr |
|
constexpr |
This is the pointer to the file segment inode that tracks this rseg array page.
|
constexpr |
The offset of the Rollback Segment Directory header on an RSEG_ARRAY page.
|
constexpr |
The start of the array of rollback segment header page numbers for this undo tablespace.
The potential size of this array is limited only by the page size minus overhead. The actual size of the array is limited by srv_rollback_segments.
|
constexpr |
Reserved space at the end of an RSEG_ARRAY page reserved for future use.
|
constexpr |
The current number of rollback segments being tracked in this array.
|
constexpr |
|
constexpr |
Rollback Segment Array Header.
The RSEG ARRAY base version is a number derived from the string 'RSEG' [0x 52 53 45 47] for extra validation. Each new version increments the base version by 1.
|
constexpr |
The RSEG ARRAY version offset in the header.
|
constexpr |
The offset of the rollback segment header on its page.
|
constexpr |
|
constexpr |
|
constexpr |
Number of file pages occupied by the logs in the history list.
|
constexpr |
Maximum allowed size for rollback segment in pages.
|
constexpr |
Page number of the header page of an undo log segment.
|
constexpr |
Slot size.
|
constexpr |
Undo log segment slots.