MySQL 9.1.0
Source Code Documentation
trx0roll.h File Reference

Transaction rollback. More...

#include "mtr0mtr.h"
#include "trx0sys.h"
#include "trx0trx.h"
#include "trx0types.h"
#include "univ.i"
#include "trx0roll.ic"

Go to the source code of this file.

Classes

struct  roll_node_t
 Rollback command node in a query graph. More...
 
struct  trx_named_savept_t
 A savepoint set with SQL's "SAVEPOINT savepoint_id" command. More...
 

Enumerations

enum  roll_node_state { ROLL_NODE_NONE = 0 , ROLL_NODE_SEND , ROLL_NODE_WAIT }
 Rollback node states. More...
 

Functions

bool trx_is_recv (const trx_t *trx)
 Determines if this transaction is rolling back an incomplete transaction in crash recovery. More...
 
trx_savept_t trx_savept_take (trx_t *trx)
 Returns a transaction savepoint taken at this point in time. More...
 
trx_undo_rec_ttrx_roll_pop_top_rec_of_trx (trx_t *trx, undo_no_t limit, roll_ptr_t *roll_ptr, mem_heap_t *heap)
 Get next undo log record from redo and noredo rollback segments. More...
 
void trx_rollback_or_clean_recovered (bool all)
 Rollback or clean up any incomplete transactions which were encountered in crash recovery. More...
 
void trx_recovery_rollback_thread ()
 Rollback or clean up any incomplete transactions which were encountered in crash recovery. More...
 
roll_node_troll_node_create (mem_heap_t *heap)
 Creates a rollback command node struct. More...
 
que_thr_ttrx_rollback_step (que_thr_t *thr)
 Performs an execution step for a rollback command node in a query graph. More...
 
dberr_t trx_rollback_for_mysql (trx_t *trx)
 Rollback a transaction used in MySQL. More...
 
dberr_t trx_rollback_last_sql_stat_for_mysql (trx_t *trx)
 Rollback the latest SQL statement for MySQL. More...
 
dberr_t trx_rollback_to_savepoint (trx_t *trx, trx_savept_t *savept)
 Rollback a transaction to a given savepoint or do a complete rollback. More...
 
dberr_t trx_rollback_to_savepoint_for_mysql (trx_t *trx, const char *savepoint_name, int64_t *mysql_binlog_cache_pos)
 Rolls back a transaction back to a named savepoint. More...
 
dberr_t trx_savepoint_for_mysql (trx_t *trx, const char *savepoint_name, int64_t binlog_cache_pos)
 Creates a named savepoint. More...
 
dberr_t trx_release_savepoint_for_mysql (trx_t *trx, const char *savepoint_name)
 Releases a named savepoint. More...
 
void trx_roll_savepoints_free (trx_t *trx, trx_named_savept_t *savep)
 Frees savepoint structs starting from savep. More...
 

Variables

os_event_t recovery_lock_taken
 

Detailed Description

Transaction rollback.

Created 3/26/1996 Heikki Tuuri

Enumeration Type Documentation

◆ roll_node_state

Rollback node states.

Enumerator
ROLL_NODE_NONE 

Unknown state.

ROLL_NODE_SEND 

about to send a rollback signal to the transaction

ROLL_NODE_WAIT 

rollback signal sent to the transaction, waiting for completion

Function Documentation

◆ roll_node_create()

roll_node_t * roll_node_create ( mem_heap_t heap)

Creates a rollback command node struct.

Returns
own: rollback node struct in: mem heap where created
own: rollback node struct
Parameters
heapin: mem heap where created

◆ trx_is_recv()

bool trx_is_recv ( const trx_t trx)

Determines if this transaction is rolling back an incomplete transaction in crash recovery.

Returns
true if trx is an incomplete transaction that is being rolled back in crash recovery in: transaction
true if trx is an incomplete transaction that is being rolled back in crash recovery
Parameters
trxin: transaction

◆ trx_recovery_rollback_thread()

void trx_recovery_rollback_thread ( )

Rollback or clean up any incomplete transactions which were encountered in crash recovery.

If the transaction already was committed, then we clean up a possible insert undo log. If the transaction was not yet committed, then we roll it back. Note: this is done in a background thread.

◆ trx_release_savepoint_for_mysql()

dberr_t trx_release_savepoint_for_mysql ( trx_t trx,
const char *  savepoint_name 
)

Releases a named savepoint.

Savepoints which were set after this savepoint are deleted.

Returns
if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS in: savepoint name

Releases a named savepoint.

Savepoints which were set after this savepoint are left as is.

Returns
if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS
Parameters
trxin: transaction handle
savepoint_namein: savepoint name

◆ trx_roll_pop_top_rec_of_trx()

trx_undo_rec_t * trx_roll_pop_top_rec_of_trx ( trx_t trx,
undo_no_t  limit,
roll_ptr_t roll_ptr,
mem_heap_t heap 
)

Get next undo log record from redo and noredo rollback segments.

Returns
undo log record copied to heap, NULL if none left, or if the undo number of the top record would be less than the limit in: memory heap where copied
undo log record copied to heap, NULL if none left, or if the undo number of the top record would be less than the limit
Parameters
trxin: transaction
limitin: least undo number we need
roll_ptrout: roll pointer to undo record
heapin: memory heap where copied

◆ trx_roll_savepoints_free()

void trx_roll_savepoints_free ( trx_t trx,
trx_named_savept_t savep 
)

Frees savepoint structs starting from savep.

Parameters
[in]trxTransaction handle
[in]savepFree all savepoints starting with this savepoint i, if savep is nullptr free all save points

◆ trx_rollback_for_mysql()

dberr_t trx_rollback_for_mysql ( trx_t trx)

Rollback a transaction used in MySQL.

Returns
error code or DB_SUCCESS in/out: transaction
error code or DB_SUCCESS
Parameters
trxin/out: transaction

◆ trx_rollback_last_sql_stat_for_mysql()

dberr_t trx_rollback_last_sql_stat_for_mysql ( trx_t trx)

Rollback the latest SQL statement for MySQL.

Returns
error code or DB_SUCCESS in/out: transaction
error code or DB_SUCCESS
Parameters
trxin/out: transaction

◆ trx_rollback_or_clean_recovered()

void trx_rollback_or_clean_recovered ( bool  all)

Rollback or clean up any incomplete transactions which were encountered in crash recovery.

If the transaction already was committed, then we clean up a possible insert undo log. If the transaction was not yet committed, then we roll it back. in: false=roll back dictionary transactions; true=roll back all non-PREPARED transactions

If the transaction already was committed, then we clean up a possible insert undo log. If the transaction was not yet committed, then we roll it back.

Parameters
allin: false=roll back dictionary transactions; true=roll back all non-PREPARED transactions

◆ trx_rollback_step()

que_thr_t * trx_rollback_step ( que_thr_t thr)

Performs an execution step for a rollback command node in a query graph.

Returns
query thread to run next, or NULL in: query thread
query thread to run next, or NULL
Parameters
thrin: query thread

◆ trx_rollback_to_savepoint()

dberr_t trx_rollback_to_savepoint ( trx_t trx,
trx_savept_t savept 
)

Rollback a transaction to a given savepoint or do a complete rollback.

Returns
error code or DB_SUCCESS in: pointer to savepoint undo number, if partial rollback requested, or NULL for complete rollback
error code or DB_SUCCESS
Parameters
trxin: transaction handle
saveptin: pointer to savepoint undo number, if partial rollback requested, or NULL for complete rollback

◆ trx_rollback_to_savepoint_for_mysql()

dberr_t trx_rollback_to_savepoint_for_mysql ( trx_t trx,
const char *  savepoint_name,
int64_t *  mysql_binlog_cache_pos 
)

Rolls back a transaction back to a named savepoint.

Modifications after the savepoint are undone but InnoDB does NOT release the corresponding locks which are stored in memory. If a lock is 'implicit', that is, a new inserted row holds a lock where the lock information is carried by the trx id stored in the row, these locks are naturally released in the rollback. Savepoints which were set after this savepoint are deleted.

Returns
if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS out: the MySQL binlog cache position corresponding to this savepoint; MySQL needs this information to remove the binlog entries of the queries executed after the savepoint

Modifications after the savepoint are undone but InnoDB does NOT release the corresponding locks which are stored in memory. If a lock is 'implicit', that is, a new inserted row holds a lock where the lock information is carried by the trx id stored in the row, these locks are naturally released in the rollback. Savepoints which were set after this savepoint are deleted.

Returns
if no savepoint of the name found then DB_NO_SAVEPOINT, otherwise DB_SUCCESS
Parameters
trxin: transaction handle
savepoint_namein: savepoint name
mysql_binlog_cache_posout: the MySQL binlog cache position corresponding to this savepoint; MySQL needs this information to remove the binlog entries of the queries executed after the savepoint

◆ trx_savepoint_for_mysql()

dberr_t trx_savepoint_for_mysql ( trx_t trx,
const char *  savepoint_name,
int64_t  binlog_cache_pos 
)

Creates a named savepoint.

If the transaction is not yet started, starts it. If there is already a savepoint of the same name, this call erases that old savepoint and replaces it with a new. Savepoints are deleted in a transaction commit or rollback.

Returns
always DB_SUCCESS in: MySQL binlog cache position corresponding to this connection at the time of the savepoint

If the transaction is not yet started, starts it. If there is already a savepoint of the same name, this call erases that old savepoint and replaces it with a new. Savepoints are deleted in a transaction commit or rollback.

Returns
always DB_SUCCESS
Parameters
trxin: transaction handle
savepoint_namein: savepoint name
binlog_cache_posin: MySQL binlog cache position corresponding to this connection at the time of the savepoint

◆ trx_savept_take()

trx_savept_t trx_savept_take ( trx_t trx)

Returns a transaction savepoint taken at this point in time.

Returns
savepoint in: transaction
savepoint
Parameters
trxin: transaction

Variable Documentation

◆ recovery_lock_taken

os_event_t recovery_lock_taken
extern