258 page_t *undo_page,
bool update_rseg_history_len,
334#ifndef UNIV_HOTBACKUP
487#define TRX_UNDO_PAGE_REUSE_LIMIT (3 * UNIV_PAGE_SIZE / 4)
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:50
uint32_t page_no_t
Page number.
Definition: api0api.h:48
Data structure that contains the information about shared tablespaces.
Definition: fsp0space.h:46
Page identifier.
Definition: buf0types.h:206
Page size descriptor.
Definition: page0size.h:49
int page
Definition: ctype-mb.cc:1233
dberr_t
Definition: db0err.h:38
constexpr uint32_t FSEG_PAGE_DATA
On a page of any file segment, data may be put starting from this offset.
Definition: fsp0types.h:78
constexpr uint32_t FSEG_HEADER_SIZE
Length of the file system header, in bytes.
Definition: fsp0types.h:93
constexpr ulint FLST_BASE_NODE_SIZE
Definition: fut0lst.h:49
constexpr ulint FLST_NODE_SIZE
Definition: fut0lst.h:52
mlog_id_t
Definition: mtr0types.h:62
mode
Definition: file_handle.h:59
Definition: trx0purge.h:140
byte page_t
Type of the index page.
Definition: page0types.h:151
required string type
Definition: replication_group_member_actions.proto:33
static bool rollback(THD *thd)
Abort the current statement and transaction.
Definition: sql_cmd_srs.cc:139
The buffer control block structure.
Definition: buf0buf.h:1750
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:176
The rollback segment memory object.
Definition: trx0types.h:176
Definition: trx0trx.h:683
The transaction handle.
Definition: trx0trx.h:643
Transaction undo log memory object; this is protected by the undo_mutex in the corresponding transact...
Definition: trx0undo.h:338
page_no_t last_page_no
page number of the last page in the undo log; this may differ from top_page_no during a rollback
Definition: trx0undo.h:408
bool del_marks
relevant only in an update undo log: this is true if the transaction may have delete marked records,...
Definition: trx0undo.h:380
void set_prepared(const XID *in_xid)
Definition: trx0undo.ic:284
bool dict_operation
true if a dict operation trx
Definition: trx0undo.h:398
ulint type
TRX_UNDO_INSERT or TRX_UNDO_UPDATE.
Definition: trx0undo.h:376
page_size_t page_size
Definition: trx0undo.h:403
buf_block_t * guess_block
guess for the buffer block where the top page might reside
Definition: trx0undo.h:423
trx_id_t trx_id
id of the trx assigned to the undo log
Definition: trx0undo.h:388
ulint id
undo log slot number within the rollback segment
Definition: trx0undo.h:374
ulint empty
true if the stack of undo log records is currently empty
Definition: trx0undo.h:413
space_id_t space
space id where the undo log placed
Definition: trx0undo.h:401
page_no_t top_page_no
page number where the latest undo log record was catenated; during rollback the page from which the l...
Definition: trx0undo.h:415
std::tuple< int, size_t > gtid_get_details(bool is_prepare) const
Get offset and flag for GTID stored in undo.
Definition: trx0undo.cc:637
trx_rseg_t * rseg
rseg where the undo log belongs
Definition: trx0undo.h:399
XID xid
X/Open XA transaction identification.
Definition: trx0undo.h:390
bool gtid_allocated(bool is_prepare) const
Check if space for GTID is allocated in undo.
Definition: trx0undo.cc:629
void set_prepared_in_tc()
Definition: trx0undo.ic:290
undo_no_t top_undo_no
undo number of the latest record
Definition: trx0undo.h:422
UT_LIST_NODE_T(trx_undo_t) undo_list
undo log objects in the rollback segment are chained into lists
bool is_prepared() const
Definition: trx0undo.ic:295
ulint state
state of the corresponding undo log segment
Definition: trx0undo.h:378
ulint flag
flag for current transaction XID and GTID.
Definition: trx0undo.h:392
Gtid_storage m_gtid_storage
Storage space allocated for GTIDs.
Definition: trx0undo.h:396
page_no_t hdr_page_no
page number of the header page in the undo log
Definition: trx0undo.h:404
ulint hdr_offset
header offset of the undo log on the page
Definition: trx0undo.h:406
Gtid_storage
Undo log may could be allocated to store transaction GTIDs.
Definition: trx0undo.h:340
ulint top_offset
offset of the latest undo record, i.e., the topmost element in the undo log if we think of it as a st...
Definition: trx0undo.h:419
ulint size
current size in pages
Definition: trx0undo.h:411
An undo::Tablespace object is used to easily convert between undo_space_id and undo_space_num and to ...
Definition: trx0purge.h:313
struct xid_t is binary compatible with the XID structure as in the X/Open CAE Specification,...
Definition: xa.h:82
Transaction system global type definitions.
byte trx_undo_rec_t
Undo log record.
Definition: trx0types.h:166
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:141
byte trx_ulogf_t
Undo log header.
Definition: trx0types.h:162
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:137
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:139
constexpr uint32_t TRX_UNDO_STATE
Undo log segment header.
Definition: trx0undo.h:507
constexpr uint32_t TRX_UNDO_DICT_TRANS
true if the transaction is a table create, index create, or drop transaction: in recovery the transac...
Definition: trx0undo.h:550
static trx_undo_rec_t * trx_undo_page_get_prev_rec(trx_undo_rec_t *rec, page_no_t page_no, ulint offset)
Returns the previous undo record on the page in the specified log, or NULL if none exists.
constexpr uint32_t TRX_UNDO_NEXT_LOG
Offset of the next undo log header on this page, 0 if none.
Definition: trx0undo.h:554
constexpr uint32_t TRX_UNDO_XA_FORMAT
X/Open XA Transaction Identification (XID)
Definition: trx0undo.h:575
static page_t * trx_undo_page_get(const page_id_t &page_id, const page_size_t &page_size, mtr_t *mtr)
Gets an undo log page and x-latches it.
constexpr uint32_t TRX_UNDO_PAGE_FREE
On each page of the undo log this field contains the byte offset of the first free byte on the page.
Definition: trx0undo.h:474
constexpr uint32_t TRX_UNDO_PAGE_NODE
The file list node in the chain of undo log pages.
Definition: trx0undo.h:476
static bool trx_undo_trx_id_is_insert(const byte *trx_id)
Returns true if the record is of the insert type.
constexpr uint32_t TRX_UNDO_INSERT
Types of an undo log segment.
Definition: trx0undo.h:310
constexpr uint32_t TRX_UNDO_PAGE_LIST
Base node for the list of pages in the undo log segment; defined only on the undo log segment's first...
Definition: trx0undo.h:514
void trx_undo_gtid_read_and_persist(trx_ulogf_t *undo_log)
Read and persist GTID from undo header during recovery.
Definition: trx0undo.cc:666
constexpr uint32_t TRX_UNDO_HISTORY_NODE
If the log is put to the history list, the file list node is here.
Definition: trx0undo.h:558
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.
Definition: trx0undo.cc:260
constexpr uint32_t TRX_UNDO_FLAG_GTID
true if undo log header includes GTID information from replication
Definition: trx0undo.h:543
constexpr uint32_t TRX_UNDO_DEL_MARKS
Defined only in an update undo log: true if the transaction may have done delete markings of records,...
Definition: trx0undo.h:532
constexpr uint32_t TRX_UNDO_LOG_GTID_XA_HDR_SIZE
Total size with XA GTID information.
Definition: trx0undo.h:611
static bool trx_undo_roll_ptr_is_insert(roll_ptr_t roll_ptr)
Returns true if the roll pointer is of the insert type.
constexpr uint32_t TRX_UNDO_FLAG_XID
true if undo log header includes X/Open XA transaction identification XID
Definition: trx0undo.h:541
constexpr uint32_t TRX_UNDO_SEG_HDR_SIZE
Size of the undo log segment header.
Definition: trx0undo.h:517
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,...
Definition: trx0undo.cc:1921
constexpr uint32_t TRX_UNDO_TO_PURGE
update undo segment will not be reused: it can be freed in purge when all undo data in it is removed
Definition: trx0undo.h:324
static void trx_undo_truncate_end(const trx_t *trx, trx_undo_t *undo, undo_no_t limit)
Definition: trx0undo.h:193
constexpr uint32_t TRX_UNDO_CACHED
cached for quick reuse
Definition: trx0undo.h:319
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.
Definition: trx0undo.cc:1798
constexpr uint32_t TRX_UNDO_XA_BQUAL_LEN
xid_t::bqual_length
Definition: trx0undo.h:579
constexpr uint32_t TRX_UNDO_PAGE_HDR_SIZE
Size of the transaction undo log page header, in bytes.
Definition: trx0undo.h:479
constexpr uint32_t TRX_UNDO_PAGE_TYPE
Transaction undo log page header offsets.
Definition: trx0undo.h:467
constexpr uint32_t TRX_UNDO_ACTIVE
contains an undo log of an active transaction
Definition: trx0undo.h:317
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.
Definition: trx0undo.cc:840
void trx_undo_free_trx_with_prepared_or_active_logs(trx_t *trx, bool prepared) UNIV_COLD
At shutdown, frees the undo logs of a transaction which was either PREPARED or (ACTIVE and recovered)...
Definition: trx0undo.cc:1994
constexpr uint32_t TRX_UNDO_PAGE_HDR
The offset of the undo log page header on pages of the undo log.
Definition: trx0undo.h:462
constexpr uint32_t TRX_UNDO_LOG_XA_HDR_SIZE
Total size of the undo log header with the XA XID.
Definition: trx0undo.h:583
constexpr uint32_t TRX_UNDO_FSEG_HEADER
Header for the file segment which the undo log segment occupies.
Definition: trx0undo.h:511
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.
Definition: trx0undo.cc:344
constexpr uint32_t TRX_UNDO_SEG_HDR
The offset of the undo log segment header on the first page of the undo log segment.
Definition: trx0undo.h:501
dberr_t trx_undo_gtid_add_update_undo(trx_t *trx, bool prepare, bool rollback)
For saving GTID add update undo slot, if required.
Definition: trx0undo.cc:584
constexpr uint32_t TRX_UNDO_FLAG_XA_PREPARE_GTID
true if undo log header includes GTID information for XA PREPARE
Definition: trx0undo.h:545
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.
Definition: trx0undo.cc:295
constexpr uint32_t TRX_UNDO_TABLE_ID
Id of the table if the preceding field is true.
Definition: trx0undo.h:552
bool trx_undo_truncate_tablespace(undo::Tablespace *marked_space)
Truncate UNDO tablespace, reinitialize header and rseg.
Definition: trx0undo.cc:2037
static trx_undo_rec_t * trx_undo_page_get_next_rec(trx_undo_rec_t *rec, page_no_t page_no, ulint offset)
Returns the next undo log record on the page in the specified log, or NULL if none exists.
ulint trx_undo_lists_init(trx_rseg_t *rseg)
Initializes the undo log lists for a rollback segment memory copy.
Definition: trx0undo.cc:1405
constexpr uint32_t TRX_UNDO_LOG_GTID_VERSION
GTID version offset.
Definition: trx0undo.h:594
static trx_undo_rec_t * trx_undo_page_get_first_rec(page_t *undo_page, page_no_t page_no, ulint offset)
Returns the first undo record on the page in the specified undo log, or NULL if none exists.
constexpr uint32_t TRX_UNDO_LOG_GTID_HDR_SIZE
Total size with GTID information.
Definition: trx0undo.h:603
void trx_undo_insert_cleanup(trx_undo_ptr_t *undo_ptr, bool noredo)
Frees an insert undo log after a transaction commit or rollback.
Definition: trx0undo.cc:1956
constexpr uint32_t TRX_UNDO_LAST_LOG
Offset of the last undo log header on the segment header page, 0 if none.
Definition: trx0undo.h:509
constexpr uint32_t TRX_UNDO_LOG_GTID_LEN
Total length of GTID.
Definition: trx0undo.h:600
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.
Definition: trx0undo.cc:1880
constexpr uint32_t TRX_UNDO_LOG_OLD_HDR_SIZE
Size of the undo log header without XID information.
Definition: trx0undo.h:561
static roll_ptr_t trx_read_roll_ptr(const byte *ptr)
Reads a roll ptr from an index page.
constexpr uint32_t TRX_UNDO_PREV_LOG
Offset of the previous undo log header on this page, 0 if none.
Definition: trx0undo.h:556
dberr_t trx_undo_assign_undo(trx_t *trx, trx_undo_ptr_t *undo_ptr, ulint type)
Assigns an undo log for a transaction.
Definition: trx0undo.cc:1687
constexpr uint32_t TRX_UNDO_PREPARED_80028
contains an undo log of an prepared transaction for a server version older than 8....
Definition: trx0undo.h:327
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.
Definition: trx0undo.cc:920
static void trx_undo_free_last_page(const trx_t *trx, trx_undo_t *undo, mtr_t *mtr)
Definition: trx0undo.h:179
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/.
Definition: trx0undo.cc:644
constexpr uint32_t TRX_UNDO_TRX_NO
Transaction number of the transaction; defined only if the log is in a history list.
Definition: trx0undo.h:529
constexpr uint32_t TRX_UNDO_PREPARED_IN_TC
Definition: trx0undo.h:332
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.
Definition: trx0undo.cc:1180
constexpr uint32_t TRX_UNDO_XA_XID
Distributed transaction identifier data.
Definition: trx0undo.h:581
static trx_undo_rec_t * trx_undo_page_get_last_rec(page_t *undo_page, page_no_t page_no, ulint offset)
Returns the last undo record on the page in the specified undo log, or NULL if none exists.
constexpr uint32_t TRX_UNDO_FLAGS
Transaction UNDO flags in one byte.
Definition: trx0undo.h:539
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.
Definition: trx0undo.cc:191
constexpr uint32_t TRX_UNDO_PAGE_START
Byte offset where the undo log records for the LATEST transaction start on this page (remember that i...
Definition: trx0undo.h:471
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.
Definition: trx0undo.cc:718
constexpr uint32_t TRX_UNDO_LOG_GTID_XA
GTID offset for XA Prepare.
Definition: trx0undo.h:607
constexpr uint32_t TRX_UNDO_UPDATE
contains undo entries for updates and delete markings: in short, modifys (the name 'UPDATE' is a hist...
Definition: trx0undo.h:313
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.
Definition: trx0undo.cc:1126
constexpr uint32_t TRX_UNDO_TRX_ID
The undo log header.
Definition: trx0undo.h:526
static void trx_write_roll_ptr(byte *ptr, roll_ptr_t roll_ptr)
Writes a roll ptr to an index page.
constexpr uint32_t TRX_UNDO_XA_TRID_LEN
xid_t::gtrid_length
Definition: trx0undo.h:577
void trx_undo_free_last_page_func(const trx_t *trx, trx_undo_t *undo, mtr_t *mtr)
Frees the last undo log page.
Definition: trx0undo.cc:1033
void trx_undo_mem_free(trx_undo_t *undo)
Frees an undo log memory copy.
Definition: trx0undo.cc:1529
constexpr uint32_t TRX_UNDO_LOG_GTID
GTID offset.
Definition: trx0undo.h:597
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.
Definition: trx0undo.cc:1838
static page_t * trx_undo_page_get_s_latched(const page_id_t &page_id, const page_size_t &page_size, mtr_t *mtr)
Gets an undo log page and s-latches it.
constexpr uint32_t TRX_UNDO_PREPARED
contains an undo log of an prepared transaction
Definition: trx0undo.h:329
constexpr uint32_t TRX_UNDO_LOG_START
Offset of the first undo log record of this log on the header page; purge may remove undo log record ...
Definition: trx0undo.h:536
constexpr uint32_t TRX_UNDO_TO_FREE
insert undo segment can be freed
Definition: trx0undo.h:321
Version control for database, common definitions, and include files.
#define UNIV_COLD
Definition: univ.i:266
#define IF_DEBUG(...)
Definition: univ.i:673
unsigned long int ulint
Definition: univ.i:405
#define UT_LIST_NODE_GETTER_DEFINITION(t, m)
A helper for the UT_LIST_BASE_NODE_T_EXTERN which declares a node getter struct which extracts member...
Definition: ut0lst.h:269
bool is_xa_prepare(THD *thd)
Checks whether or not the underlying statement is an XA PREPARE.
Definition: xa.cc:695
#define XIDDATASIZE
Definition: xa.h:72
static void prepare(pax_msg *p, pax_op op)
Definition: xcom_base.cc:1587