53#include <unordered_map> 
  146#ifndef UNIV_HOTBACKUP 
  194                                   const char *
file, uint64_t offset);
 
  266#define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000) 
  279#define TRX_SYS_TRX_NUM_GTID \ 
  280  (TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME + TRX_SYS_MYSQL_LOG_NAME_LEN) 
  281#define TRX_SYS_TRX_NUM_END (TRX_SYS_TRX_NUM_GTID + 8) 
  285#define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200) 
  315#define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE 
  330    return (it != 
end());
 
  347#ifndef UNIV_HOTBACKUP 
  355  using By_id = std::unordered_map<trx_id_t, trx_t *, Trx_track_hash>;
 
  577        const auto val = lower_bound.load();
 
  583          best_bound = 
std::max(best_bound, val);
 
  598    const auto it = 
m_by_id.find(trx_id);
 
  611    if (trx_id < 
m_min_id.load(std::memory_order_relaxed)) {
 
  630    if (
m_min_id.load(std::memory_order_relaxed) == trx_id) {
 
  657        ut_a(new_min <= some_id);
 
  660        while (
m_by_id.count(new_min) == 0) {
 
  663        m_min_id.store(new_min, std::memory_order_release);
 
  792  template <
typename F>
 
  797          return std::forward<F>(f)(trx_by_id_with_min.
get(trx_id));
 
  805#ifndef UNIV_HOTBACKUP 
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:48
 
uint32_t page_no_t
Page number.
Definition: api0api.h:46
 
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
 
The database buffer pool high-level routines.
 
The MVCC read view manager.
Definition: read0read.h:44
 
Read view lists the trx ids of those transactions for which a consistent read should not see the modi...
Definition: read0types.h:48
 
This is a wrapper for a std::vector of trx_rseg_t object pointers.
Definition: trx0types.h:331
 
List of undo tablespace IDs.
Definition: trx0sys.h:319
 
void sort()
Definition: trx0sys.h:321
 
bool contains(space_id_t id)
Definition: trx0sys.h:323
 
iterator find(space_id_t id)
Definition: trx0sys.h:333
 
Definition: trx0sys.h:348
 
std::atomic< trx_id_t > m_min_id
For observers which use Trx_shard::mutex protection: each transaction id in the m_by_id is guaranteed...
Definition: trx0sys.h:364
 
trx_t * get(trx_id_t trx_id) const
Definition: trx0sys.h:597
 
static std::atomic< trx_id_t > s_lower_bound[2]
A "lower bound" is a value which is guaranteed to be smaller or equal than any id in any of the shard...
Definition: trx0sys.h:541
 
By_id const & by_id() const
Definition: trx0sys.h:595
 
trx_id_t min_id() const
Definition: trx0sys.h:596
 
static constexpr trx_id_t UPDATING_LOWER_BOUND
Definition: trx0sys.h:542
 
static trx_id_t get_better_lower_bound_for_already_active_id()
Definition: trx0sys.cc:65
 
static std::atomic< bool > s_updating_lower_bound
This is used during get_better_lower_bound_for_already_active_id() to announce that it is trying to e...
Definition: trx0sys.h:550
 
static trx_id_t get_cheap_lower_bound_for_already_active_id()
Returns a value which is lower or equal to id of any transaction for which insert(id) happened before...
Definition: trx0sys.h:569
 
void erase(trx_id_t trx_id)
Definition: trx0sys.h:627
 
static void limit_to(std::atomic< trx_id_t > &a, trx_id_t upper_bound)
Performs an equivalent of if(upper_bound < a) a=upper_bound atomically, ignoring, but preserving the ...
Definition: trx0sys.h:555
 
void insert(trx_t &trx)
Definition: trx0sys.h:607
 
std::unordered_map< trx_id_t, trx_t *, Trx_track_hash > By_id
Definition: trx0sys.h:355
 
By_id m_by_id
Definition: trx0sys.h:356
 
Page identifier.
Definition: buf0types.h:207
 
The low-level file system.
 
constexpr uint32_t FSEG_PAGE_DATA
On a page of any file segment, data may be put starting from this offset.
Definition: fsp0types.h:79
 
constexpr uint32_t FSEG_HEADER_SIZE
Length of the file system header, in bytes.
Definition: fsp0types.h:94
 
#define F
Definition: jit_executor_value.cc:374
 
Container::const_iterator find(const Container &c, Value &&value)
Definition: generic.h:39
 
ValueType max(X &&first)
Definition: gtid.h:103
 
const char * begin(const char *const c)
Definition: base64.h:44
 
size_t size(const char *const c)
Definition: base64.h:46
 
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
 
constexpr size_t INNODB_CACHE_LINE_SIZE
CPU cache line size.
Definition: ut0cpu_cache.h:41
 
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2880
 
required string key
Definition: replication_asynchronous_connection_failover.proto:60
 
Definition: trx0sys.h:349
 
size_t operator()(const trx_id_t &key) const
Definition: trx0sys.h:350
 
Shard for subset of transactions.
Definition: trx0sys.h:670
 
ut::Cacheline_padded< ut::Guarded< Trx_by_id_with_min, LATCH_ID_TRX_SYS_SHARD > > active_rw_trxs
Mapping from trx->id to trx of active rw transactions.
Definition: trx0sys.h:675
 
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:177
 
The transaction system central memory data structure.
Definition: trx0sys.h:679
 
UT_LIST_BASE_NODE_T(trx_t, no_list) serialisation_list
Tracks minimal transaction id which has received trx->no, but has not yet finished commit for the mtr...
 
TrxSysMutex serialisation_mutex
Mutex to protect serialisation_list.
Definition: trx0sys.h:725
 
char pad3[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:737
 
UT_LIST_BASE_NODE_T(trx_t, mysql_trx_list) mysql_trx_list
List of transactions created for MySQL.
 
UT_LIST_BASE_NODE_T(trx_t, trx_list) rw_trx_list
List of active and committed in memory read-write transactions, sorted on trx id, biggest first.
 
std::atomic< trx_id_t > next_trx_id_or_no
The smallest number not yet assigned as a transaction id or transaction number.
Definition: trx0sys.h:715
 
std::atomic< uint64_t > rseg_history_len
Length of the TRX_RSEG_HISTORY list (update undo logs for committed transactions).
Definition: trx0sys.h:697
 
auto latch_and_execute_with_active_trx(trx_id_t trx_id, F &&f, const ut::Location &loc)
Definition: trx0sys.h:793
 
std::atomic< trx_id_t > serialisation_min_trx_no
Definition: trx0sys.h:741
 
char pad7[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:774
 
char pad2[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:720
 
trx_id_t rw_max_trx_no
Max trx number of read-write transactions added for purge.
Definition: trx0sys.h:734
 
Rsegs tmp_rsegs
Vector of pointers to rollback segments within the temp tablespace; This vector is created and destro...
Definition: trx0sys.h:693
 
char pad4[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:746
 
char pad1[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:702
 
bool found_prepared_trx
True if XA PREPARED trxs are found.
Definition: trx0sys.h:783
 
MVCC * mvcc
Multi version concurrency control manager.
Definition: trx0sys.h:687
 
Trx_shard & get_shard_by_trx_id(trx_id_t trx_id)
Definition: trx0sys.h:789
 
Trx_shard shards[TRX_SHARDS_N]
Mapping from transaction id to transaction instance.
Definition: trx0sys.h:777
 
char pad5[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:753
 
ulint n_prepared_trx
Number of transactions currently in the XA PREPARED state.
Definition: trx0sys.h:780
 
TrxSysMutex mutex
Mutex protecting most fields in this structure (the default one).
Definition: trx0sys.h:751
 
char pad0[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:681
 
char pad_after[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:787
 
char pad6[ut::INNODB_CACHE_LINE_SIZE]
Definition: trx0sys.h:759
 
trx_ids_t rw_trx_ids
Array of Read write transaction IDs for MVCC snapshot.
Definition: trx0sys.h:772
 
Definition: trx0trx.h:675
 
trx_id_t id
transaction id
Definition: trx0trx.h:727
 
A utility wrapper class, which adds padding at the end of the wrapped structure, so that the next obj...
Definition: ut0cpu_cache.h:55
 
constexpr size_t TRX_SHARDS_N
Number of shards created for transactions.
Definition: trx0sys.h:337
 
constexpr trx_id_t TRX_SYS_TRX_ID_WRITE_MARGIN
When a trx id which is zero modulo this number (which must be a power of two) is assigned,...
Definition: trx0sys.h:810
 
static void trx_sysf_rseg_set_page_no(trx_sysf_t *sys_header, ulint i, page_no_t page_no, mtr_t *mtr)
Set the page number of the nth rollback segment slot in the trx system file copy.
 
constexpr uint32_t TRX_SYS_MYSQL_LOG_NAME
MySQL log file name.
Definition: trx0sys.h:275
 
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 trans...
Definition: trx0sys.cc:363
 
constexpr uint32_t TRX_SYS_MYSQL_LOG_OFFSET_HIGH
high 4 bytes of the offset within that file
Definition: trx0sys.h:271
 
size_t trx_get_shard_no(trx_id_t trx_id)
Computes shard number for a given trx_id.
Definition: trx0sys.h:342
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_MAGIC
4-byte magic number which shows if we already have created the doublewrite buffer
Definition: trx0sys.h:291
 
static bool trx_sys_hdr_page(const page_id_t &page_id)
Checks if a page address is the trx sys header page.
 
static void trx_sys_mutex_exit()
Release the trx_sys->mutex.
Definition: trx0sys.h:816
 
static void trx_write_trx_id(byte *ptr, trx_id_t id)
Writes a trx id to an index page.
 
void trx_sys_get_binlog_prepared(std::vector< trx_id_t > &trx_ids)
Get a list of all binlog prepared transactions.
Definition: trx0sys.cc:211
 
static void trx_sys_serialisation_mutex_exit()
Release the trx_sys->serialisation_mutex.
Definition: trx0sys.h:835
 
void trx_sys_after_pre_dd_shutdown_validate()
Validates lists of transactions at the very end of the pre-dd-shutdown phase.
Definition: trx0sys.cc:720
 
static void trx_sys_serialisation_mutex_enter()
Acquire the trx_sys->serialisation_mutex.
Definition: trx0sys.h:830
 
constexpr uint32_t TRX_SYS_SYSTEM_RSEG_ID
The automatically created system rollback segment has this id.
Definition: trx0sys.h:241
 
static trx_t * trx_rw_is_active(trx_id_t trx_id, bool do_ref_count)
Checks if a rw transaction with the given id is active.
 
static trx_sysf_t * trx_sysf_get(mtr_t *mtr)
Gets a pointer to the transaction system file copy and x-locks its page.
 
void trx_sys_read_binlog_position(char *file, uint64_t &offset)
Get current binary log positions stored.
Definition: trx0sys.cc:295
 
constexpr uint32_t TRX_SYS
The offset of the transaction system header on the page.
Definition: trx0sys.h:244
 
void trx_sys_create(void)
Creates the trx_sys instance and initializes purge_queue and mutex.
Definition: trx0sys.cc:601
 
trx_id_t trx_sys_oldest_trx_no()
Definition: trx0sys.cc:201
 
size_t trx_sys_recovered_active_trxs_count()
Reads number of recovered transactions which have state equal to TRX_STATE_ACTIVE (so are not prepare...
Definition: trx0sys.cc:758
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N
Contents of TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED.
Definition: trx0sys.h:312
 
void trx_sys_before_pre_dd_shutdown_validate()
Validates lists of transactions at the very beginning of the pre-dd-shutdown phase.
Definition: trx0sys.cc:697
 
constexpr uint32_t TRX_SYS_MYSQL_LOG_MAGIC_N
Contents of TRX_SYS_MYSQL_LOG_MAGIC_N_FLD.
Definition: trx0sys.h:262
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_FSEG
fseg header of the fseg containing the doublewrite buffer
Definition: trx0sys.h:288
 
purge_pq_t * trx_sys_init_at_db_start(void)
Creates and initializes the central memory structures for the transaction system.
Definition: trx0sys.cc:481
 
ulint trx_sysf_rseg_find_free(mtr_t *mtr)
Look for a free slot for a rollback segment in the trx system file copy.
Definition: trx0sys.cc:384
 
void trx_sys_close(void)
Shutdown/Close the transaction system.
Definition: trx0sys.cc:644
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_REPEAT
we repeat TRX_SYS_DOUBLEWRITE_MAGIC, TRX_SYS_DOUBLEWRITE_BLOCK1, TRX_SYS_DOUBLEWRITE_BLOCK2 so that i...
Definition: trx0sys.h:301
 
trx_id_t trx_sys_allocate_trx_no()
Allocates a new transaction number (for trx->no).
Definition: trx0sys.ic:231
 
static trx_id_t trx_read_trx_id(const byte *ptr)
Reads a trx id from an index page.
 
static bool trx_sys_need_rollback()
Determine if there are incomplete transactions in the system.
 
bool trx_sys_validate_trx_list()
Validate the trx_sys_t::rw_trx_list.
Definition: trx0sys.cc:775
 
static void trx_sysf_rseg_set_space(trx_sysf_t *sys_header, ulint i, space_id_t space, mtr_t *mtr)
Sets the space id of the nth rollback segment slot in the trx system file copy.
 
static void trx_sys_rw_trx_add(trx_t *trx)
Add the transaction to the RW transaction set.
 
constexpr uint32_t TRX_SYS_MYSQL_LOG_NAME_LEN
Maximum length of MySQL binlog file name, in bytes.
Definition: trx0sys.h:260
 
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.
Definition: trx0sys.cc:347
 
void trx_sys_create_sys_pages(void)
Creates and initializes the transaction system at the database creation.
Definition: trx0sys.cc:632
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_BLOCK1
page number of the first page in the first sequence of 64 (= FSP_EXTENT_SIZE) consecutive pages in th...
Definition: trx0sys.h:294
 
static bool trx_sys_mutex_own()
Test if trx_sys->mutex is owned.
Definition: trx0sys.h:821
 
constexpr uint32_t TRX_SYS_TRX_ID_STORE
Transaction system header.
Definition: trx0sys.h:252
 
void trx_sys_after_background_threads_shutdown_validate()
Validates lists of transactions after all background threads of InnoDB exited during shutdown of MySQ...
Definition: trx0sys.cc:752
 
constexpr uint32_t TRX_SYS_MYSQL_LOG_OFFSET_LOW
low 4 bytes of the offset within that file
Definition: trx0sys.h:273
 
trx_id_t trx_sys_allocate_trx_id()
Allocates a new transaction id (for trx->id).
Definition: trx0sys.ic:226
 
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.
Definition: trx0sys.cc:190
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_MAGIC_N
Contents of TRX_SYS_DOUBLEWRITE_MAGIC.
Definition: trx0sys.h:310
 
static void trx_sys_mutex_enter()
Acquire the trx_sys->mutex.
Definition: trx0sys.h:813
 
static page_no_t trx_sysf_rseg_get_page_no(trx_sysf_t *sys_header, ulint i, mtr_t *mtr)
Gets the page number of the nth rollback segment slot in the trx system file copy.
 
uint trx_rseg_n_slots_debug
Definition: trx0sys.cc:147
 
constexpr uint32_t TRX_SYS_MYSQL_LOG_MAGIC_N_FLD
magic number which is TRX_SYS_MYSQL_LOG_MAGIC_N if we have valid data in the MySQL binlog info
Definition: trx0sys.h:269
 
trx_sys_t * trx_sys
The transaction system.
Definition: trx0sys.cc:60
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_BLOCK2
page number of the first page in the second sequence of 64 consecutive pages in the doublewrite buffe...
Definition: trx0sys.h:297
 
constexpr uint32_t TRX_SYS_FSEG_HEADER
segment header for the tablespace segment the trx system is created into
Definition: trx0sys.h:254
 
constexpr uint32_t TRX_SYS_RSEGS
the start of the array of rollback segment specification slots
Definition: trx0sys.h:256
 
static bool trx_sys_serialisation_mutex_own()
Test if trx_sys->serialisation_mutex is owned.
Definition: trx0sys.h:824
 
trx_id_t trx_sys_get_next_trx_id_or_no()
Retrieves a next value that will be allocated if trx_sys_allocate_trx_id() or trx_sys_allocate_trx_id...
Definition: trx0sys.ic:242
 
constexpr uint32_t TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED
If this is not yet set to TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N, we must reset the doublewrite buffer...
Definition: trx0sys.h:306
 
static bool trx_state_eq(const trx_t *trx, trx_state_t state)
Determines if a transaction is in the given state.
 
Transaction system global type definitions.
 
@ TRX_STATE_COMMITTED_IN_MEMORY
Definition: trx0types.h:93
 
constexpr trx_id_t TRX_ID_MAX
Maximum transaction identifier.
Definition: trx0types.h:145
 
std::priority_queue< TrxUndoRsegs, std::vector< TrxUndoRsegs, ut::allocator< TrxUndoRsegs > >, TrxUndoRsegs > purge_pq_t
Definition: trx0types.h:631
 
std::vector< trx_id_t, ut::allocator< trx_id_t > > trx_ids_t
Definition: trx0types.h:633
 
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138
 
byte trx_sysf_t
File objects.
Definition: trx0types.h:155
 
ib_mutex_t TrxSysMutex
Definition: trx0types.h:174
 
Version control for database, common definitions, and include files.
 
constexpr uint32_t UNIV_PAGE_SIZE_MIN
Minimum page size InnoDB currently supports.
Definition: univ.i:321
 
unsigned long int ulint
Definition: univ.i:406
 
Utilities for byte operations.
 
Utilities related to class lifecycle.
 
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:105
 
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:93
 
The ut::Guarded template which protects access to another class with mutex.
 
#define mutex_enter(M)
Definition: ut0mutex.h:117