MySQL 9.1.0
Source Code Documentation
row0purge.cc File Reference

Purge obsolete records. More...

#include "row0purge.h"
#include <stddef.h>
#include "current_thd.h"
#include "debug_sync.h"
#include "mysqld.h"
#include "string_with_len.h"
#include "dict0dd.h"
#include "fsp0fsp.h"
#include "ha_innodb.h"
#include "handler.h"
#include "lob0lob.h"
#include "log0chkp.h"
#include "mach0data.h"
#include "que0que.h"
#include "row0log.h"
#include "row0mysql.h"
#include "row0row.h"
#include "row0upd.h"
#include "row0vers.h"
#include "sql_base.h"
#include "srv0mon.h"
#include "srv0start.h"
#include "sync0types.h"
#include "table.h"
#include "trx0purge.h"
#include "trx0rec.h"
#include "trx0roll.h"
#include "trx0rseg.h"
#include "trx0trx.h"
#include "trx0undo.h"

Functions

purge_node_trow_purge_node_create (que_thr_t *parent, mem_heap_t *heap)
 Create a purge node to a query graph. More...
 
static bool row_purge_reposition_pcur (ulint mode, purge_node_t *node, mtr_t *mtr)
 Repositions the pcur in the purge node on the clustered index record, if found. More...
 
static bool row_purge_remove_clust_if_poss_low (purge_node_t *node, ulint mode)
 Removes a delete marked clustered index record if possible. More...
 
static bool row_purge_remove_clust_if_poss (purge_node_t *node)
 Removes a clustered index record if it has not been modified after the delete marking. More...
 
bool row_purge_poss_sec (purge_node_t *node, dict_index_t *index, const dtuple_t *entry)
 Determines if it is possible to remove a secondary index entry. More...
 
static bool row_purge_remove_sec_if_poss_tree (purge_node_t *node, dict_index_t *index, const dtuple_t *entry)
 
static bool row_purge_remove_sec_if_poss_leaf (purge_node_t *node, dict_index_t *index, const dtuple_t *entry)
 
static void row_purge_remove_sec_if_poss (purge_node_t *node, dict_index_t *index, const dtuple_t *entry)
 Removes a secondary index entry if possible. More...
 
static void row_purge_skip_uncommitted_virtual_index (dict_index_t *&index)
 Skip uncommitted virtual indexes on newly added virtual column. More...
 
static void row_purge_remove_multi_sec_if_poss (purge_node_t *node, mem_heap_t *heap, bool selected)
 Remove multi-value index entries if possible. More...
 
static bool row_purge_del_mark (purge_node_t *node)
 Purges a delete marking of a record. More...
 
static void row_purge_upd_exist_or_extern_func (const que_thr_t *thr, purge_node_t *node, trx_undo_rec_t *undo_rec)
 Purges an update of an existing record. More...
 
void row_purge_upd_exist_or_extern (const que_thr_t *thr, purge_node_t *node, trx_undo_rec_t *undo_rec)
 
static bool row_purge_parse_undo_rec (purge_node_t *node, trx_undo_rec_t *undo_rec, bool *updated_extern, THD *thd, que_thr_t *thr)
 Parses the row reference and other info in a modify undo log record. More...
 
static bool row_purge_record_func (purge_node_t *node, trx_undo_rec_t *undo_rec, const que_thr_t *thr, bool updated_extern, THD *thd)
 Purges the parsed record. More...
 
bool row_purge_record (purge_node_t *node, trx_undo_rec_t *undo_rec, const que_thr_t *thr, bool updated_extern, THD *thd)
 
static void row_purge (purge_node_t *node, trx_undo_rec_t *undo_rec, que_thr_t *thr)
 Fetches an undo log record and does the purge for the recorded operation. More...
 
static void row_purge_end (que_thr_t *thr)
 Reset the purge query thread. More...
 
que_thr_trow_purge_step (que_thr_t *thr)
 Does the purge operation for a single undo log record. More...
 

Detailed Description

Purge obsolete records.

Created 3/14/1997 Heikki Tuuri

Function Documentation

◆ row_purge()

static void row_purge ( purge_node_t node,
trx_undo_rec_t undo_rec,
que_thr_t thr 
)
static

Fetches an undo log record and does the purge for the recorded operation.

If none left, or the current purge completed, returns the control to the parent node, which is always a query thread node.

Parameters
nodein: row purge node
undo_recin: record to purge
thrin: query thread

◆ row_purge_del_mark()

static bool row_purge_del_mark ( purge_node_t node)
static

Purges a delete marking of a record.

Return values
trueif the row was not found, or it was successfully removed
falsethe purge needs to be suspended because of running out of file space
Parameters
nodein/out: row purge node

◆ row_purge_end()

static void row_purge_end ( que_thr_t thr)
static

Reset the purge query thread.

Parameters
[in,out]thrThe query thread to execute

◆ row_purge_node_create()

purge_node_t * row_purge_node_create ( que_thr_t parent,
mem_heap_t heap 
)

Create a purge node to a query graph.

Parameters
[in]parentparent node, i.e., a thr node
[in]heapmemory heap where created
Returns
own: purge node

◆ row_purge_parse_undo_rec()

static bool row_purge_parse_undo_rec ( purge_node_t node,
trx_undo_rec_t undo_rec,
bool *  updated_extern,
THD thd,
que_thr_t thr 
)
static

Parses the row reference and other info in a modify undo log record.

Parameters
[in,out]noderow undo node
[in]undo_recundo record to purge
[out]updated_externwhether an externally stored field was updated
[in,out]thdcurrent thread
[in,out]threxecution thread
Returns
true if purge operation required

◆ row_purge_poss_sec()

bool row_purge_poss_sec ( purge_node_t node,
dict_index_t index,
const dtuple_t entry 
)

Determines if it is possible to remove a secondary index entry.

Removal is possible if the secondary index entry does not refer to any not delete marked version of a clustered index record where DB_TRX_ID is newer than the purge view.

NOTE: This function should only be called by the purge thread, only while holding a latch on the leaf page of the secondary index entry (or keeping the buffer pool watch on the page). It is possible that this function first returns true and then false, if a user transaction inserts a record that the secondary index entry would refer to. However, in that case, the user transaction would also re-insert the secondary index entry after purge has removed it and released the leaf page latch.

Returns
true if the secondary index record can be purged
Parameters
nodein/out: row purge node
indexin: secondary index
entryin: secondary index entry

◆ row_purge_record()

bool row_purge_record ( purge_node_t node,
trx_undo_rec_t undo_rec,
const que_thr_t thr,
bool  updated_extern,
THD thd 
)
inline

◆ row_purge_record_func()

static bool row_purge_record_func ( purge_node_t node,
trx_undo_rec_t undo_rec,
const que_thr_t thr,
bool  updated_extern,
THD thd 
)
static

Purges the parsed record.

Parameters
[in,out]noderow purge node
[in]undo_recundo record to purge
[in,out]thrquery thread
[in]updated_externwhether external columns were updated
[in,out]thdcurrent thread
Returns
true if purged, false if skipped

◆ row_purge_remove_clust_if_poss()

static bool row_purge_remove_clust_if_poss ( purge_node_t node)
static

Removes a clustered index record if it has not been modified after the delete marking.

Return values
trueif the row was not found, or it was successfully removed
falsethe purge needs to be suspended because of running out of file space.
Parameters
nodein/out: row purge node

◆ row_purge_remove_clust_if_poss_low()

static bool row_purge_remove_clust_if_poss_low ( purge_node_t node,
ulint  mode 
)
static

Removes a delete marked clustered index record if possible.

Return values
trueif the row was not found, or it was successfully removed
falseif the row was modified after the delete marking
Parameters
nodein/out: row purge node
modein: BTR_MODIFY_LEAF or BTR_MODIFY_TREE

◆ row_purge_remove_multi_sec_if_poss()

static void row_purge_remove_multi_sec_if_poss ( purge_node_t node,
mem_heap_t heap,
bool  selected 
)
inlinestatic

Remove multi-value index entries if possible.

Parameters
[in,out]noderow purge node
[in,out]heapmemory heap
[in]selectedtrue if only selected multi-value data should be purged

◆ row_purge_remove_sec_if_poss()

static void row_purge_remove_sec_if_poss ( purge_node_t node,
dict_index_t index,
const dtuple_t entry 
)
inlinestatic

Removes a secondary index entry if possible.

Parameters
nodein: row purge node
indexin: index
entryin: index entry

◆ row_purge_remove_sec_if_poss_leaf()

static bool row_purge_remove_sec_if_poss_leaf ( purge_node_t node,
dict_index_t index,
const dtuple_t entry 
)
static
Parameters
nodein: row purge node
indexin: index
entryin: index entry

◆ row_purge_remove_sec_if_poss_tree()

static bool row_purge_remove_sec_if_poss_tree ( purge_node_t node,
dict_index_t index,
const dtuple_t entry 
)
static
Parameters
nodein: row purge node
indexin: index
entryin: index entry

◆ row_purge_reposition_pcur()

static bool row_purge_reposition_pcur ( ulint  mode,
purge_node_t node,
mtr_t mtr 
)
static

Repositions the pcur in the purge node on the clustered index record, if found.

If the record is not found, close pcur.

Returns
true if the record was found
Parameters
modein: latching mode
nodein: row purge node
mtrin: mtr

◆ row_purge_skip_uncommitted_virtual_index()

static void row_purge_skip_uncommitted_virtual_index ( dict_index_t *&  index)
inlinestatic

Skip uncommitted virtual indexes on newly added virtual column.

Parameters
[in,out]indexdict index object

◆ row_purge_step()

que_thr_t * row_purge_step ( que_thr_t thr)

Does the purge operation for a single undo log record.

in: query thread

This is a high-level function used in an SQL execution graph.

Parameters
[in,out]thrThe query thread to execute
Returns
query thread to run next or nullptr

◆ row_purge_upd_exist_or_extern()

void row_purge_upd_exist_or_extern ( const que_thr_t thr,
purge_node_t node,
trx_undo_rec_t undo_rec 
)
inline

◆ row_purge_upd_exist_or_extern_func()

static void row_purge_upd_exist_or_extern_func ( const que_thr_t thr,
purge_node_t node,
trx_undo_rec_t undo_rec 
)
static

Purges an update of an existing record.

Also purges an update of a delete marked record if that record contained an externally stored field.

Parameters
[in]thrquery thread
[in]noderow purge node
[in]undo_recrecord to purge