MySQL 8.0.39
Source Code Documentation
|
Transaction rollback. More...
#include <sys/types.h>
#include "clone0clone.h"
#include "dict0dd.h"
#include "fsp0fsp.h"
#include "ha_prototypes.h"
#include "lock0lock.h"
#include "mach0data.h"
#include "os0thread-create.h"
#include "pars0pars.h"
#include "que0que.h"
#include "read0read.h"
#include "row0mysql.h"
#include "row0undo.h"
#include "sql_thd_internal_api.h"
#include "srv0mon.h"
#include "srv0start.h"
#include "trx0rec.h"
#include "trx0roll.h"
#include "trx0rseg.h"
#include "trx0sys.h"
#include "trx0trx.h"
#include "trx0undo.h"
#include "usr0sess.h"
#include "current_thd.h"
Functions | |
static void | trx_rollback_finish (trx_t *trx) |
Finishes a transaction rollback. More... | |
static void | trx_rollback_to_savepoint_low (trx_t *trx, trx_savept_t *savept) |
Rollback a transaction used in 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... | |
static dberr_t | trx_rollback_for_mysql_low (trx_t *trx) |
Rollback a transaction used in MySQL. More... | |
static dberr_t | trx_rollback_low (trx_t *trx) |
Rollback a transaction used in MySQL. 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... | |
static trx_named_savept_t * | trx_savepoint_find (trx_t *trx, const char *name) |
Search for a savepoint using name. More... | |
static void | trx_roll_savepoint_free (trx_t *trx, trx_named_savept_t *savep) |
Frees a single savepoint struct. More... | |
void | trx_roll_savepoints_free (trx_t *trx, trx_named_savept_t *savep) |
Frees savepoint structs starting from savep. More... | |
static dberr_t | trx_rollback_to_savepoint_for_mysql_low (trx_t *trx, trx_named_savept_t *savep, int64_t *mysql_binlog_cache_pos) |
Rolls back a transaction back to a named savepoint. 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 only the named savepoint. More... | |
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... | |
static void | trx_rollback_active (trx_t *trx) |
Roll back an active transaction. More... | |
static bool | trx_rollback_or_clean_resurrected (trx_t *trx, bool all) |
Rollback or clean up any resurrected incomplete transactions. 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 (THD *thd) |
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... | |
static void | trx_roll_try_truncate (trx_t *trx, trx_undo_ptr_t *undo_ptr) |
Tries truncate the undo logs. More... | |
static const page_t * | trx_roll_pop_top_rec (trx_t *trx, trx_undo_t *undo, mtr_t *mtr, uint32_t *undo_offset) |
Pops the topmost undo log record in a single undo log and updates the info about the topmost record in the undo log memory struct. More... | |
static trx_undo_rec_t * | trx_roll_pop_top_rec_of_trx_low (trx_t *trx, trx_undo_ptr_t *undo_ptr, undo_no_t limit, roll_ptr_t *roll_ptr, mem_heap_t *heap) |
Pops the topmost record when the two undo logs of a transaction are seen as a single stack of records ordered by their undo numbers. More... | |
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. More... | |
static que_t * | trx_roll_graph_build (trx_t *trx, bool partial_rollback) |
Builds an undo 'query' graph for a transaction. More... | |
static que_thr_t * | trx_rollback_start (trx_t *trx, ib_id_t roll_limit, bool partial_rollback) |
Starts a rollback operation, creates the UNDO graph that will do the actual undo operation. More... | |
roll_node_t * | roll_node_create (mem_heap_t *heap) |
Creates a rollback command node struct. More... | |
que_thr_t * | trx_rollback_step (que_thr_t *thr) |
Performs an execution step for a rollback command node in a query graph. More... | |
Variables | |
static const ulint | TRX_ROLL_TRUNC_THRESHOLD = 1 |
This many pages must be undone before a truncate is tried within rollback. More... | |
static const trx_t * | trx_roll_crash_recv_trx = nullptr |
In crash recovery, the current trx to be rolled back; NULL otherwise. More... | |
static undo_no_t | trx_roll_max_undo_no |
In crash recovery we set this to the undo n:o of the current trx to be rolled back. More... | |
static ulint | trx_roll_progress_printed_pct |
Auxiliary variable which tells the previous progress % we printed. More... | |
Transaction rollback.
Created 3/26/1996 Heikki Tuuri
roll_node_t * roll_node_create | ( | mem_heap_t * | heap | ) |
Creates a rollback command node struct.
heap | in: mem heap where created |
bool trx_is_recv | ( | const trx_t * | trx | ) |
Determines if this transaction is rolling back an incomplete transaction in crash recovery.
trx | in: transaction |
void trx_recovery_rollback | ( | THD * | thd | ) |
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.
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.
Releases only the named savepoint.
Releases a named savepoint.
Savepoints which were set after this savepoint are left as is.
trx | in: transaction handle |
savepoint_name | in: savepoint name |
Builds an undo 'query' graph for a transaction.
The actual rollback is performed by executing this query graph like a query subprocedure call. The reply about the completion of the rollback will be sent by this graph.
[in,out] | trx | transaction |
[in] | partial_rollback | true if partial rollback |
|
static |
Pops the topmost undo log record in a single undo log and updates the info about the topmost record in the undo log memory struct.
[in] | trx | transaction |
[in] | undo | undo log |
[in] | mtr | mtr |
[out] | undo_offset | offset of undo record in the page |
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.
trx | in: transaction |
limit | in: least undo number we need |
roll_ptr | out: roll pointer to undo record |
heap | in: memory heap where copied |
|
static |
Pops the topmost record when the two undo logs of a transaction are seen as a single stack of records ordered by their undo numbers.
trx | in/out: transaction |
undo_ptr | in: rollback segment to look for next undo log record. |
limit | in: least undo number we need |
roll_ptr | out: roll pointer to undo record |
heap | in/out: memory heap where copied |
|
static |
Frees a single savepoint struct.
trx | in: transaction handle |
savep | in: savepoint to free |
void trx_roll_savepoints_free | ( | trx_t * | trx, |
trx_named_savept_t * | savep | ||
) |
Frees savepoint structs starting from savep.
[in] | trx | Transaction handle |
[in] | savep | Free all savepoints starting with this savepoint i, if savep is nullptr free all save points |
|
static |
Tries truncate the undo logs.
trx | in/out: transaction |
undo_ptr | in: rollback segment to look for next undo log record. |
|
static |
Roll back an active transaction.
trx | in/out: transaction |
|
static |
Finishes a transaction rollback.
in: transaction
trx | in: transaction |
Rollback a transaction used in MySQL.
trx | in/out: transaction |
Rollback a transaction used in MySQL.
trx | in/out: transaction |
Rollback the latest SQL statement for MySQL.
trx | in/out: transaction |
Rollback a transaction used in MySQL.
[in,out] | trx | transaction |
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.
all | in: false=roll back dictionary transactions; true=roll back all non-PREPARED transactions |
|
static |
Rollback or clean up any resurrected incomplete transactions.
It assumes that the caller holds the trx_sys_t::mutex and it will release the lock if it does a clean up or rollback.
trx | in: transaction to rollback or clean |
all | in: false=roll back dictionary transactions; true=roll back all non-PREPARED transactions |
|
static |
Starts a rollback operation, creates the UNDO graph that will do the actual undo operation.
[in] | trx | transaction |
[in] | roll_limit | rollback to undo no (for partial undo), 0 if we are rolling back the entire transaction |
[in] | partial_rollback | true if partial rollback |
Performs an execution step for a rollback command node in a query graph.
thr | in: query thread |
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.
trx | in: transaction handle |
savept | in: pointer to savepoint undo number, if partial rollback requested, or NULL for complete rollback |
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.
trx | in: transaction handle |
savepoint_name | in: savepoint name |
mysql_binlog_cache_pos | 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 |
|
static |
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.
trx | in/out: transaction |
savep | in/out: savepoint |
mysql_binlog_cache_pos | 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 |
|
static |
Rollback a transaction used in MySQL.
trx | in: transaction handle |
savept | in: pointer to savepoint undo number, if partial rollback requested, or NULL for complete rollback |
|
static |
Search for a savepoint using name.
trx | in: transaction |
name | in: savepoint name |
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.
trx | in: transaction handle |
savepoint_name | in: savepoint name |
binlog_cache_pos | in: MySQL binlog cache position corresponding to this connection at the time of the savepoint |
trx_savept_t trx_savept_take | ( | trx_t * | trx | ) |
Returns a transaction savepoint taken at this point in time.
trx | in: transaction |
In crash recovery, the current trx to be rolled back; NULL otherwise.
|
static |
In crash recovery we set this to the undo n:o of the current trx to be rolled back.
Then we can print how many % the rollback has progressed.
|
static |
Auxiliary variable which tells the previous progress % we printed.
|
static |
This many pages must be undone before a truncate is tried within rollback.