MySQL  8.0.12
Source Code Documentation
trx0trx.cc File Reference

The transaction. More...

#include <sys/types.h>
#include <time.h>
#include <new>
#include <set>
#include <sql_thd_internal_api.h>
#include "btr0sea.h"
#include "dict0dd.h"
#include "fsp0sysspace.h"
#include "ha_prototypes.h"
#include "lock0lock.h"
#include "log0log.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.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"

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, TrxPoolLocktrx_pool_t
 Use explicit mutexes for the trx_t pool and its manager. More...
 
typedef PoolManager< trx_pool_t, TrxPoolManagerLocktrx_pools_t
 

Functions

void trx_set_flush_observer (trx_t *trx, FlushObserver *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_ttrx_create_low ()
 
static void trx_free (trx_t *&trx)
 Release a trx_t instance back to the pool. More...
 
trx_ttrx_allocate_for_background (void)
 Creates a transaction object for background operations by the master thread. More...
 
trx_ttrx_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 (trx_t *trx)
 At shutdown, frees a transaction object that is in the PREPARED state. More...
 
void trx_disconnect_from_mysql (trx_t *trx, bool prepared)
 Disconnect a transaction from MySQL and optionally mark it as if it's been recovered. 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 ()
 Resurrect table locks for resurrected transactions. More...
 
static trx_ttrx_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...
 
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_tget_next_redo_rseg_from_undo_spaces (ulong target_undo_tablespaces)
 Get next redo rollback segment in round-robin fashion. More...
 
static trx_rseg_tget_next_redo_rseg_from_trx_sys ()
 Get the next redo rollback segment in round-robin fashion. More...
 
static trx_rseg_tget_next_redo_rseg ()
 Get next redo rollback segment in round-robin fashion. More...
 
static trx_rseg_tget_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_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, bool serialised)
 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...
 
ReadViewtrx_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_ttrx_commit_node_create (mem_heap_t *heap)
 Creates a commit command node struct. More...
 
que_thr_ttrx_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...
 
ibool trx_assert_started (const trx_t *trx)
 Asserts that a transaction has been started. 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...
 
static void trx_prepare (trx_t *trx)
 Prepares a transaction. More...
 
dberr_t trx_prepare_for_mysql (trx_t *trx)
 Does the transaction prepare for MySQL. More...
 
int trx_recover_for_mysql (XID *xid_list, ulint len)
 This function is used to find number of prepared transactions and their transaction objects for a recovery. More...
 
static trx_ttrx_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_ttrx_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)
 Kill all transactions that are blocking this transaction from acquiring locks. 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...
 
sess_ttrx_dummy_sess = NULL
 Dummy session used currently in MySQL interface. More...
 
static trx_pools_ttrx_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...
 

Detailed Description

The transaction.

Created 3/26/1996 Heikki Tuuri

Typedef Documentation

◆ table_id_set

Set of table_id.

◆ trx_pool_t

Use explicit mutexes for the trx_t pool and its manager.

◆ trx_pools_t

◆ trx_table_map

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.

Function Documentation

◆ get_next_redo_rseg()

static trx_rseg_t* get_next_redo_rseg ( )
static

Get next redo rollback segment in round-robin fashion.

We assume that the assigned slots are not contiguous and have gaps.

Returns
assigned rollback segment instance

◆ get_next_redo_rseg_from_trx_sys()

static trx_rseg_t* get_next_redo_rseg_from_trx_sys ( )
static

Get the next redo rollback segment in round-robin fashion.

The assigned slots may have gaps but the vector does not.

Returns
assigned rollback segment instance

◆ get_next_redo_rseg_from_undo_spaces()

static trx_rseg_t* get_next_redo_rseg_from_undo_spaces ( ulong  target_undo_tablespaces)
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.

Parameters
[in]target_undo_tablespacesnumber of undo tablespaces to use when calculating which rseg to assign.
Returns
assigned rollback segment instance

◆ get_next_temp_rseg()

static trx_rseg_t* get_next_temp_rseg ( )
static

Get the next noredo rollback segment.

Returns
assigned rollback segment instance

◆ trx_allocate_for_background()

trx_t* trx_allocate_for_background ( void  )

Creates a transaction object for background operations by the master thread.

Returns
own: transaction object

◆ trx_allocate_for_mysql()

trx_t* trx_allocate_for_mysql ( void  )

Creates a transaction object for MySQL.

Returns
own: transaction object

◆ trx_assert_started()

ibool trx_assert_started ( const trx_t trx)

Asserts that a transaction has been started.

The caller must hold trx_sys->mutex.

Returns
true if started
Parameters
trxin: transaction

◆ trx_assign_read_view()

ReadView* trx_assign_read_view ( trx_t trx)

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.

Returns
consistent read view
Parameters
trxin/out: active transaction

◆ trx_assign_rseg_durable()

void trx_assign_rseg_durable ( trx_t trx)

Assign a durable rollback segment to a transaction in a round-robin fashion.

Parameters
[in,out]trxtransaction that involves a durable write.

◆ trx_assign_rseg_temp()

void trx_assign_rseg_temp ( trx_t trx)

Assign a temp-tablespace bound rollback-segment to a transaction.

Parameters
[in,out]trxtransaction that involves write to temp-table.

◆ trx_cleanup_at_db_startup()

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.

Parameters
trxin: transaction

◆ trx_commit()

void trx_commit ( trx_t trx)

Commits a transaction.

Parameters
trxin/out: transaction

◆ trx_commit_complete_for_mysql()

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.

Parameters
trxin/out: transaction

◆ trx_commit_for_mysql()

dberr_t trx_commit_for_mysql ( trx_t trx)

Does the transaction commit for MySQL.

Returns
DB_SUCCESS or error number
Parameters
trxin/out: transaction

◆ trx_commit_in_memory()

static void trx_commit_in_memory ( trx_t trx,
const mtr_t mtr,
bool  serialised 
)
static

Commits a transaction in memory.

Parameters
trxin/out: transaction
mtrin: mini-transaction of trx_write_serialisation_history(), or NULL if the transaction did not modify anything
serialisedin: true if serialisation log was written

◆ trx_commit_low()

void trx_commit_low ( trx_t trx,
mtr_t mtr 
)

Commits a transaction and a mini-transaction.

Parameters
trxin/out: transaction
mtrin/out: mini-transaction (will be committed), or NULL if trx made no modifications

◆ trx_commit_node_create()

commit_node_t* trx_commit_node_create ( mem_heap_t heap)

Creates a commit command node struct.

Returns
own: commit node struct
Parameters
heapin: mem heap where created

◆ trx_commit_or_rollback_prepare()

void trx_commit_or_rollback_prepare ( trx_t trx)

Prepares a transaction for commit/rollback.

Parameters
trxin/out: transaction

◆ trx_commit_step()

que_thr_t* trx_commit_step ( que_thr_t thr)

Performs an execution step for a commit type node in a query graph.

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

◆ trx_create_low()

static trx_t* trx_create_low ( )
static
Returns
a trx_t instance from trx_pools.

◆ trx_disconnect_from_mysql()

void trx_disconnect_from_mysql ( trx_t trx,
bool  prepared 
)
inline

Disconnect a transaction from MySQL and optionally mark it as if it's been recovered.

For the marking the transaction must be in prepared state. The recovery-marked transaction is going to survive "alone" so its association with the mysql handle is destroyed now rather than when it will be finally freed.

Parameters
[in,out]trxtransaction
[in]preparedboolean value to specify whether trx is for recovery or not.

◆ trx_disconnect_plain()

void trx_disconnect_plain ( trx_t trx)
inline

Disconnect a transaction from MySQL.

Parameters
[in,out]trxtransaction

◆ trx_disconnect_prepared()

void trx_disconnect_prepared ( trx_t trx)

Disconnect a prepared transaction from MySQL.

Parameters
[in,out]trxtransaction

◆ trx_erase_lists()

static void trx_erase_lists ( trx_t trx,
bool  serialised 
)
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.

Parameters
[in]trxTransaction to erase, must have an ID > 0
[in]serialisedtrue if serialisation log was written

◆ trx_finalize_for_fts()

static void trx_finalize_for_fts ( trx_t trx,
bool  is_commit 
)
static

Finalize a transaction containing updates to FTS tables.

Parameters
trxin/out: transaction
is_commitin: true if the transaction was committed, false if it was rolled back.

◆ trx_finalize_for_fts_table()

static void trx_finalize_for_fts_table ( fts_trx_table_t ftt)
static

◆ trx_flush_log_if_needed()

static void trx_flush_log_if_needed ( lsn_t  lsn,
trx_t trx 
)
static

If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit.

Parameters
lsnin: lsn up to which logs are to be flushed.
trxin/out: transaction

◆ trx_flush_log_if_needed_low()

static void trx_flush_log_if_needed_low ( lsn_t  lsn)
static

If required, flushes the log to disk based on the value of innodb_flush_log_at_trx_commit.

Parameters
lsnin: lsn up to which logs are to be flushed.

◆ trx_free()

static void trx_free ( trx_t *&  trx)
static

Release a trx_t instance back to the pool.

Parameters
trxthe instance to release.

◆ trx_free_for_background()

void trx_free_for_background ( trx_t trx)

Free a transaction that was allocated by background or user threads.

Parameters
[in,out]trxtransaction object to free

◆ trx_free_for_mysql()

void trx_free_for_mysql ( trx_t trx)

Free a transaction object for MySQL.

Parameters
[in,out]trxtransaction

◆ trx_free_prepared()

void trx_free_prepared ( trx_t trx)

At shutdown, frees a transaction object that is in the PREPARED state.

Parameters
trxin, own: trx object

◆ trx_free_resurrected()

void trx_free_resurrected ( trx_t trx)

Free and initialize a transaction object instantiated during recovery.

Parameters
[in,out]trxtransaction object to free and initialize

◆ trx_get_trx_by_xid()

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.

Returns
trx or NULL; on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex
Parameters
xidin: X/Open XA transaction identifier

◆ trx_get_trx_by_xid_low()

static trx_t* trx_get_trx_by_xid_low ( const XID xid)
static

This function is used to find one X/Open XA distributed transaction which is in the prepared state.

Returns
trx on match, the trx->xid will be invalidated; note that the trx may have been committed, unless the caller is holding lock_sys->mutex
Parameters
xidin: X/Open XA transaction identifier

◆ trx_init()

static void trx_init ( trx_t trx)
static

Initialize transaction object.

Parameters
trxtrx to initialize

◆ trx_kill_blocking()

void trx_kill_blocking ( trx_t trx)

Kill all transactions that are blocking this transaction from acquiring locks.

Parameters
[in,out]trxHigh priority transaction

Kill the transactions in the lock acquisition order old -> new.

◆ trx_lists_init_at_db_start()

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.

◆ trx_mark_sql_stat_end()

void trx_mark_sql_stat_end ( trx_t trx)

Marks the latest SQL statement ended.

Parameters
trxin: trx handle

◆ trx_pool_close()

void trx_pool_close ( )

Destroy the trx_t pool.

◆ trx_pool_init()

void trx_pool_init ( )

Create the trx_t pool.

◆ trx_prepare()

static void trx_prepare ( trx_t trx)
static

Prepares a transaction.

Parameters
trxin/out: transaction

◆ trx_prepare_for_mysql()

dberr_t trx_prepare_for_mysql ( trx_t trx)

Does the transaction prepare for MySQL.

Parameters
[in,out]trxTransaction instance to prepare

◆ trx_prepare_low()

static lsn_t trx_prepare_low ( trx_t trx,
trx_undo_ptr_t undo_ptr,
bool  noredo_logging 
)
static

Prepares a transaction for given rollback segment.

Returns
lsn_t: lsn assigned for commit of scheduled rollback segment
Parameters
trxin/out: transaction
undo_ptrin/out: pointer to rollback segment scheduled for prepare.
noredo_loggingin: turn-off redo logging.

◆ trx_print()

void trx_print ( FILE *  f,
const trx_t trx,
ulint  max_query_len 
)

Prints info about a transaction.

Acquires and releases lock_sys->mutex and trx_sys->mutex.

Parameters
fin: output stream
trxin: transaction
max_query_lenin: max query length to print, or 0 to use the default max length

◆ trx_print_latched()

void trx_print_latched ( FILE *  f,
const trx_t trx,
ulint  max_query_len 
)

Prints info about a transaction.

The caller must hold lock_sys->mutex and trx_sys->mutex. When possible, use trx_print() instead.

Parameters
fin: output stream
trxin: transaction
max_query_lenin: max query length to print, or 0 to use the default max length

◆ trx_print_low()

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.

Parameters
fin: output stream
trxin: transaction
max_query_lenin: max query length to print, or 0 to use the default max length
n_rec_locksin: lock_number_of_rows_locked(&trx->lock)
n_trx_locksin: length of trx->lock.trx_locks
heap_sizein: mem_heap_get_size(trx->lock.lock_heap)

◆ trx_recover_for_mysql()

int trx_recover_for_mysql ( XID xid_list,
ulint  len 
)

This function is used to find number of prepared transactions and their transaction objects for a recovery.

Returns
number of prepared transactions stored in xid_list
Parameters
xid_listin/out: prepared transactions
lenin: number of slots in xid_list

◆ trx_resurrect()

static void trx_resurrect ( trx_rseg_t rseg)
static

Resurrect the transactions that were doing inserts and updates at the time of a crash, they need to be undone.

Parameters
[in]rsegrollback segment

◆ trx_resurrect_insert()

static trx_t* trx_resurrect_insert ( trx_undo_t undo,
trx_rseg_t rseg 
)
static

Resurrect the transactions that were doing inserts at the time of the crash, they need to be undone.

Returns
trx_t instance
Parameters
undoin: entry to UNDO
rsegin: rollback segment

◆ trx_resurrect_locks()

void trx_resurrect_locks ( )

Resurrect table locks for resurrected transactions.

◆ trx_resurrect_table_ids()

static void trx_resurrect_table_ids ( trx_t trx,
const trx_undo_ptr_t undo_ptr,
const trx_undo_t undo 
)
static

Resurrect the table IDs for a resurrected transaction.

Parameters
[in]trxresurrected transaction
[in]undo_ptrpointer to undo segment
[in]undoundo log

◆ trx_resurrect_update()

static void trx_resurrect_update ( trx_t trx,
trx_undo_t undo,
trx_rseg_t rseg 
)
static

Resurrect the transactions that were doing updates the time of the crash, they need to be undone.

Parameters
trxin/out: transaction
undoin/out: update UNDO record
rsegin/out: rollback segment

◆ trx_resurrect_update_in_prepared_state()

static void trx_resurrect_update_in_prepared_state ( trx_t trx,
const trx_undo_t undo 
)
static

Prepared transactions are left in the prepared state waiting for a commit or abort decision from MySQL.

Parameters
trxin,out: transaction
undoin: update UNDO record

◆ trx_serialisation_number_get()

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 
)
static

Set the transaction serialisation number.

Returns
true if the transaction number was added to the serialisation_list.
Parameters
trxin/out: transaction
redo_rseg_undo_ptrin/out: Set trx serialisation number in referred undo rseg.
temp_rseg_undo_ptrin/out: Set trx serialisation number in referred undo rseg.

◆ trx_set_detailed_error()

void trx_set_detailed_error ( trx_t trx,
const char *  msg 
)

Set detailed error message for the transaction.

Parameters
trxin: transaction struct
msgin: detailed error message

◆ trx_set_detailed_error_from_file()

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.

Parameters
trxin: transaction struct
filein: file to read message from

◆ trx_set_flush_observer()

void trx_set_flush_observer ( trx_t trx,
FlushObserver observer 
)

Set flush observer for the transaction.

Parameters
[in,out]trxtransaction struct
[in]observerflush observer

◆ trx_set_rw_mode()

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.

Parameters
trxin/out: transaction that is RW

◆ trx_start_if_not_started_low()

void trx_start_if_not_started_low ( trx_t trx,
bool  read_write 
)

Starts the transaction if it is not yet started.

Parameters
trxin: transaction
read_writein: true if read write transaction

◆ trx_start_if_not_started_xa_low()

void trx_start_if_not_started_xa_low ( trx_t trx,
bool  read_write 
)

Starts the transaction if it is not yet started.

Parameters
trxin/out: transaction
read_writein: true if read write transaction

◆ trx_start_internal_low()

void trx_start_internal_low ( trx_t trx)

Starts a transaction for internal processing.

Parameters
trxin/out: transaction

◆ trx_start_internal_read_only_low()

void trx_start_internal_read_only_low ( trx_t trx)

Starts a read-only transaction for internal processing.

Parameters
[in,out]trxtransaction to be started

◆ trx_start_low()

static void trx_start_low ( trx_t trx,
bool  read_write 
)
static

Starts a transaction.

Parameters
trxin: transaction
read_writein: true if read-write transaction

◆ trx_update_mod_tables_timestamp()

static void trx_update_mod_tables_timestamp ( trx_t trx)
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.

Parameters
trxin: transaction

◆ trx_validate_state_before_free()

static void trx_validate_state_before_free ( trx_t trx)
static

Check state of transaction before freeing it.

Parameters
[in,out]trxtransaction object to validate

◆ trx_weight_ge()

bool trx_weight_ge ( const trx_t a,
const trx_t b 
)

Compares the "weight" (or size) of two transactions.

Transactions that have edited non-transactional tables are considered heavier than ones that have not.

Returns
true if weight(a) >= weight(b)
Parameters
ain: transaction to be compared
bin: transaction to be compared

◆ trx_write_serialisation_history()

static bool trx_write_serialisation_history ( trx_t trx,
mtr_t mtr 
)
static

Assign the transaction its history serialisation number and write the update UNDO log record to the assigned rollback segment.

Returns
true if a serialisation log was written
Parameters
trxin/out: transaction
mtrin/out: mini-transaction

Variable Documentation

◆ MAX_DETAILED_ERROR_LEN

const ulint MAX_DETAILED_ERROR_LEN = 256
static

◆ MAX_TRX_BLOCK_SIZE

const ulint MAX_TRX_BLOCK_SIZE = 1024 * 1024 * 4
static

Size of on trx_t pool in bytes.

◆ resurrected_trx_tables

trx_table_map resurrected_trx_tables
static

Map of resurrected transactions to affected table_id.

◆ trx_dummy_sess

sess_t* trx_dummy_sess = NULL

Dummy session used currently in MySQL interface.

◆ trx_pools

trx_pools_t* trx_pools
static

The trx_t pool manager.