#include "univ.i"
#include "trx0trx.h"
#include "trx0types.h"
#include "mtr0mtr.h"
#include "trx0sys.h"
Go to the source code of this file.
Classes | |
struct | trx_undo_inf_struct |
struct | trx_undo_arr_struct |
struct | roll_node_struct |
struct | trx_named_savept_struct |
Macros | |
#define | trx0roll_h |
#define | trx_roll_free_all_savepoints(s) trx_roll_savepoints_free((s), NULL) |
Enumerations | |
enum | roll_node_state { ROLL_NODE_SEND = 1, ROLL_NODE_WAIT } |
Functions | |
UNIV_INTERN ibool | trx_is_recv (const trx_t *trx) |
UNIV_INTERN trx_savept_t | trx_savept_take (trx_t *trx) |
UNIV_INTERN trx_undo_arr_t * | trx_undo_arr_create (void) |
UNIV_INTERN void | trx_undo_arr_free (trx_undo_arr_t *arr) |
UNIV_INLINE trx_undo_inf_t * | trx_undo_arr_get_nth_info (trx_undo_arr_t *arr, ulint n) |
UNIV_INTERN void | trx_roll_try_truncate (trx_t *trx) |
UNIV_INTERN 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) |
UNIV_INTERN ibool | trx_undo_rec_reserve (trx_t *trx, undo_no_t undo_no) |
UNIV_INTERN void | trx_undo_rec_release (trx_t *trx, undo_no_t undo_no) |
UNIV_INTERN void | trx_rollback (trx_t *trx, trx_sig_t *sig, que_thr_t **next_thr) |
UNIV_INTERN void | trx_rollback_or_clean_recovered (ibool all) |
UNIV_INTERN os_thread_ret_t | trx_rollback_or_clean_all_recovered (void *arg) |
UNIV_INTERN void | trx_finish_rollback_off_kernel (que_t *graph, trx_t *trx, que_thr_t **next_thr) |
UNIV_INTERN que_t * | trx_roll_graph_build (trx_t *trx) |
UNIV_INTERN roll_node_t * | roll_node_create (mem_heap_t *heap) |
UNIV_INTERN que_thr_t * | trx_rollback_step (que_thr_t *thr) |
UNIV_INTERN int | trx_rollback_for_mysql (trx_t *trx) |
UNIV_INTERN int | trx_rollback_last_sql_stat_for_mysql (trx_t *trx) |
UNIV_INTERN int | trx_general_rollback_for_mysql (trx_t *trx, trx_savept_t *savept) |
UNIV_INTERN ulint | trx_rollback_to_savepoint_for_mysql (trx_t *trx, const char *savepoint_name, ib_int64_t *mysql_binlog_cache_pos) |
UNIV_INTERN ulint | trx_savepoint_for_mysql (trx_t *trx, const char *savepoint_name, ib_int64_t binlog_cache_pos) |
UNIV_INTERN ulint | trx_release_savepoint_for_mysql (trx_t *trx, const char *savepoint_name) |
UNIV_INTERN void | trx_roll_savepoint_free (trx_t *trx, trx_named_savept_t *savep) |
UNIV_INTERN void | trx_roll_savepoints_free (trx_t *trx, trx_named_savept_t *savep) |
enum roll_node_state |
Rollback node states
Enumerator | |
---|---|
ROLL_NODE_SEND |
about to send a rollback signal to the transaction |
ROLL_NODE_WAIT |
rollback signal sent to the transaction, waiting for completion |
Definition at line 316 of file trx0roll.h.
UNIV_INTERN roll_node_t* roll_node_create | ( | mem_heap_t * | heap) |
Creates a rollback command node struct.
Creates a rollback command node struct.
heap | in: mem heap where created |
Definition at line 1295 of file trx0roll.cc.
References roll_node_struct::common, mem_heap_alloc(), roll_node_struct::partial, roll_node_create(), ROLL_NODE_SEND, roll_node_struct::state, and que_common_struct::type.
Referenced by pars_rollback_statement(), roll_node_create(), and trx_general_rollback_for_mysql().
UNIV_INTERN void trx_finish_rollback_off_kernel | ( | que_t * | graph, |
trx_t * | trx, | ||
que_thr_t ** | next_thr | ||
) |
Finishes a transaction rollback. in/out: next query thread to run; if the value which is passed in is a pointer to a NULL pointer, then the calling function can start running a new query thread; if this parameter is NULL, it is ignored
Finishes a transaction rollback.
graph | in: undo graph which can now be freed |
trx | in: transaction |
next_thr | in/out: next query thread to run; if the value which is passed in is a pointer to a NULL pointer, then the calling function can start running a new query thread; if this parameter is NULL, it is ignored |
Definition at line 1226 of file trx0roll.cc.
References trx_struct::id, trx_undo_arr_struct::n_used, que_graph_free(), trx_struct::que_state, trx_struct::signals, trx_commit_off_kernel(), trx_finish_rollback_off_kernel(), TRX_ID_FMT, trx_sig_remove(), trx_sig_reply(), trx_sig_struct::type, trx_struct::undo_no_arr, ut_a, ut_ad, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.
Referenced by trx_finish_rollback_off_kernel().
UNIV_INTERN int trx_general_rollback_for_mysql | ( | trx_t * | trx, |
trx_savept_t * | savept | ||
) |
Rollback a transaction used in MySQL.
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 |
Definition at line 65 of file trx0roll.cc.
References trx_struct::error_state, mem_heap_create, mem_heap_free, os_thread_sleep(), pars_complete_graph_for_exec(), roll_node_struct::partial, que_fork_start_command(), que_node_get_parent(), que_run_threads(), trx_struct::que_state, roll_node_create(), roll_node_struct::savept, srv_active_wake_master_thread(), trx_general_rollback_for_mysql(), trx_start_if_not_started(), and ut_a.
Referenced by row_create_index_for_mysql(), row_create_table_for_mysql(), row_discard_tablespace_for_mysql(), row_merge_rename_tables(), row_mysql_handle_errors(), row_rename_table_for_mysql(), row_table_add_foreign_constraints(), row_truncate_table_for_mysql(), trx_general_rollback_for_mysql(), trx_rollback_for_mysql(), trx_rollback_last_sql_stat_for_mysql(), and trx_rollback_to_savepoint_for_mysql().
UNIV_INTERN ibool trx_is_recv | ( | const trx_t * | trx) |
Determines if this transaction is rolling back an incomplete transaction in crash recovery.
Determines if this transaction is rolling back an incomplete transaction in crash recovery.
trx | in: transaction |
Definition at line 387 of file trx0roll.cc.
References trx_is_recv().
Referenced by row_undo_ins(), and trx_is_recv().
UNIV_INTERN ulint 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.
Releases only the named savepoint. Savepoints which were set after this savepoint are left as is.
trx | in: transaction handle |
savepoint_name | in: savepoint name |
Definition at line 359 of file trx0roll.cc.
References trx_named_savept_struct::name, trx_release_savepoint_for_mysql(), trx_roll_savepoint_free(), trx_struct::trx_savepoints, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, and ut_strcmp().
Referenced by InnobaseEngine::doReleaseSavepoint(), and trx_release_savepoint_for_mysql().
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.
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.
trx | in: trx handle |
Definition at line 1140 of file trx0roll.cc.
References que_thr_struct::child, mem_heap_create, que_fork_create(), que_thr_create(), row_undo_node_create(), que_fork_struct::trx, trx_roll_graph_build(), and ut_ad.
Referenced by trx_roll_graph_build(), and trx_rollback().
UNIV_INTERN 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 | ||
) |
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. Inserts the undo number of the popped undo record to the array of currently processed undo numbers in the transaction. When the query thread finishes processing of this undo record, it must be released with trx_undo_rec_release.
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. Inserts the undo number of the popped undo record to the array of currently processed undo numbers in the transaction. When the query thread finishes processing of this undo record, it must be released with trx_undo_rec_release.
trx | in: transaction |
limit | in: least undo number we need |
roll_ptr | out: roll pointer to undo record |
heap | in: memory heap where copied |
Definition at line 899 of file trx0roll.cc.
References trx_undo_struct::empty, trx_struct::insert_undo, mtr_commit(), mtr_start(), trx_rseg_struct::mutex, trx_struct::pages_undone, trx_undo_struct::rseg, trx_struct::rseg, trx_undo_struct::top_offset, trx_undo_struct::top_page_no, trx_undo_struct::top_undo_no, trx_roll_pop_top_rec_of_trx(), trx_roll_try_truncate(), trx_undo_build_roll_ptr(), trx_undo_rec_copy(), trx_undo_rec_get_undo_no(), trx_struct::undo_mutex, trx_struct::undo_no, trx_struct::undo_no_arr, trx_struct::update_undo, and ut_ad.
Referenced by trx_roll_pop_top_rec_of_trx().
UNIV_INTERN void trx_roll_savepoint_free | ( | trx_t * | trx, |
trx_named_savept_t * | savep | ||
) |
Frees a single savepoint struct. in: savepoint to free
Frees a single savepoint struct.
trx | in: transaction handle |
savep | in: savepoint to free |
Definition at line 184 of file trx0roll.cc.
References mem_free, trx_named_savept_struct::name, trx_roll_savepoint_free(), trx_struct::trx_savepoints, ut_a, UT_LIST_GET_LEN, and UT_LIST_REMOVE.
Referenced by trx_release_savepoint_for_mysql(), trx_roll_savepoint_free(), and trx_roll_savepoints_free().
UNIV_INTERN void trx_roll_savepoints_free | ( | trx_t * | trx, |
trx_named_savept_t * | savep | ||
) |
Frees savepoint structs starting from savep, if savep == NULL then free all savepoints. in: free all savepoints > this one; if this is NULL, free all savepoints of trx
Frees savepoint structs starting from savep, if savep == NULL then free all savepoints.
trx | in: transaction handle |
savep | in: free all savepoints > this one; if this is NULL, free all savepoints of trx |
Definition at line 202 of file trx0roll.cc.
References trx_roll_savepoint_free(), trx_roll_savepoints_free(), trx_struct::trx_savepoints, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.
Referenced by trx_roll_savepoints_free(), and trx_rollback_to_savepoint_for_mysql().
UNIV_INTERN void trx_roll_try_truncate | ( | trx_t * | trx) |
Tries truncate the undo logs. in/out: transaction
Tries truncate the undo logs.
trx | in/out: transaction |
Definition at line 805 of file trx0roll.cc.
References trx_struct::insert_undo, trx_undo_arr_struct::n_used, trx_struct::pages_undone, trx_struct::rseg, trx_roll_try_truncate(), trx_undo_truncate_end(), trx_struct::undo_mutex, trx_struct::undo_no, trx_struct::undo_no_arr, trx_struct::update_undo, and ut_ad.
Referenced by trx_roll_pop_top_rec_of_trx(), and trx_roll_try_truncate().
Starts a rollback operation. in/out: next query thread to run; if the value which is passed in is a pointer to a NULL pointer, then the calling function can start running a new query thread
Starts a rollback operation.
trx | in: transaction |
sig | in: signal starting the rollback |
next_thr | in/out: next query thread to run; if the value which is passed in is a pointer to a NULL pointer, then the calling function can start running a new query thread; if the passed value is NULL, the parameter is ignored |
Definition at line 1066 of file trx0roll.cc.
References trx_struct::graph, trx_savept_struct::least_undo_no, trx_struct::pages_undone, que_fork_start_command(), trx_struct::que_state, trx_struct::roll_limit, trx_sig_struct::savept, srv_que_task_enqueue_low(), trx_roll_graph_build(), trx_rollback(), trx_undo_arr_create(), trx_sig_struct::type, trx_struct::undo_no, trx_struct::undo_no_arr, ut_a, ut_ad, and ut_error.
Referenced by trx_rollback(), and trx_sig_start_handle().
UNIV_INTERN int trx_rollback_for_mysql | ( | trx_t * | trx) |
Rollback a transaction used in MySQL.
Rollback a transaction used in MySQL.
trx | in: transaction handle |
Definition at line 129 of file trx0roll.cc.
References trx_struct::conc_state, trx_struct::op_info, trx_general_rollback_for_mysql(), and trx_rollback_for_mysql().
Referenced by InnobaseEngine::doRollback(), innobase_rollback_trx(), and trx_rollback_for_mysql().
UNIV_INTERN int trx_rollback_last_sql_stat_for_mysql | ( | trx_t * | trx) |
Rollback the latest SQL statement for MySQL.
Rollback the latest SQL statement for MySQL.
trx | in: transaction handle |
Definition at line 158 of file trx0roll.cc.
References trx_struct::conc_state, trx_struct::op_info, trx_general_rollback_for_mysql(), trx_mark_sql_stat_end(), and trx_rollback_last_sql_stat_for_mysql().
Referenced by InnobaseEngine::doRollback(), and trx_rollback_last_sql_stat_for_mysql().
UNIV_INTERN os_thread_ret_t trx_rollback_or_clean_all_recovered | ( | void * | ) |
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.
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.
Definition at line 611 of file trx0roll.cc.
References os_thread_exit(), trx_rollback_or_clean_all_recovered(), and trx_rollback_or_clean_recovered().
Referenced by recv_recovery_rollback_active(), and trx_rollback_or_clean_all_recovered().
UNIV_INTERN void trx_rollback_or_clean_recovered | ( | ibool | 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
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 |
Definition at line 537 of file trx0roll.cc.
References trx_struct::conc_state, trx_struct::id, trx_struct::is_recovered, trx_cleanup_at_db_startup(), TRX_DICT_OP_NONE, trx_get_dict_operation(), TRX_ID_FMT, trx_rollback_or_clean_recovered(), trx_sys, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, and ut_print_timestamp().
Referenced by recv_recovery_from_checkpoint_finish(), trx_rollback_or_clean_all_recovered(), and trx_rollback_or_clean_recovered().
Performs an execution step for a rollback command node in a query graph.
Performs an execution step for a rollback command node in a query graph.
thr | in: query thread |
Definition at line 1316 of file trx0roll.cc.
References roll_node_struct::partial, que_thr_struct::prev_node, que_node_get_parent(), que_node_get_type(), ROLL_NODE_SEND, ROLL_NODE_WAIT, que_thr_struct::run_node, roll_node_struct::savept, roll_node_struct::state, que_thr_struct::state, thr_get_trx(), trx_rollback_step(), trx_sig_send(), and ut_ad.
Referenced by trx_rollback_step().
UNIV_INTERN ulint trx_rollback_to_savepoint_for_mysql | ( | trx_t * | trx, |
const char * | savepoint_name, | ||
ib_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.
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 |
Definition at line 237 of file trx0roll.cc.
References trx_struct::conc_state, trx_named_savept_struct::mysql_binlog_cache_pos, trx_named_savept_struct::name, trx_struct::op_info, trx_named_savept_struct::savept, trx_general_rollback_for_mysql(), trx_mark_sql_stat_end(), trx_roll_savepoints_free(), trx_rollback_to_savepoint_for_mysql(), trx_struct::trx_savepoints, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, ut_print_name(), ut_print_timestamp(), and ut_strcmp().
Referenced by InnobaseEngine::doRollbackToSavepoint(), and trx_rollback_to_savepoint_for_mysql().
UNIV_INTERN ulint trx_savepoint_for_mysql | ( | trx_t * | trx, |
const char * | savepoint_name, | ||
ib_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.
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 |
Definition at line 302 of file trx0roll.cc.
References mem_free, mem_strdup(), trx_named_savept_struct::mysql_binlog_cache_pos, trx_named_savept_struct::name, trx_named_savept_struct::savept, trx_savepoint_for_mysql(), trx_struct::trx_savepoints, trx_savept_take(), trx_start_if_not_started(), ut_a, UT_LIST_ADD_LAST, UT_LIST_GET_FIRST, UT_LIST_GET_NEXT, UT_LIST_REMOVE, and ut_strcmp().
Referenced by InnobaseEngine::doSetSavepoint(), and trx_savepoint_for_mysql().
UNIV_INTERN trx_savept_t trx_savept_take | ( | trx_t * | trx) |
Returns a transaction savepoint taken at this point in time.
Returns a transaction savepoint taken at this point in time.
trx | in: transaction |
Definition at line 399 of file trx0roll.cc.
References trx_savept_struct::least_undo_no, trx_savept_take(), and trx_struct::undo_no.
Referenced by row_insert_for_mysql(), row_update_for_mysql(), trx_savepoint_for_mysql(), and trx_savept_take().
UNIV_INTERN trx_undo_arr_t* trx_undo_arr_create | ( | void | ) |
Creates an undo number array.
Creates an undo number array.
Definition at line 636 of file trx0roll.cc.
References trx_undo_arr_struct::heap, trx_undo_arr_struct::infos, mem_heap_alloc(), mem_heap_create, trx_undo_arr_struct::n_cells, trx_undo_arr_struct::n_used, trx_undo_arr_create(), and trx_undo_arr_get_nth_info().
Referenced by trx_purge_sys_create(), trx_rollback(), and trx_undo_arr_create().
UNIV_INTERN void trx_undo_arr_free | ( | trx_undo_arr_t * | arr) |
Frees an undo number array. in: undo number array
Frees an undo number array.
arr | in: undo number array |
Definition at line 666 of file trx0roll.cc.
References trx_undo_arr_struct::heap, mem_heap_free, trx_undo_arr_struct::n_used, trx_undo_arr_free(), and ut_ad.
Referenced by trx_free(), trx_purge_sys_close(), and trx_undo_arr_free().
UNIV_INLINE trx_undo_inf_t* trx_undo_arr_get_nth_info | ( | trx_undo_arr_t * | arr, |
ulint | n | ||
) |
Returns pointer to nth element in an undo number array.
arr | in: undo number array |
Referenced by trx_undo_arr_create().
Releases a reserved undo record. in: undo number
Releases a reserved undo record.
trx | in/out: transaction |
undo_no | in: undo number |
Definition at line 1046 of file trx0roll.cc.
References trx_undo_rec_release(), trx_struct::undo_mutex, and trx_struct::undo_no_arr.
Referenced by row_undo_ins(), row_undo_mod(), and trx_undo_rec_release().
Reserves an undo log record for a query thread to undo. This should be called if the query thread gets the undo log record not using the pop function above.
Reserves an undo log record for a query thread to undo. This should be called if the query thread gets the undo log record not using the pop function above.
trx | in/out: transaction |
undo_no | in: undo number of the record |
Definition at line 1026 of file trx0roll.cc.
References trx_undo_rec_reserve(), and trx_struct::undo_mutex.
Referenced by trx_undo_rec_reserve().