MySQL 9.1.0
Source Code Documentation
trx0undo.cc File Reference

Transaction undo log. More...

#include <stddef.h>
#include <sql_thd_internal_api.h>
#include "fsp0fsp.h"
#include "ha_prototypes.h"
#include "trx0undo.h"
#include "my_dbug.h"
#include "clone0clone.h"
#include "current_thd.h"
#include "dict0dd.h"
#include "fil0fil.h"
#include "log0chkp.h"
#include "log0write.h"
#include "mach0data.h"
#include "mtr0log.h"
#include "srv0mon.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "trx0purge.h"
#include "trx0rec.h"
#include "trx0rseg.h"
#include "trx0trx.h"

Functions

static void trx_undo_page_init (page_t *undo_page, ulint type, mtr_t *mtr)
 Initializes the fields in an undo log segment page. More...
 
static trx_undo_ttrx_undo_mem_create (trx_rseg_t *rseg, ulint id, ulint type, trx_id_t trx_id, const XID *xid, page_no_t page_no, ulint offset)
 Creates and initializes an undo log memory object. More...
 
static ulint trx_undo_insert_header_reuse (page_t *undo_page, trx_id_t trx_id, mtr_t *mtr)
 Initializes a cached insert undo log header page for new use. More...
 
static trx_undo_rec_ttrx_undo_get_prev_rec_from_prev_page (trx_undo_rec_t *rec, page_no_t page_no, ulint offset, bool shared, mtr_t *mtr)
 Gets the previous record in an undo log from the previous page. More...
 
trx_undo_rec_ttrx_undo_get_prev_rec (trx_undo_rec_t *rec, page_no_t page_no, ulint offset, bool shared, mtr_t *mtr)
 Gets the previous record in an undo log. More...
 
static trx_undo_rec_ttrx_undo_get_next_rec_from_next_page (space_id_t space, const page_size_t &page_size, const page_t *undo_page, page_no_t page_no, ulint offset, ulint mode, mtr_t *mtr)
 Gets the next record in an undo log from the next page. More...
 
trx_undo_rec_ttrx_undo_get_next_rec (trx_undo_rec_t *rec, page_no_t page_no, ulint offset, mtr_t *mtr)
 Gets the next record in an undo log. More...
 
trx_undo_rec_ttrx_undo_get_first_rec (trx_id_t *modifier_trx_id, space_id_t space, const page_size_t &page_size, page_no_t page_no, ulint offset, ulint mode, mtr_t *mtr)
 Gets the first record in an undo log. More...
 
static void trx_undo_page_init_log (page_t *undo_page, ulint type, mtr_t *mtr)
 Writes the mtr log entry of an undo log page initialization. More...
 
bytetrx_undo_parse_page_init (const byte *ptr, const byte *end_ptr, page_t *page, mtr_t *mtr)
 Parses the redo log entry of an undo log page initialization. More...
 
static dberr_t trx_undo_seg_create (trx_rseg_t *rseg, trx_rsegf_t *rseg_hdr, ulint type, ulint *id, page_t **undo_page, mtr_t *mtr)
 Creates a new undo log segment in file. More...
 
static void trx_undo_header_create_log (const page_t *undo_page, trx_id_t trx_id, mtr_t *mtr)
 Writes the mtr log entry of an undo log header initialization. More...
 
static ulint trx_undo_header_create (page_t *undo_page, trx_id_t trx_id, mtr_t *mtr)
 Creates a new undo log header in file. More...
 
static void trx_undo_write_xid (trx_ulogf_t *log_hdr, const XID *xid, mtr_t *mtr)
 Write X/Open XA Transaction Identification (XID) to undo log header. More...
 
dberr_t trx_undo_gtid_add_update_undo (trx_t *trx, bool prepare, bool rollback)
 For saving GTID add update undo slot, if required. More...
 
void trx_undo_gtid_set (trx_t *trx, trx_undo_t *undo, bool is_xa_prepare)
 Set GTID flag in undo if transaction has GTID/. More...
 
void trx_undo_gtid_read_and_persist (trx_ulogf_t *undo_header)
 Read and persist GTID from undo header during recovery. More...
 
void trx_undo_gtid_write (trx_t *trx, trx_ulogf_t *undo_header, trx_undo_t *undo, mtr_t *mtr, bool is_xa_prepare)
 Write GTID information to undo log header. More...
 
static void trx_undo_read_xid (trx_ulogf_t *log_hdr, XID *xid)
 Read X/Open XA Transaction Identification (XID) from undo log header. More...
 
static void trx_undo_header_add_space_for_xid (page_t *undo_page, trx_ulogf_t *log_hdr, mtr_t *mtr, trx_undo_t::Gtid_storage gtid_storage)
 Adds space for the XA XID after an undo log old-style header. More...
 
static void trx_undo_insert_header_reuse_log (const page_t *undo_page, trx_id_t trx_id, mtr_t *mtr)
 Writes the mtr log entry of an undo log header reuse. More...
 
bytetrx_undo_parse_page_header (mlog_id_t type, const byte *ptr, const byte *end_ptr, page_t *page, mtr_t *mtr)
 Parse the redo log entry of an undo log page header create or reuse. More...
 
buf_block_ttrx_undo_add_page (trx_t *trx, trx_undo_t *undo, trx_undo_ptr_t *undo_ptr, mtr_t *mtr)
 Tries to add a page to the undo log segment where the undo log is placed. More...
 
static page_no_t trx_undo_free_page (trx_rseg_t *rseg, bool in_history, space_id_t space, page_no_t hdr_page_no, page_no_t page_no, mtr_t *mtr)
 Frees an undo log page that is not the header page. More...
 
void trx_undo_free_last_page_func (const trx_t *trx, trx_undo_t *undo, mtr_t *mtr)
 Frees the last undo log page. More...
 
static void trx_undo_empty_header_page (space_id_t space_id, const page_size_t &page_size, page_no_t hdr_page_no, ulint hdr_offset, mtr_t *mtr)
 Empties an undo log header page of undo records for that undo log. More...
 
int trx_undo_page_truncate_offset (trx_undo_t *undo, page_t *undo_page, undo_no_t limit)
 Get page offset up to which undo logs can be truncated. More...
 
void trx_undo_truncate_end_func (const trx_t *trx, trx_undo_t *undo, undo_no_t limit)
 Truncates an undo log from the end. More...
 
void trx_undo_truncate_start (trx_rseg_t *rseg, page_no_t hdr_page_no, ulint hdr_offset, undo_no_t limit)
 Truncate the head of an undo log. More...
 
static void trx_undo_seg_free (const trx_undo_t *undo, bool noredo)
 Frees an undo log segment which is not in the history list. More...
 
static trx_undo_ttrx_undo_mem_init (trx_rseg_t *rseg, ulint id, page_no_t page_no, mtr_t *mtr)
 Creates and initializes an undo log memory object for a newly created rseg. More...
 
ulint trx_undo_lists_init (trx_rseg_t *rseg)
 Initializes the undo log lists for a rollback segment memory copy. More...
 
static void trx_undo_mem_init_for_reuse (trx_undo_t *undo, trx_id_t trx_id, const XID *xid, ulint offset)
 Initializes a cached undo log object for new use. More...
 
void trx_undo_mem_free (trx_undo_t *undo)
 Frees an undo log memory copy. More...
 
static dberr_t trx_undo_create (trx_rseg_t *rseg, ulint type, trx_id_t trx_id, const XID *xid, trx_undo_t::Gtid_storage gtid_storage, trx_undo_t **undo, mtr_t *mtr)
 Create a new undo log in the given rollback segment. More...
 
static trx_undo_ttrx_undo_reuse_cached (trx_rseg_t *rseg, ulint type, trx_id_t trx_id, const XID *xid, trx_undo_t::Gtid_storage gtid_storage, mtr_t *mtr)
 Reuses a cached undo log. More...
 
static void trx_undo_mark_as_dict_operation (trx_undo_t *undo, mtr_t *mtr)
 Marks an undo log header as a header of a data dictionary operation transaction. More...
 
dberr_t trx_undo_assign_undo (trx_t *trx, trx_undo_ptr_t *undo_ptr, ulint type)
 Assigns an undo log for a transaction. More...
 
page_ttrx_undo_set_state_at_finish (trx_undo_t *undo, mtr_t *mtr)
 Sets the state of the undo log segment at a transaction finish. More...
 
page_ttrx_undo_set_state_at_prepare (trx_t *trx, trx_undo_t *undo, bool rollback, mtr_t *mtr)
 Set the state of the undo log segment at a XA PREPARE or XA ROLLBACK. More...
 
page_ttrx_undo_set_prepared_in_tc (trx_t *trx, trx_undo_t *undo, mtr_t *mtr)
 Set the state of the undo log segment as prepared in TC. More...
 
void trx_undo_update_cleanup (trx_t *trx, trx_undo_ptr_t *undo_ptr, page_t *undo_page, bool update_rseg_history_len, ulint n_added_logs, mtr_t *mtr)
 Adds the update undo log header as the first in the history list, and frees the memory object, or puts it to the list of cached update undo log segments. More...
 
void trx_undo_insert_cleanup (trx_undo_ptr_t *undo_ptr, bool noredo)
 Frees an insert undo log after a transaction commit or rollback. More...
 
void trx_undo_free_trx_with_prepared_or_active_logs (trx_t *trx, bool prepared)
 At shutdown, frees the undo logs of a transaction which was either PREPARED or (ACTIVE and recovered). More...
 
bool trx_undo_truncate_tablespace (undo::Tablespace *marked_space)
 Truncate UNDO tablespace, reinitialize header and rseg. More...
 

Detailed Description

Transaction undo log.

Created 3/26/1996 Heikki Tuuri

Function Documentation

◆ trx_undo_add_page()

buf_block_t * trx_undo_add_page ( trx_t trx,
trx_undo_t undo,
trx_undo_ptr_t undo_ptr,
mtr_t mtr 
)

Tries to add a page to the undo log segment where the undo log is placed.

Returns
X-latched block if success, else NULL
Parameters
trxin: transaction
undoin: undo log memory object
undo_ptrin: assign undo log from referred rollback segment.
mtrin: mtr which does not have a latch to any undo log page; the caller must have reserved the rollback segment mutex

◆ trx_undo_assign_undo()

dberr_t trx_undo_assign_undo ( trx_t trx,
trx_undo_ptr_t undo_ptr,
ulint  type 
)

Assigns an undo log for a transaction.

A new undo log is created or a cached undo log reused.

Returns
DB_SUCCESS if undo log assign successful, possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE DB_READ_ONLY DB_OUT_OF_MEMORY
Parameters
trxin: transaction
undo_ptrin: assign undo log from referred rollback segment.
typein: TRX_UNDO_INSERT or TRX_UNDO_UPDATE

◆ trx_undo_create()

static dberr_t trx_undo_create ( trx_rseg_t rseg,
ulint  type,
trx_id_t  trx_id,
const XID xid,
trx_undo_t::Gtid_storage  gtid_storage,
trx_undo_t **  undo,
mtr_t mtr 
)
static

Create a new undo log in the given rollback segment.

Parameters
[in]rsegrollback segment memory copy
[in]typetype of the log: TRX_UNDO_INSERT or TRX_UNDO_UPDATE
[in]trx_idid of the trx for which the undo log is created
[in]xidX/Open transaction identification
[in]gtid_storageGTID storage type
[out]undothe new undo log object, undefined if did not succeed
[in]mtrmini-transation
Return values
DB_SUCCESSif successful in creating the new undo lob object,
DB_TOO_MANY_CONCURRENT_TRXStoo many concurrent trxs
DB_OUT_OF_FILE_SPACEout of file-space
DB_OUT_OF_MEMORYout of memory

◆ trx_undo_empty_header_page()

static void trx_undo_empty_header_page ( space_id_t  space_id,
const page_size_t page_size,
page_no_t  hdr_page_no,
ulint  hdr_offset,
mtr_t mtr 
)
static

Empties an undo log header page of undo records for that undo log.

Other undo logs may still have records on that page, if it is an update undo log.

Parameters
[in]space_idTablespace ID
[in]page_sizePage size
[in]hdr_page_noHeader page number
[in]hdr_offsetHeader offset
[in,out]mtrMini-transaction

◆ trx_undo_free_last_page_func()

void trx_undo_free_last_page_func ( const trx_t trx,
trx_undo_t undo,
mtr_t mtr 
)

Frees the last undo log page.

The caller must hold the rollback segment mutex.

Parameters
[in]trxtransaction
[in,out]undoundo log memory copy
[in,out]mtrmini-transaction which does not have a latch to any undo log page or which has allocated the undo log page

◆ trx_undo_free_page()

static page_no_t trx_undo_free_page ( trx_rseg_t rseg,
bool  in_history,
space_id_t  space,
page_no_t  hdr_page_no,
page_no_t  page_no,
mtr_t mtr 
)
static

Frees an undo log page that is not the header page.

Returns
last page number in remaining log
Parameters
rsegin: rollback segment
in_historyin: true if the undo log is in the history list
spacein: space
hdr_page_noin: header page number
page_noin: page number to free: must not be the header page
mtrin: mtr which does not have a latch to any undo log page; the caller must have reserved the rollback segment mutex

◆ trx_undo_free_trx_with_prepared_or_active_logs()

void trx_undo_free_trx_with_prepared_or_active_logs ( trx_t trx,
bool  prepared 
)

At shutdown, frees the undo logs of a transaction which was either PREPARED or (ACTIVE and recovered).

Parameters
[in]trxtransaction which undo logs are freed
[in]preparedwhether or not the undo segment is in prepared or prepared in tc states

◆ trx_undo_get_first_rec()

trx_undo_rec_t * trx_undo_get_first_rec ( trx_id_t modifier_trx_id,
space_id_t  space,
const page_size_t page_size,
page_no_t  page_no,
ulint  offset,
ulint  mode,
mtr_t mtr 
)

Gets the first record in an undo log.

Parameters
[out]modifier_trx_idThe modifier trx identifier.
[in]spaceUndo log header space
[in]page_sizePage size
[in]page_noUndo log header page number
[in]offsetUndo log header offset on page
[in]modeLatching mode: RW_S_LATCH or RW_X_LATCH
[in,out]mtrMini-transaction
Returns
undo log record, the page latched, NULL if none

◆ trx_undo_get_next_rec()

trx_undo_rec_t * trx_undo_get_next_rec ( trx_undo_rec_t rec,
page_no_t  page_no,
ulint  offset,
mtr_t mtr 
)

Gets the next record in an undo log.

Returns
undo log record, the page s-latched, NULL if none
Parameters
recin: undo record
page_noin: undo log header page number
offsetin: undo log header offset on page
mtrin: mtr

◆ trx_undo_get_next_rec_from_next_page()

static trx_undo_rec_t * trx_undo_get_next_rec_from_next_page ( space_id_t  space,
const page_size_t page_size,
const page_t undo_page,
page_no_t  page_no,
ulint  offset,
ulint  mode,
mtr_t mtr 
)
static

Gets the next record in an undo log from the next page.

Parameters
[in]spaceUndo log header space
[in]page_sizePage size
[in]undo_pageUndo log page
[in]page_noUndo log header page number
[in]offsetUndo log header offset on page
[in]modeLatch mode: RW_S_LATCH or RW_X_LATCH
[in,out]mtrMini-transaction
Returns
undo log record, the page latched, NULL if none

◆ trx_undo_get_prev_rec()

trx_undo_rec_t * trx_undo_get_prev_rec ( trx_undo_rec_t rec,
page_no_t  page_no,
ulint  offset,
bool  shared,
mtr_t mtr 
)

Gets the previous record in an undo log.

Returns
undo log record, the page s-latched, NULL if none
Parameters
recin: undo record
page_noin: undo log header page number
offsetin: undo log header offset on page
sharedin: true=S-latch, false=X-latch
mtrin: mtr

◆ trx_undo_get_prev_rec_from_prev_page()

static trx_undo_rec_t * trx_undo_get_prev_rec_from_prev_page ( trx_undo_rec_t rec,
page_no_t  page_no,
ulint  offset,
bool  shared,
mtr_t mtr 
)
static

Gets the previous record in an undo log from the previous page.

Returns
undo log record, the page s-latched, NULL if none
Parameters
recin: undo record
page_noin: undo log header page number
offsetin: undo log header offset on page
sharedin: true=S-latch, false=X-latch
mtrin: mtr

◆ trx_undo_gtid_add_update_undo()

dberr_t trx_undo_gtid_add_update_undo ( trx_t trx,
bool  prepare,
bool  rollback 
)

For saving GTID add update undo slot, if required.

Parameters
[in]trxtransaction
[in]prepareoperation is prepare
[in]rollbackoperation is rollback
Returns
innodb error code.

◆ trx_undo_gtid_read_and_persist()

void trx_undo_gtid_read_and_persist ( trx_ulogf_t undo_log)

Read and persist GTID from undo header during recovery.

Parameters
[in]undo_logundo log header

◆ trx_undo_gtid_set()

void trx_undo_gtid_set ( trx_t trx,
trx_undo_t undo,
bool  is_xa_prepare 
)

Set GTID flag in undo if transaction has GTID/.

Parameters
[in,out]trxtransaction
[in,out]undoundo log memory object
[in]is_xa_prepareGTID is for XA prepared transaction.

◆ trx_undo_gtid_write()

void trx_undo_gtid_write ( trx_t trx,
trx_ulogf_t undo_header,
trx_undo_t undo,
mtr_t mtr,
bool  is_xa_prepare 
)

Write GTID information to undo log header.

Parameters
[in,out]trxtransaction
[in,out]undo_headerundo log header
[in,out]undoundo log memory object
[in,out]mtrminit transaction for write
[in]is_xa_prepareGTID is for XA prepared transaction.

◆ trx_undo_header_add_space_for_xid()

static void trx_undo_header_add_space_for_xid ( page_t undo_page,
trx_ulogf_t log_hdr,
mtr_t mtr,
trx_undo_t::Gtid_storage  gtid_storage 
)
static

Adds space for the XA XID after an undo log old-style header.

Parameters
[in,out]undo_pageUndo log segment header page
[in,out]log_hdrUndo log header
[in,out]mtrMini-transaction
[in]gtid_storageGTID storage type

◆ trx_undo_header_create()

static ulint trx_undo_header_create ( page_t undo_page,
trx_id_t  trx_id,
mtr_t mtr 
)
static

Creates a new undo log header in file.

NOTE that this function has its own log record type MLOG_UNDO_HDR_CREATE. You must NOT change the operation of this function!

Returns
header byte offset on page
Parameters
undo_pagein/out: undo log segment header page, x-latched; it is assumed that there is TRX_UNDO_LOG_HDR_SIZE bytes free space on it
trx_idin: transaction id
mtrin: mtr

◆ trx_undo_header_create_log()

static void trx_undo_header_create_log ( const page_t undo_page,
trx_id_t  trx_id,
mtr_t mtr 
)
inlinestatic

Writes the mtr log entry of an undo log header initialization.

Parameters
undo_pagein: undo log header page
trx_idin: transaction id
mtrin: mtr

◆ trx_undo_insert_cleanup()

void trx_undo_insert_cleanup ( trx_undo_ptr_t undo_ptr,
bool  noredo 
)

Frees an insert undo log after a transaction commit or rollback.

Knowledge of inserts is not needed after a commit or rollback, therefore the data can be discarded.

Parameters
[in,out]undo_ptrundo log to clean up
[in]noredowhether the undo tablespace is redo logged

◆ trx_undo_insert_header_reuse()

static ulint trx_undo_insert_header_reuse ( page_t undo_page,
trx_id_t  trx_id,
mtr_t mtr 
)
static

Initializes a cached insert undo log header page for new use.

NOTE that this function has its own log record type MLOG_UNDO_HDR_REUSE. You must NOT change the operation of this function!

Returns
undo log header byte offset on page in: mtr

NOTE that this function has its own log record type MLOG_UNDO_HDR_REUSE. You must NOT change the operation of this function!

Returns
undo log header byte offset on page
Parameters
undo_pagein/out: insert undo log segment header page, x-latched
trx_idin: transaction id
mtrin: mtr

◆ trx_undo_insert_header_reuse_log()

static void trx_undo_insert_header_reuse_log ( const page_t undo_page,
trx_id_t  trx_id,
mtr_t mtr 
)
inlinestatic

Writes the mtr log entry of an undo log header reuse.

Parameters
undo_pagein: undo log header page
trx_idin: transaction id
mtrin: mtr

◆ trx_undo_lists_init()

ulint trx_undo_lists_init ( trx_rseg_t rseg)

Initializes the undo log lists for a rollback segment memory copy.

This function is only called when the database is started or a new rollback segment is created.

Returns
the combined size of undo log segments in pages
Parameters
rsegin: rollback segment memory object

◆ trx_undo_mark_as_dict_operation()

static void trx_undo_mark_as_dict_operation ( trx_undo_t undo,
mtr_t mtr 
)
static

Marks an undo log header as a header of a data dictionary operation transaction.

Parameters
undoin: assigned undo log
mtrin: mtr

◆ trx_undo_mem_create()

static trx_undo_t * trx_undo_mem_create ( trx_rseg_t rseg,
ulint  id,
ulint  type,
trx_id_t  trx_id,
const XID xid,
page_no_t  page_no,
ulint  offset 
)
static

Creates and initializes an undo log memory object.

Parameters
[in]rsegrollback segment memory object
[in]idslot index within rseg
[in]typetype of the log: TRX_UNDO_INSERT or TRX_UNDO_UPDATE
[in]trx_idid of the trx for which the undo log is created
[in]xidX/Open XA transaction identification
[in]page_noundo log header page number
[in]offsetundo log header byte offset on page
Returns
own: the undo log memory object

◆ trx_undo_mem_free()

void trx_undo_mem_free ( trx_undo_t undo)

Frees an undo log memory copy.

Parameters
undoin: the undo object to be freed

◆ trx_undo_mem_init()

static trx_undo_t * trx_undo_mem_init ( trx_rseg_t rseg,
ulint  id,
page_no_t  page_no,
mtr_t mtr 
)
static

Creates and initializes an undo log memory object for a newly created rseg.

The memory object is inserted in the appropriate list in the rseg.

Returns
own: the undo log memory object
Parameters
rsegin: rollback segment memory object
idin: slot index within rseg
page_noin: undo log segment page number
mtrin: mtr

◆ trx_undo_mem_init_for_reuse()

static void trx_undo_mem_init_for_reuse ( trx_undo_t undo,
trx_id_t  trx_id,
const XID xid,
ulint  offset 
)
static

Initializes a cached undo log object for new use.

Parameters
undoin: undo log to init
trx_idin: id of the trx for which the undo log is created
xidin: X/Open XA transaction identification
offsetin: undo log header byte offset on page

◆ trx_undo_page_init()

static void trx_undo_page_init ( page_t undo_page,
ulint  type,
mtr_t mtr 
)
static

Initializes the fields in an undo log segment page.

in: mtr

Parameters
undo_pagein: undo log segment page
typein: undo log segment type
mtrin: mtr

◆ trx_undo_page_init_log()

static void trx_undo_page_init_log ( page_t undo_page,
ulint  type,
mtr_t mtr 
)
inlinestatic

Writes the mtr log entry of an undo log page initialization.

Parameters
undo_pagein: undo log page
typein: undo log type
mtrin: mtr

◆ trx_undo_page_truncate_offset()

int trx_undo_page_truncate_offset ( trx_undo_t undo,
page_t undo_page,
undo_no_t  limit 
)

Get page offset up to which undo logs can be truncated.

There are three possibilities.

  1. Truncate nothing on this page. Return -1
  2. Truncate part of the page. Return the offset
  3. Truncate the whole page. Return 0
    Parameters
    [in]undoundo log to truncate
    [in]undo_pageundo log page to check
    [in]limitlimit up to which undo logs to be truncated
    Returns
    page offset to truncate to, 0 for whole page, -1 for nothing.

◆ trx_undo_parse_page_header()

byte * trx_undo_parse_page_header ( mlog_id_t  type,
const byte ptr,
const byte end_ptr,
page_t page,
mtr_t mtr 
)

Parse the redo log entry of an undo log page header create or reuse.

Parameters
[in]typeMLOG_UNDO_HDR_CREATE or MLOG_UNDO_HDR_REUSE
[in]ptrRedo log record
[in]end_ptrEnd of log buffer
[in,out]pagePage frame or NULL
[in,out]mtrMini-transaction or NULL
Returns
end of log record or NULL

◆ trx_undo_parse_page_init()

byte * trx_undo_parse_page_init ( const byte ptr,
const byte end_ptr,
page_t page,
mtr_t mtr 
)

Parses the redo log entry of an undo log page initialization.

Returns
end of log record or NULL
Parameters
ptrin: buffer
end_ptrin: buffer end
pagein: page or NULL
mtrin: mtr or NULL

◆ trx_undo_read_xid()

static void trx_undo_read_xid ( trx_ulogf_t log_hdr,
XID xid 
)
static

Read X/Open XA Transaction Identification (XID) from undo log header.

Parameters
log_hdrin: undo log header
xidout: X/Open XA Transaction Identification

◆ trx_undo_reuse_cached()

static trx_undo_t * trx_undo_reuse_cached ( trx_rseg_t rseg,
ulint  type,
trx_id_t  trx_id,
const XID xid,
trx_undo_t::Gtid_storage  gtid_storage,
mtr_t mtr 
)
static

Reuses a cached undo log.

Parameters
[in,out]rsegRollback segment memory object
[in]typeType of the log: TRX_UNDO_INSERT or TRX_UNDO_UPDATE
[in]trx_idId of the trx for which the undo log is used
[in]xidX/Open XA transaction identification
[in]gtid_storageGTID storage type
[in,out]mtrMini-transaction
Returns
the undo log memory object, NULL if none cached

◆ trx_undo_seg_create()

static dberr_t trx_undo_seg_create ( trx_rseg_t rseg,
trx_rsegf_t rseg_hdr,
ulint  type,
ulint id,
page_t **  undo_page,
mtr_t mtr 
)
static

Creates a new undo log segment in file.

Returns
DB_SUCCESS if page creation OK possible error codes are: DB_TOO_MANY_CONCURRENT_TRXS DB_OUT_OF_FILE_SPACE
Parameters
rsegin: rollback segment
rseg_hdrin: rollback segment header, page x-latched
typein: type of the segment: TRX_UNDO_INSERT or TRX_UNDO_UPDATE
idout: slot index within rseg header
undo_pageout: segment header page x-latched, NULL if there was an error
mtrin: mtr

◆ trx_undo_seg_free()

static void trx_undo_seg_free ( const trx_undo_t undo,
bool  noredo 
)
static

Frees an undo log segment which is not in the history list.

Parameters
[in]undoundo log
[in]noredowhether the undo tablespace is redo logged

◆ trx_undo_set_prepared_in_tc()

page_t * trx_undo_set_prepared_in_tc ( trx_t trx,
trx_undo_t undo,
mtr_t mtr 
)

Set the state of the undo log segment as prepared in TC.

Parameters
[in,out]trxTransaction
[in,out]undoInsert_undo or update_undo log
[in,out]mtrMini-transaction
Returns
undo log segment header page, x-latched

◆ trx_undo_set_state_at_finish()

page_t * trx_undo_set_state_at_finish ( trx_undo_t undo,
mtr_t mtr 
)

Sets the state of the undo log segment at a transaction finish.

Returns
undo log segment header page, x-latched
Parameters
undoin: undo log memory copy
mtrin: mtr

◆ trx_undo_set_state_at_prepare()

page_t * trx_undo_set_state_at_prepare ( trx_t trx,
trx_undo_t undo,
bool  rollback,
mtr_t mtr 
)

Set the state of the undo log segment at a XA PREPARE or XA ROLLBACK.

Parameters
[in,out]trxTransaction
[in,out]undoInsert_undo or update_undo log
[in]rollbackfalse=XA PREPARE, true=XA ROLLBACK
[in,out]mtrMini-transaction
Returns
undo log segment header page, x-latched

◆ trx_undo_truncate_end_func()

void trx_undo_truncate_end_func ( const trx_t trx,
trx_undo_t undo,
undo_no_t  limit 
)

Truncates an undo log from the end.

This function is used during a rollback to free space from an undo log.

Parameters
[in]trxtransaction for this undo log
[in]undoundo log
[in]limitall undo records with undo number; This value should be truncated.

◆ trx_undo_truncate_start()

void trx_undo_truncate_start ( trx_rseg_t rseg,
page_no_t  hdr_page_no,
ulint  hdr_offset,
undo_no_t  limit 
)

Truncate the head of an undo log.

NOTE that only whole pages are freed; the header page is not freed, but emptied, if all the records there are below the limit.

Parameters
[in,out]rsegrollback segment
[in]hdr_page_noheader page number
[in]hdr_offsetheader offset on the page
[in]limitfirst undo number to preserve (everything below the limit will be truncated)

◆ trx_undo_truncate_tablespace()

bool trx_undo_truncate_tablespace ( undo::Tablespace marked_space)

Truncate UNDO tablespace, reinitialize header and rseg.

Parameters
[in]marked_spaceUNDO tablespace to truncate
Returns
true if success else false.

◆ trx_undo_update_cleanup()

void trx_undo_update_cleanup ( trx_t trx,
trx_undo_ptr_t undo_ptr,
page_t undo_page,
bool  update_rseg_history_len,
ulint  n_added_logs,
mtr_t mtr 
)

Adds the update undo log header as the first in the history list, and frees the memory object, or puts it to the list of cached update undo log segments.

Parameters
[in]trxTrx owning the update undo log
[in]undo_ptrUpdate undo log.
[in]undo_pageUpdate undo log header page, x-latched
[in]update_rseg_history_lenIf true: update rseg history len else skip updating it.
[in]n_added_logsNumber of logs added
[in]mtrMini-transaction

◆ trx_undo_write_xid()

static void trx_undo_write_xid ( trx_ulogf_t log_hdr,
const XID xid,
mtr_t mtr 
)
static

Write X/Open XA Transaction Identification (XID) to undo log header.

Parameters
log_hdrin: undo log header
xidin: X/Open XA Transaction Identification
mtrin: mtr