MySQL 8.0.39
Source Code Documentation
|
Transaction system. More...
#include <sys/types.h>
#include <new>
#include "current_thd.h"
#include "ha_prototypes.h"
#include "mysql/plugin.h"
#include "sql_error.h"
#include "trx0sys.h"
#include "fsp0fsp.h"
#include "fsp0sysspace.h"
#include "log0recv.h"
#include "mtr0log.h"
#include "os0file.h"
#include "read0read.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "trx0purge.h"
#include "trx0rseg.h"
#include "trx0trx.h"
#include "trx0undo.h"
Functions | |
void | trx_sys_write_max_trx_id (void) |
Writes the value of max_trx_id to the file based trx system header. More... | |
void | trx_sys_persist_gtid_num (trx_id_t gtid_trx_no) |
Persist transaction number limit below which all transaction GTIDs are persisted to disk table. More... | |
trx_id_t | trx_sys_oldest_trx_no () |
void | trx_sys_get_binlog_prepared (std::vector< trx_id_t > &trx_ids) |
Get a list of all binlog prepared transactions. More... | |
static bool | read_binlog_position (const byte *binlog_buf, const char *&file_name, uint32_t &high, uint32_t &low) |
Read binary log positions from buffer passed. More... | |
static void | write_binlog_position (const char *file_name, uint64_t offset, byte *binlog_buf, mtr_t *mtr) |
Write binary log position into passed buffer. More... | |
void | trx_sys_read_binlog_position (char *file, uint64_t &offset) |
Get current binary log positions stored. More... | |
static bool | binlog_position_changed (const char *file_name, uint64_t offset, byte *binlog_buf) |
Check if binary log position is changed. More... | |
bool | trx_sys_write_binlog_position (const char *last_file, uint64_t last_offset, const char *file, uint64_t offset) |
Update binary log position if not already updated. More... | |
void | trx_sys_update_mysql_binlog_offset (trx_t *trx, mtr_t *mtr) |
Updates the offset information about the end of the MySQL binlog entry which corresponds to the transaction being committed, external XA transaction being prepared or rolled back. More... | |
page_no_t | trx_sysf_rseg_find_page_no (ulint rseg_id) |
Find the page number in the TRX_SYS page for a given slot/rseg_id. More... | |
ulint | trx_sysf_rseg_find_free (mtr_t *mtr) |
Look for a free slot for a rollback segment in the trx system file copy. More... | |
static void | trx_sysf_create (mtr_t *mtr) |
Creates the file page for the transaction system. More... | |
purge_pq_t * | trx_sys_init_at_db_start (void) |
Creates and initializes the central memory structures for the transaction system. More... | |
void | trx_sys_create (void) |
Creates the trx_sys instance and initializes purge_queue and mutex. More... | |
void | trx_sys_create_sys_pages (void) |
Creates and initializes the transaction system at the database creation. More... | |
void | trx_sys_close (void) |
Shutdown/Close the transaction system. More... | |
void | trx_sys_before_pre_dd_shutdown_validate () |
Validates lists of transactions at the very beginning of the pre-dd-shutdown phase. More... | |
void | trx_sys_after_pre_dd_shutdown_validate () |
Validates lists of transactions at the very end of the pre-dd-shutdown phase. More... | |
void | trx_sys_after_background_threads_shutdown_validate () |
Validates lists of transactions after all background threads of InnoDB exited during shutdown of MySQL. More... | |
size_t | trx_sys_recovered_active_trxs_count () |
Reads number of recovered transactions which have state equal to TRX_STATE_ACTIVE (so are not prepared transactions). More... | |
bool | trx_sys_validate_trx_list () |
Validate the trx_sys_t::rw_trx_list. More... | |
void | trx_sys_undo_spaces_init () |
Initialize trx_sys_undo_spaces, called once during srv_start(). More... | |
void | trx_sys_undo_spaces_deinit () |
Free the resources occupied by trx_sys_undo_spaces, called once during thread de-initialization. More... | |
Variables | |
trx_sys_t * | trx_sys = nullptr |
The transaction system. More... | |
uint | trx_rseg_n_slots_debug = 0 |
const uint32_t | max_rseg_init_threads = 4 |
Space_Ids * | trx_sys_undo_spaces |
A list of undo tablespace IDs found in the TRX_SYS page. More... | |
Transaction system.
Created 3/26/1996 Heikki Tuuri
|
static |
Check if binary log position is changed.
[in] | file_name | previous binary log file name |
[in] | offset | previous binary log file offset |
[out] | binlog_buf | buffer from trx sys page to write to |
|
static |
Read binary log positions from buffer passed.
[in] | binlog_buf | binary log buffer from trx sys page |
[out] | file_name | binary log file name |
[out] | high | offset part high order bytes |
[out] | low | offset part low order bytes |
void trx_sys_after_background_threads_shutdown_validate | ( | ) |
Validates lists of transactions after all background threads of InnoDB exited during shutdown of MySQL.
void trx_sys_after_pre_dd_shutdown_validate | ( | ) |
Validates lists of transactions at the very end of the pre-dd-shutdown phase.
At this point we check the mysql_trx_list again, now we don't expect purge thread transactions in the list
void trx_sys_before_pre_dd_shutdown_validate | ( | ) |
Validates lists of transactions at the very beginning of the pre-dd-shutdown phase.
All connections are closed and close_connection unregisters associated trx from mysql_trx_list. We still might have some non started transactions in mysql_trx_list. Purge threads are an exception, they create their own trx_t objects which are not real transactions but are needed for the purge sys to use the query threads framework. Purge sys shutdown happens at a later point in the shutdown sequence so we need to skip its transactions here. IMPORTANT: If allocating transactions for background threads, please use trx_allocate_for_background. This function does not add the trx to the mysql_trx_list so we don't have to add logic to skip these at shutdown.
Skip purge thread trx, it will be cleared after purge sys shutdown
void trx_sys_close | ( | void | ) |
Shutdown/Close the transaction system.
void trx_sys_create | ( | void | ) |
Creates the trx_sys instance and initializes purge_queue and mutex.
void trx_sys_create_sys_pages | ( | void | ) |
Creates and initializes the transaction system at the database creation.
void trx_sys_get_binlog_prepared | ( | std::vector< trx_id_t > & | trx_ids | ) |
Get a list of all binlog prepared transactions.
[out] | trx_ids | all prepared transaction IDs. |
purge_pq_t * trx_sys_init_at_db_start | ( | void | ) |
Creates and initializes the central memory structures for the transaction system.
This is called when the database is started.
trx_id_t trx_sys_oldest_trx_no | ( | ) |
void trx_sys_persist_gtid_num | ( | trx_id_t | gtid_trx_no | ) |
Persist transaction number limit below which all transaction GTIDs are persisted to disk table.
[in] | gtid_trx_no | transaction number |
void trx_sys_read_binlog_position | ( | char * | file, |
uint64_t & | offset | ||
) |
Get current binary log positions stored.
[out] | file | binary log file name |
[out] | offset | binary log file offset |
size_t trx_sys_recovered_active_trxs_count | ( | ) |
Reads number of recovered transactions which have state equal to TRX_STATE_ACTIVE (so are not prepared transactions).
void trx_sys_undo_spaces_deinit | ( | ) |
Free the resources occupied by trx_sys_undo_spaces, called once during thread de-initialization.
void trx_sys_undo_spaces_init | ( | ) |
Initialize trx_sys_undo_spaces, called once during srv_start().
Updates the offset information about the end of the MySQL binlog entry which corresponds to the transaction being committed, external XA transaction being prepared or rolled back.
In a MySQL replication slave updates the latest master binlog position up to which replication has proceeded.
[in] | trx | Current transaction |
[in,out] | mtr | Mini-transaction for update |
bool trx_sys_validate_trx_list | ( | ) |
Validate the trx_sys_t::rw_trx_list.
bool trx_sys_write_binlog_position | ( | const char * | last_file, |
uint64_t | last_offset, | ||
const char * | file, | ||
uint64_t | offset | ||
) |
Update binary log position if not already updated.
This is called by clone to update any stale binary log position if any transaction is yet to update the binary log position in SE.
[in] | last_file | last noted binary log file name |
[in] | last_offset | last noted binary log offset |
[in] | file | current binary log file name |
[in] | offset | current binary log file offset |
void trx_sys_write_max_trx_id | ( | void | ) |
Writes the value of max_trx_id to the file based trx system header.
|
static |
Creates the file page for the transaction system.
This function is called only at the database creation, before trx_sys_init.
mtr | in: mtr |
Look for a free slot for a rollback segment in the trx system file copy.
[in,out] | mtr | mtr |
Find the page number in the TRX_SYS page for a given slot/rseg_id.
[in] | rseg_id | slot number in the TRX_SYS page rseg array |
|
static |
Write binary log position into passed buffer.
[in] | file_name | Binary log file name |
[in] | offset | Binary log offset |
[out] | binlog_buf | Buffer from trx sys page to write to |
[in,out] | mtr | Mini-transaction |
const uint32_t max_rseg_init_threads = 4 |
uint trx_rseg_n_slots_debug = 0 |
Space_Ids* trx_sys_undo_spaces |
A list of undo tablespace IDs found in the TRX_SYS page.
These are the old type of undo tablespaces that do not have space_IDs in the reserved range nor contain an RSEG_ARRAY page. This cannot be part of the trx_sys_t object because it must be built before that is initialized.