MySQL 9.1.0
Source Code Documentation
|
The transaction. More...
#include <sys/types.h>
#include <time.h>
#include <algorithm>
#include <new>
#include <set>
#include <sql_thd_internal_api.h>
#include "btr0sea.h"
#include "clone0clone.h"
#include "current_thd.h"
#include "dict0dd.h"
#include "fsp0sysspace.h"
#include "ha_prototypes.h"
#include "lock0lock.h"
#include "log0chkp.h"
#include "log0write.h"
#include "os0proc.h"
#include "que0que.h"
#include "read0read.h"
#include "row0mysql.h"
#include "srv0mon.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "trx0purge.h"
#include "trx0rec.h"
#include "trx0roll.h"
#include "trx0rseg.h"
#include "trx0trx.h"
#include "trx0undo.h"
#include "trx0xa.h"
#include "usr0sess.h"
#include "ut0new.h"
#include "ut0pool.h"
#include "ut0vec.h"
#include "my_dbug.h"
#include "mysql/plugin.h"
#include "sql/clone_handler.h"
Classes | |
struct | TrxFactory |
For managing the life-cycle of the trx_t instance that we get from the pool. More... | |
struct | TrxPoolLock |
The lock strategy for TrxPool. More... | |
struct | TrxPoolManagerLock |
The lock strategy for the TrxPoolManager. More... | |
Typedefs | |
typedef std::set< table_id_t, std::less< table_id_t >, ut::allocator< table_id_t > > | table_id_set |
Set of table_id. More... | |
typedef std::map< trx_t *, table_id_set, std::less< trx_t * >, ut::allocator< std::pair< trx_t *const, table_id_set > > > | trx_table_map |
Map of transactions to affected table_id. More... | |
typedef Pool< trx_t, TrxFactory, TrxPoolLock > | trx_pool_t |
Use explicit mutexes for the trx_t pool and its manager. More... | |
typedef PoolManager< trx_pool_t, TrxPoolManagerLock > | trx_pools_t |
Functions | |
static void | trx_release_impl_and_expl_locks (trx_t *trx, bool serialised) |
static void | trx_flush_logs (trx_t *trx, lsn_t lsn) |
Tests the durability settings and flushes logs if needed. More... | |
void | trx_set_flush_observer (trx_t *trx, Flush_observer *observer) |
Set flush observer for the transaction. More... | |
void | trx_set_detailed_error (trx_t *trx, const char *msg) |
Set detailed error message for the transaction. More... | |
void | trx_set_detailed_error_from_file (trx_t *trx, FILE *file) |
Set detailed error message for the transaction from a file. More... | |
static void | trx_init (trx_t *trx) |
Initialize transaction object. More... | |
void | trx_pool_init () |
Create the trx_t pool. More... | |
void | trx_pool_close () |
Destroy the trx_t pool. More... | |
static trx_t * | trx_create_low () |
static void | trx_free (trx_t *&trx) |
Release a trx_t instance back to the pool. More... | |
trx_t * | trx_allocate_for_background (void) |
Creates a transaction object for background operations by the master thread. More... | |
trx_t * | trx_allocate_for_mysql (void) |
Creates a transaction object for MySQL. More... | |
static void | trx_validate_state_before_free (trx_t *trx) |
Check state of transaction before freeing it. More... | |
void | trx_free_resurrected (trx_t *trx) |
Free and initialize a transaction object instantiated during recovery. More... | |
void | trx_free_for_background (trx_t *trx) |
Free a transaction that was allocated by background or user threads. More... | |
void | trx_free_prepared_or_active_recovered (trx_t *trx) |
At shutdown, frees a transaction object that represents either: More... | |
void | trx_disconnect_from_mysql (trx_t *trx, bool prepared) |
Disconnect a transaction from MySQL. More... | |
void | trx_disconnect_plain (trx_t *trx) |
Disconnect a transaction from MySQL. More... | |
void | trx_disconnect_prepared (trx_t *trx) |
Disconnect a prepared transaction from MySQL. More... | |
void | trx_free_for_mysql (trx_t *trx) |
Free a transaction object for MySQL. More... | |
static void | trx_resurrect_table_ids (trx_t *trx, const trx_undo_ptr_t *undo_ptr, const trx_undo_t *undo) |
Resurrect the table IDs for a resurrected transaction. More... | |
void | trx_resurrect_locks (bool all) |
Resurrect table locks for resurrected transactions. More... | |
void | trx_clear_resurrected_table_ids () |
Clear all resurrected table IDs. More... | |
static trx_t * | trx_resurrect_insert (trx_undo_t *undo, trx_rseg_t *rseg) |
Resurrect the transactions that were doing inserts at the time of the crash, they need to be undone. More... | |
static void | trx_resurrect_update_in_prepared_state (trx_t *trx, const trx_undo_t *undo) |
Prepared transactions are left in the prepared state waiting for a commit or abort decision from MySQL. More... | |
static void | trx_resurrect_update (trx_t *trx, trx_undo_t *undo, trx_rseg_t *rseg) |
Resurrect the transactions that were doing updates the time of the crash, they need to be undone. More... | |
static void | trx_resurrect (trx_rseg_t *rseg) |
Resurrect the transactions that were doing inserts and updates at the time of a crash, they need to be undone. More... | |
static void | trx_add_to_rw_trx_list (trx_t *trx) |
Adds the transaction to trx_sys->rw_trx_list Requires trx_sys->mutex, unless called in the single threaded startup code. More... | |
static void | trx_remove_from_rw_trx_list (trx_t *trx) |
Removes the transaction from trx_sys->rw_trx_list. More... | |
void | trx_lists_init_at_db_start (void) |
Creates trx objects for transactions and initializes the trx list of trx_sys at database start. More... | |
static trx_rseg_t * | get_next_redo_rseg_from_undo_spaces () |
Get next redo rollback segment in round-robin fashion. More... | |
static trx_rseg_t * | get_next_redo_rseg_from_trx_sys () |
Get the next redo rollback segment in round-robin fashion. More... | |
static trx_rseg_t * | get_next_redo_rseg () |
Get next redo rollback segment in round-robin fashion. More... | |
static trx_rseg_t * | get_next_temp_rseg () |
Get the next noredo rollback segment. More... | |
void | trx_assign_rseg_durable (trx_t *trx) |
Assign a durable rollback segment to a transaction in a round-robin fashion. More... | |
void | trx_assign_rseg_temp (trx_t *trx) |
Assign a temp-tablespace bound rollback-segment to a transaction. More... | |
static void | trx_start_low (trx_t *trx, bool read_write) |
Starts a transaction. More... | |
static bool | trx_add_to_serialisation_list (trx_t *trx) |
Assigns the trx->no and add the transaction to the serialisation_list. More... | |
static void | trx_erase_from_serialisation_list_low (trx_t *trx) |
Erases transaction from the serialisation_list. More... | |
static bool | trx_serialisation_number_get (trx_t *trx, trx_undo_ptr_t *redo_rseg_undo_ptr, trx_undo_ptr_t *temp_rseg_undo_ptr) |
Set the transaction serialisation number. More... | |
static bool | trx_write_serialisation_history (trx_t *trx, mtr_t *mtr) |
Assign the transaction its history serialisation number and write the update UNDO log record to the assigned rollback segment. More... | |
static void | trx_finalize_for_fts_table (fts_trx_table_t *ftt) |
static void | trx_finalize_for_fts (trx_t *trx, bool is_commit) |
Finalize a transaction containing updates to FTS tables. More... | |
static void | trx_flush_log_if_needed_low (lsn_t lsn) |
If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit. More... | |
static void | trx_flush_log_if_needed (lsn_t lsn, trx_t *trx) |
If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit. More... | |
static void | trx_update_mod_tables_timestamp (trx_t *trx) |
For each table that has been modified by the given transaction: update its dict_table_t::update_time with the current timestamp. More... | |
static void | trx_erase_lists (trx_t *trx) |
Erase the transaction from running transaction lists and serialization list. More... | |
static void | trx_commit_in_memory (trx_t *trx, const mtr_t *mtr, bool serialised) |
Commits a transaction in memory. More... | |
void | trx_commit_low (trx_t *trx, mtr_t *mtr) |
Commits a transaction and a mini-transaction. More... | |
void | trx_commit (trx_t *trx) |
Commits a transaction. More... | |
void | trx_cleanup_at_db_startup (trx_t *trx) |
Cleans up a transaction at database startup. More... | |
ReadView * | trx_assign_read_view (trx_t *trx) |
Assigns a read view for a consistent read query. More... | |
void | trx_commit_or_rollback_prepare (trx_t *trx) |
Prepares a transaction for commit/rollback. More... | |
commit_node_t * | trx_commit_node_create (mem_heap_t *heap) |
Creates a commit command node struct. More... | |
que_thr_t * | trx_commit_step (que_thr_t *thr) |
Performs an execution step for a commit type node in a query graph. More... | |
dberr_t | trx_commit_for_mysql (trx_t *trx) |
Does the transaction commit for MySQL. More... | |
void | trx_commit_complete_for_mysql (trx_t *trx) |
If required, flushes the log to disk if we called trx_commit_for_mysql() with trx->flush_log_later == true. More... | |
void | trx_mark_sql_stat_end (trx_t *trx) |
Marks the latest SQL statement ended. More... | |
void | trx_print_low (FILE *f, const trx_t *trx, ulint max_query_len, ulint n_rec_locks, ulint n_trx_locks, ulint heap_size) |
Prints info about a transaction. More... | |
void | trx_print_latched (FILE *f, const trx_t *trx, ulint max_query_len) |
Prints info about a transaction. More... | |
void | trx_print (FILE *f, const trx_t *trx, ulint max_query_len) |
Prints info about a transaction. More... | |
bool | trx_can_be_handled_by_current_thread (const trx_t *trx) |
Determines if trx can be handled by current thread, which is when trx->mysql_thd is nullptr (a "background" trx) or equals current_thd. More... | |
bool | trx_can_be_handled_by_current_thread_or_is_hp_victim (const trx_t *trx) |
Determines if trx can be handled by current thread, which is when trx->mysql_thd is nullptr (a "background" trx) or equals current_thd, or is a victim being killed by HP transaction run by the current thread. More... | |
bool | trx_assert_started (const trx_t *trx) |
Asserts that a transaction has been started. More... | |
void | trx_before_mutex_enter (const trx_t *trx, bool first_of_two) |
Verifies the invariants and records debug state related to latching rules. More... | |
void | trx_before_mutex_exit (const trx_t *trx) |
Verifies the invariants and records debug state related to latching rules. More... | |
bool | trx_weight_ge (const trx_t *a, const trx_t *b) |
Compares the "weight" (or size) of two transactions. More... | |
static lsn_t | trx_prepare_low (trx_t *trx, trx_undo_ptr_t *undo_ptr, bool noredo_logging) |
Prepares a transaction for given rollback segment. More... | |
bool | trx_is_mysql_xa (const trx_t *trx) |
Check if transaction is internal XA transaction. More... | |
static void | trx_prepare (trx_t *trx) |
Prepares a transaction. More... | |
static lsn_t | trx_set_prepared_in_tc_low (trx_t *trx, trx_undo_ptr_t *undo_ptr) |
Sets the transaction as prepared in the transaction coordinator for the given rollback segment. More... | |
static void | trx_set_prepared_in_tc (trx_t *trx) |
Marks a transaction as prepared in the transaction coordinator. More... | |
dberr_t | trx_prepare_for_mysql (trx_t *trx) |
Does the transaction prepare for MySQL. More... | |
static bool | get_table_name_info (st_handler_tablename *table, const dict_table_t *dd_table, MEM_ROOT *mem_root) |
Get the table name and database name for the given dd_table object. More... | |
static bool | get_info_about_prepared_transaction (XA_recover_txn *txn_list, const trx_t *trx, MEM_ROOT *mem_root) |
Get prepared transaction info from InnoDB data structure. More... | |
int | trx_recover_for_mysql (XA_recover_txn *txn_list, ulint len, MEM_ROOT *mem_root) |
This function is used to find number of prepared transactions and their transaction objects for a recovery. More... | |
int | trx_recover_tc_for_mysql (Xa_state_list &xa_list) |
Find prepared transactions that are marked as prepared in TC, for recovery purposes. More... | |
static trx_t * | trx_get_trx_by_xid_low (const XID *xid) |
This function is used to find one X/Open XA distributed transaction which is in the prepared state. More... | |
trx_t * | trx_get_trx_by_xid (const XID *xid) |
This function is used to find one X/Open XA distributed transaction which is in the prepared state. More... | |
void | trx_start_if_not_started_xa_low (trx_t *trx, bool read_write) |
Starts the transaction if it is not yet started. More... | |
void | trx_start_if_not_started_low (trx_t *trx, bool read_write) |
Starts the transaction if it is not yet started. More... | |
void | trx_start_internal_low (trx_t *trx) |
Starts a transaction for internal processing. More... | |
void | trx_start_internal_read_only_low (trx_t *trx) |
Starts a read-only transaction for internal processing. More... | |
void | trx_set_rw_mode (trx_t *trx) |
Set the transaction as a read-write transaction if it is not already tagged as such. More... | |
void | trx_kill_blocking (trx_t *trx) |
If this is a high priority transaction, kill all transactions that are blocking this transaction from acquiring locks. More... | |
THD * | thd_get_current_thd () |
Get current THD object from thread local data. More... | |
void | trx_sys_update_binlog_position (trx_t *trx) |
Update transaction binlog file name and position from session THD. More... | |
bool | trx_is_prepared_in_tc (trx_t const *trx) |
Checks whether or not the transaction has been marked as prepared in TC. More... | |
dberr_t | trx_set_prepared_in_tc_for_mysql (trx_t *trx) |
Does the 2nd phase of an XA transaction prepare for MySQL. More... | |
Variables | |
static const ulint | MAX_DETAILED_ERROR_LEN = 256 |
static trx_table_map | resurrected_trx_tables |
Map of resurrected transactions to affected table_id. More... | |
std::vector< std::pair< trx_id_t, table_id_t > > | to_rollback_trx_tables |
sess_t * | trx_dummy_sess = nullptr |
Dummy session used currently in MySQL interface. More... | |
static trx_pools_t * | trx_pools |
The trx_t pool manager. More... | |
static const ulint | MAX_TRX_BLOCK_SIZE = 1024 * 1024 * 4 |
Size of on trx_t pool in bytes. More... | |
static thread_local const trx_t * | trx_first_latched_trx = nullptr |
static thread_local int32_t | trx_latched_count = 0 |
static thread_local bool | trx_allowed_two_latches = false |
The transaction.
Created 3/26/1996 Heikki Tuuri
typedef std::set<table_id_t, std::less<table_id_t>, ut::allocator<table_id_t> > table_id_set |
Set of table_id.
typedef Pool<trx_t, TrxFactory, TrxPoolLock> trx_pool_t |
Use explicit mutexes for the trx_t pool and its manager.
typedef PoolManager<trx_pool_t, TrxPoolManagerLock> trx_pools_t |
typedef std::map<trx_t *, table_id_set, std::less<trx_t *>, ut::allocator<std::pair<trx_t *const, table_id_set> > > trx_table_map |
Map of transactions to affected table_id.
|
static |
Get prepared transaction info from InnoDB data structure.
[in,out] | txn_list | Handler layer transaction list. |
[in] | trx | Innodb transaction info. |
[in] | mem_root | Mem_root for space allocation. |
true | Error, e.g. Memory allocation failure. |
false | Success |
|
static |
Get next redo rollback segment in round-robin fashion.
We assume that the assigned slots are not contiguous and have gaps.
|
static |
Get the next redo rollback segment in round-robin fashion.
The assigned slots may have gaps but the vector does not.
|
static |
Get next redo rollback segment in round-robin fashion.
While InnoDB is running in multi-threaded mode, the vectors of undo tablespaces and rsegs do not shrink. So they do not need protection to get a pointer to an rseg. If an rseg is not marked for undo tablespace truncation, we assign it to a transaction. We increment trx_ref_count to keep the purge thread from truncating the undo tablespace that contains this rseg until the transaction is done with it.
|
static |
Get the next noredo rollback segment.
|
static |
Get the table name and database name for the given dd_table object.
[in,out] | table | Handler table name object pointer. |
[in] | dd_table | Pointer table name DD object. |
[in] | mem_root | Mem_root for space allocation. |
true | Error, e.g. Memory allocation failure. |
false | Success |
THD * thd_get_current_thd | ( | ) |
Get current THD object from thread local data.
The | THD object for the thread, NULL if not connection thread |
|
inlinestatic |
Adds the transaction to trx_sys->rw_trx_list Requires trx_sys->mutex, unless called in the single threaded startup code.
[in] | trx | The transaction assumed to not be in the rw_trx_list yet |
|
inlinestatic |
Assigns the trx->no and add the transaction to the serialisation_list.
Skips adding to the serialisation_list if the transaction is read-only, in which case still the trx->no is assigned.
[in,out] | trx | the modified transaction |
trx_t * trx_allocate_for_background | ( | void | ) |
Creates a transaction object for background operations by the master thread.
trx_t * trx_allocate_for_mysql | ( | void | ) |
Creates a transaction object for MySQL.
bool trx_assert_started | ( | const trx_t * | trx | ) |
Asserts that a transaction has been started.
The caller must hold trx_sys->mutex.
trx | in: transaction |
Assigns a read view for a consistent read query.
All the consistent reads within the same transaction will get the same read view, which is created when this function is first called for a new started transaction.
trx | in/out: active transaction |
void trx_assign_rseg_durable | ( | trx_t * | trx | ) |
Assign a durable rollback segment to a transaction in a round-robin fashion.
[in,out] | trx | transaction that involves a durable write. |
void trx_assign_rseg_temp | ( | trx_t * | trx | ) |
Assign a temp-tablespace bound rollback-segment to a transaction.
[in,out] | trx | transaction that involves write to temp-table. |
void trx_before_mutex_enter | ( | const trx_t * | trx, |
bool | allow_another | ||
) |
Verifies the invariants and records debug state related to latching rules.
Called during trx_mutex_enter before the actual mutex acquisition.
[in] | trx | The transaction for which trx_mutex_enter(trx) is called |
[in] | allow_another | If false, then no further calls to trx_mutex_enter are allowed, until trx_mutex_exit(). If true, then this must be the first trx acquisition and we will allow one more. |
void trx_before_mutex_exit | ( | const trx_t * | trx | ) |
Verifies the invariants and records debug state related to latching rules.
Called during trx_mutex_exit before the actual mutex release.
[in] | trx | The transaction for which trx_mutex_exit(trx) is called |
bool trx_can_be_handled_by_current_thread | ( | const trx_t * | trx | ) |
Determines if trx can be handled by current thread, which is when trx->mysql_thd is nullptr (a "background" trx) or equals current_thd.
[in] | trx | The transaction to check |
bool trx_can_be_handled_by_current_thread_or_is_hp_victim | ( | const trx_t * | trx | ) |
Determines if trx can be handled by current thread, which is when trx->mysql_thd is nullptr (a "background" trx) or equals current_thd, or is a victim being killed by HP transaction run by the current thread.
[in] | trx | The transaction to check |
void trx_cleanup_at_db_startup | ( | trx_t * | trx | ) |
Cleans up a transaction at database startup.
The cleanup is needed if the transaction already got to the middle of a commit when the database crashed, and we cannot roll it back.
trx | in: transaction |
void trx_clear_resurrected_table_ids | ( | ) |
Clear all resurrected table IDs.
Needs to be called after all tables locks are resurrected.
void trx_commit | ( | trx_t * | trx | ) |
Commits a transaction.
in/out: transaction
trx | in/out: transaction |
void trx_commit_complete_for_mysql | ( | trx_t * | trx | ) |
If required, flushes the log to disk if we called trx_commit_for_mysql() with trx->flush_log_later == true.
in/out: transaction
trx | in/out: transaction |
Does the transaction commit for MySQL.
trx | in/out: transaction |
Commits a transaction in memory.
trx | in/out: transaction |
mtr | in: mini-transaction of trx_write_serialisation_history(), or NULL if the transaction did not modify anything |
serialised | in: true if serialisation log was written |
Commits a transaction and a mini-transaction.
[in,out] | trx | Transaction |
[in,out] | mtr | Mini-transaction (will be committed), or null if trx made no modifications |
commit_node_t * trx_commit_node_create | ( | mem_heap_t * | heap | ) |
Creates a commit command node struct.
heap | in: mem heap where created |
void trx_commit_or_rollback_prepare | ( | trx_t * | trx | ) |
Prepares a transaction for commit/rollback.
in/out: transaction
trx | in/out: transaction |
Performs an execution step for a commit type node in a query graph.
thr | in: query thread |
|
static |
|
inline |
Disconnect a transaction from MySQL.
[in,out] | trx | transaction |
[in] | prepared | boolean value to specify whether trx is in TRX_STATE_PREPARED state (such as after XA PREPARE) and we want to unlink it from the mysql_thd object, so it can potentially be linked to another session in future. |
|
inline |
Disconnect a transaction from MySQL.
[in,out] | trx | transaction |
void trx_disconnect_prepared | ( | trx_t * | trx | ) |
Disconnect a prepared transaction from MySQL.
[in,out] | trx | transaction |
|
inlinestatic |
Erases transaction from the serialisation_list.
Caller must have acquired trx_sys->serialisation_mutex prior to calling this function.
[in,out] | trx | the transaction to erase |
|
static |
Erase the transaction from running transaction lists and serialization list.
Active RW transaction list of a MVCC snapshot(ReadView::prepare) won't include this transaction after this call. All implicit locks are also released by this call as trx is removed from rw_trx_list.
[in] | trx | Transaction to erase, must have an ID > 0 |
|
static |
Finalize a transaction containing updates to FTS tables.
trx | in/out: transaction |
is_commit | in: true if the transaction was committed, false if it was rolled back. |
|
static |
If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit.
lsn | in: lsn up to which logs are to be flushed. |
trx | in/out: transaction |
|
static |
If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit.
lsn | in: lsn up to which logs are to be flushed. |
Tests the durability settings and flushes logs if needed.
[in,out] | trx | the transaction to flush the logs for. |
[in] | lsn | the identifier of the transaction to flush. |
|
static |
Release a trx_t instance back to the pool.
trx | the instance to release. |
void trx_free_for_background | ( | trx_t * | trx | ) |
Free a transaction that was allocated by background or user threads.
[in,out] | trx | transaction object to free |
void trx_free_for_mysql | ( | trx_t * | trx | ) |
Free a transaction object for MySQL.
[in,out] | trx | transaction |
void trx_free_prepared_or_active_recovered | ( | trx_t * | trx | ) |
At shutdown, frees a transaction object that represents either:
[in,out] | trx | transaction object to free |
void trx_free_resurrected | ( | trx_t * | trx | ) |
Free and initialize a transaction object instantiated during recovery.
[in,out] | trx | transaction object to free and initialize |
This function is used to find one X/Open XA distributed transaction which is in the prepared state.
[in] | xid | X/Open XA transaction identifier |
This function is used to find one X/Open XA distributed transaction which is in the prepared state.
xid | in: X/Open XA transaction identifier |
|
static |
Initialize transaction object.
trx | trx to initialize |
bool trx_is_mysql_xa | ( | const trx_t * | trx | ) |
Check if transaction is internal XA transaction.
[in] | trx | transaction |
bool trx_is_prepared_in_tc | ( | trx_t const * | trx | ) |
Checks whether or not the transaction has been marked as prepared in TC.
[in] | trx | the transaction |
void trx_kill_blocking | ( | trx_t * | trx | ) |
If this is a high priority transaction, kill all transactions that are blocking this transaction from acquiring locks.
[in,out] | trx | High priority transaction |
Kill the transactions in the lock acquisition order old -> new.
void trx_lists_init_at_db_start | ( | void | ) |
Creates trx objects for transactions and initializes the trx list of trx_sys at database start.
Rollback segments and undo log lists must already exist when this function is called, because the lists of transactions to be rolled back or cleaned up are built based on the undo log lists.
void trx_mark_sql_stat_end | ( | trx_t * | trx | ) |
Marks the latest SQL statement ended.
in: trx handle
trx | in: trx handle |
void trx_pool_close | ( | ) |
Destroy the trx_t pool.
void trx_pool_init | ( | ) |
Create the trx_t pool.
|
static |
Prepares a transaction.
[in] | trx | the transction to prepare. |
Does the transaction prepare for MySQL.
[in,out] | trx | Transaction instance to prepare |
|
static |
Prepares a transaction for given rollback segment.
trx | in/out: transaction |
undo_ptr | in/out: pointer to rollback segment scheduled for prepare. |
noredo_logging | in: turn-off redo logging. |
Prints info about a transaction.
Acquires and releases lock_sys exclusive global latch and trx_sys->mutex.
[in] | f | output stream |
[in] | trx | transaction |
[in] | max_query_len | max query length to print, must be positive |
Prints info about a transaction.
The caller must hold lock_sys exclusive global latch and trx_sys->mutex.
[in] | f | output stream |
[in] | trx | transaction |
[in] | max_query_len | max query length to print, must be positive |
void trx_print_low | ( | FILE * | f, |
const trx_t * | trx, | ||
ulint | max_query_len, | ||
ulint | n_rec_locks, | ||
ulint | n_trx_locks, | ||
ulint | heap_size | ||
) |
Prints info about a transaction.
Caller must hold trx_sys->mutex.
f | in: output stream |
trx | in: transaction |
max_query_len | in: max query length to print, must be positive |
n_rec_locks | in: lock_number_of_rows_locked(&trx->lock) |
n_trx_locks | in: length of trx->lock.trx_locks |
heap_size | in: mem_heap_get_size(trx->lock.lock_heap) |
int trx_recover_for_mysql | ( | XA_recover_txn * | txn_list, |
ulint | len, | ||
MEM_ROOT * | mem_root | ||
) |
This function is used to find number of prepared transactions and their transaction objects for a recovery.
txn_list | in/out: prepared transactions |
len | in: number of slots in xid_list |
mem_root | in: memory for table names |
int trx_recover_tc_for_mysql | ( | Xa_state_list & | xa_list | ) |
Find prepared transactions that are marked as prepared in TC, for recovery purposes.
[in,out] | xa_list | prepared transactions state |
|
static |
|
inlinestatic |
Removes the transaction from trx_sys->rw_trx_list.
Requires trx_sys->mutex, unless called in the single threaded startup code.
[in] | trx | The transaction assumed to be in the rw_trx_list |
|
static |
Resurrect the transactions that were doing inserts and updates at the time of a crash, they need to be undone.
[in] | rseg | rollback segment |
|
static |
Resurrect the transactions that were doing inserts at the time of the crash, they need to be undone.
undo | in: entry to UNDO |
rseg | in: rollback segment |
void trx_resurrect_locks | ( | bool | all | ) |
Resurrect table locks for resurrected transactions.
[in] | all | false: resurrect locks for dictionary transactions, true : resurrect locks for all transactions. |
|
static |
Resurrect the table IDs for a resurrected transaction.
[in] | trx | resurrected transaction |
[in] | undo_ptr | pointer to undo segment |
[in] | undo | undo log |
|
static |
Resurrect the transactions that were doing updates the time of the crash, they need to be undone.
trx | in/out: transaction |
undo | in/out: update UNDO record |
rseg | in/out: rollback segment |
|
static |
Prepared transactions are left in the prepared state waiting for a commit or abort decision from MySQL.
trx | in,out: transaction |
undo | in: update UNDO record |
|
static |
Set the transaction serialisation number.
trx | in/out: transaction |
redo_rseg_undo_ptr | in/out: Set trx serialisation number in referred undo rseg. |
temp_rseg_undo_ptr | in/out: Set trx serialisation number in referred undo rseg. |
void trx_set_detailed_error | ( | trx_t * | trx, |
const char * | msg | ||
) |
Set detailed error message for the transaction.
[in] | trx | Transaction struct |
[in] | msg | Detailed error message |
void trx_set_detailed_error_from_file | ( | trx_t * | trx, |
FILE * | file | ||
) |
Set detailed error message for the transaction from a file.
Note that the file is rewinded before reading from it.
trx | in: transaction struct |
file | in: file to read message from |
void trx_set_flush_observer | ( | trx_t * | trx, |
Flush_observer * | observer | ||
) |
Set flush observer for the transaction.
[in,out] | trx | transaction struct |
[in] | observer | flush observer |
|
static |
Marks a transaction as prepared in the transaction coordinator.
[in] | trx | the transction to mark. |
Does the 2nd phase of an XA transaction prepare for MySQL.
[in,out] | trx | Transaction instance to finish prepare |
|
static |
Sets the transaction as prepared in the transaction coordinator for the given rollback segment.
[in,out] | trx | The rollback segment parent transaction. |
[in] | undo_ptr | The rollback segment. |
void trx_set_rw_mode | ( | trx_t * | trx | ) |
Set the transaction as a read-write transaction if it is not already tagged as such.
Read-only transactions that are writing to temporary tables are assigned an ID and a rollback segment but are not added to the trx read-write list because their updates should not be visible to other transactions and therefore their changes can be ignored by by MVCC.
trx | in/out: transaction that is RW |
void trx_start_if_not_started_low | ( | trx_t * | trx, |
bool | read_write | ||
) |
Starts the transaction if it is not yet started.
[in] | trx | Transaction |
[in] | read_write | True if read write transaction |
void trx_start_if_not_started_xa_low | ( | trx_t * | trx, |
bool | read_write | ||
) |
Starts the transaction if it is not yet started.
[in,out] | trx | Transaction |
[in] | read_write | True if read write transaction |
void trx_start_internal_low | ( | trx_t * | trx | ) |
Starts a transaction for internal processing.
in/out: transaction
trx | in/out: transaction |
void trx_start_internal_read_only_low | ( | trx_t * | trx | ) |
Starts a read-only transaction for internal processing.
[in,out] | trx | transaction to be started |
|
static |
Starts a transaction.
trx | in: transaction |
read_write | in: true if read-write transaction |
void trx_sys_update_binlog_position | ( | trx_t * | trx | ) |
Update transaction binlog file name and position from session THD.
[in,out] | trx | current transaction. |
|
static |
For each table that has been modified by the given transaction: update its dict_table_t::update_time with the current timestamp.
Clear the list of the modified tables at the end.
trx | in: transaction |
|
static |
Check state of transaction before freeing it.
[in,out] | trx | transaction object to validate |
Compares the "weight" (or size) of two transactions.
Transactions that have edited non-transactional tables are considered heavier than ones that have not.
a | in: transaction to be compared |
b | in: transaction to be compared |
Assign the transaction its history serialisation number and write the update UNDO log record to the assigned rollback segment.
trx | in/out: transaction |
mtr | in/out: mini-transaction |
|
static |
|
static |
Size of on trx_t pool in bytes.
|
static |
Map of resurrected transactions to affected table_id.
std::vector<std::pair<trx_id_t, table_id_t> > to_rollback_trx_tables |
|
static |
|
static |
|
static |
The trx_t pool manager.