49#define TRX_ID_FMT IB_ID_FMT
315 std::ostream &
print(std::ostream &out)
const {
316 out <<
"[trx_rseg_t: this=" << (
void *)
this <<
", id=" <<
id
324 return (rseg.
print(out));
327using Rsegs_Vector = std::vector<trx_rseg_t *, ut::allocator<trx_rseg_t *>>;
335#ifndef UNIV_HOTBACKUP
341#ifndef UNIV_HOTBACKUP
601 for (
size_t i = 0; i < append_from.
m_rsegs_n; ++i) {
628typedef std::priority_queue<
629 TrxUndoRsegs, std::vector<TrxUndoRsegs, ut::allocator<TrxUndoRsegs>>,
633typedef std::vector<trx_id_t, ut::allocator<trx_id_t>>
trx_ids_t;
642typedef std::vector<TrxVersion, ut::allocator<TrxVersion>>
hit_list_t;
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:52
uint32_t page_no_t
Page number.
Definition: api0api.h:50
This is a wrapper for a std::vector of trx_rseg_t object pointers.
Definition: trx0types.h:331
~Rsegs()
Definition: trx0types.h:340
void set_empty()
Set the state of the undo tablespace to empty so that it can be dropped.
Definition: trx0types.h:450
void set_inactive_implicit()
Set the state of the rollback segments in this undo tablespace to inactive_implicit.
Definition: trx0types.h:438
rw_lock_t * m_latch
RW lock to protect m_rsegs vector, m_active, and each trx_rseg_t::trx_ref_count within it.
Definition: trx0types.h:466
trx_rseg_t * find(ulint rseg_id)
Find an rseg in the std::vector that uses the rseg_id given.
Definition: trx0rseg.cc:776
void clear()
Clear the vector of cached rollback segments leaving the reserved space allocated.
Definition: trx0rseg.cc:764
Rsegs_Vector m_rsegs
std::vector of rollback segments
Definition: trx0types.h:457
void push_back(trx_rseg_t *rseg)
Add rollback segment.
Definition: trx0types.h:358
void set_active()
Set the state of the rollback segments in this undo tablespace to ACTIVE for use by new transactions.
Definition: trx0types.h:431
void s_lock()
Acquire the shared lock on m_rsegs.
Definition: trx0types.h:395
bool is_empty()
Return whether the undo tablespace is empty and ready to be dropped.
Definition: trx0types.h:423
undo_space_states m_state
The current state of this undo tablespace.
Definition: trx0types.h:546
Rseg_Iterator end()
ending iterator
Definition: trx0types.h:370
Rsegs()
Default constructor.
Definition: trx0types.h:334
void sort()
Sort the vector on trx_rseg_t::id.
Definition: trx0types.h:384
bool is_init()
Return whether the undo tablespace is being initialized.
Definition: trx0types.h:427
bool is_inactive_implicit()
Return whether the undo tablespace is inactive due to implicit selection by the purge thread.
Definition: trx0types.h:413
bool is_inactive_explicit()
Return whether the undo tablespace was made inactive by ALTER TABLESPACE.
Definition: trx0types.h:418
ulint size()
Number of registered rsegs.
Definition: trx0types.h:362
void s_unlock()
Release the shared lock on m_rsegs.
Definition: trx0types.h:398
void set_inactive_explicit()
Make the undo tablespace inactive so that it will not be used for new transactions.
Definition: trx0types.h:446
bool is_active()
Return whether the undo tablespace is active.
Definition: trx0types.h:408
Rseg_Iterator begin()
beginning iterator
Definition: trx0types.h:366
void x_unlock()
Release the exclusive lock on m_rsegs.
Definition: trx0types.h:404
undo_space_states
Definition: trx0types.h:537
@ EMPTY
Definition: trx0types.h:542
@ INACTIVE_IMPLICIT
Definition: trx0types.h:540
@ INIT
Definition: trx0types.h:538
@ ACTIVE
Definition: trx0types.h:539
@ INACTIVE_EXPLICIT
Definition: trx0types.h:541
void deinit()
De-initialize.
Definition: trx0rseg.cc:754
void x_lock()
Acquire the exclusive lock on m_rsegs.
Definition: trx0types.h:401
trx_rseg_t * at(ulint slot)
Find the rseg at the given slot in this vector.
Definition: trx0types.h:375
void init()
Initialize.
Definition: trx0rseg.cc:744
Rollback segments from a given transaction with trx-no scheduled for purge.
Definition: trx0types.h:554
TrxUndoRsegs(trx_id_t trx_no)
Definition: trx0types.h:556
trx_id_t get_trx_no() const
Get transaction number.
Definition: trx0types.h:569
Rsegs_array< 2 > m_rsegs
Rollback segments of a transaction, scheduled for purge.
Definition: trx0types.h:625
size_t size() const
Number of registered rsegs.
Definition: trx0types.h:585
Rsegs_array< 2 >::iterator end()
Definition: trx0types.h:593
trx_id_t m_trx_no
Compiler defined copy-constructor/assignment operator should be fine given that there is no reference...
Definition: trx0types.h:620
size_t m_rsegs_n
Definition: trx0types.h:622
Rsegs_array< 2 >::iterator begin()
Definition: trx0types.h:589
bool operator()(const TrxUndoRsegs &lhs, const TrxUndoRsegs &rhs)
Compare two TrxUndoRsegs based on trx_no.
Definition: trx0types.h:610
void set_trx_no(trx_id_t trx_no)
Definition: trx0types.h:565
void insert(const TrxUndoRsegs &append_from)
Append rollback segments from referred instance to current instance.
Definition: trx0types.h:599
TrxUndoRsegs()
Default constructor.
Definition: trx0types.h:563
void insert(trx_rseg_t *rseg)
Add rollback segment.
Definition: trx0types.h:573
Page size descriptor.
Definition: page0size.h:50
constexpr uint32_t FSP_TRX_SYS_PAGE_NO
transaction system header, in tablespace 0
Definition: fsp0types.h:170
A class describing a page size.
Definition: trx0types.h:635
uint64_t m_version
Definition: trx0types.h:639
TrxVersion(trx_t *trx)
Constructor.
Definition: trx0trx.cc:97
trx_t * m_trx
Definition: trx0types.h:638
Commit command node in a query graph.
Definition: trx0trx.h:1337
Rollback command node in a query graph.
Definition: trx0roll.h:156
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:360
Used to identify trx uniquely over time.
Definition: trx0types.h:177
bool operator==(const trx_guid_t &rhs) const
Checks if two guids represent the same transaction: they refer to the same trx_t struct and it was no...
Definition: trx0types.h:203
trx_guid_t()=default
Initializes trx_guid_t object to a value which doesn't match any real transaction.
uint64_t m_version
As trx_t objects and thus immutable ids can be reused we need also trx's version, which is incremente...
Definition: trx0types.h:188
uint64_t m_immutable_id
The immutable id of trx_t object - if you have a pointer to trx_t then we guarantee that immutable id...
Definition: trx0types.h:184
Latching protocol for trx_lock_t::que_state.
Definition: trx0trx.h:401
A savepoint set with SQL's "SAVEPOINT savepoint_id" command.
Definition: trx0roll.h:168
The control structure used in the purge operation.
Definition: trx0purge.h:986
The rollback segment memory object.
Definition: trx0types.h:214
std::ostream & print(std::ostream &out) const
Definition: trx0types.h:315
trx_id_t last_trx_no
Transaction number of the last not yet purged log.
Definition: trx0types.h:307
Undo_list insert_undo_list
List of insert undo logs.
Definition: trx0types.h:292
size_t last_offset
Byte offset of the last not yet purged log header.
Definition: trx0types.h:304
bool last_del_marks
true if the last not yet purged log needs purging
Definition: trx0types.h:310
page_no_t get_curr_size() const
Definition: trx0types.h:248
void set_curr_size(page_no_t npages)
Definition: trx0types.h:252
RsegMutex mutex
mutex protecting the fields in this struct except id,space,page_no which are constant
Definition: trx0types.h:261
space_id_t space_id
space ID where the rollback segment header is placed
Definition: trx0types.h:264
void decr_curr_size(page_no_t npages=1)
Decrement the current size of the rollback segment by the given number of pages.
Definition: trx0types.h:237
page_no_t curr_size
current size in pages
Definition: trx0types.h:277
page_no_t page_no
page number of the rollback segment header
Definition: trx0types.h:267
page_size_t page_size
page size of the relevant tablespace
Definition: trx0types.h:270
Undo_list update_undo_cached
List of update undo log segments cached for fast reuse.
Definition: trx0types.h:287
std::atomic< size_t > trx_ref_count
Reference counter to track rseg allocated transactions.
Definition: trx0types.h:313
page_no_t max_size
maximum allowed size in pages
Definition: trx0types.h:273
void incr_curr_size()
Increment the current size of the rollback segment by the given number of pages.
Definition: trx0types.h:244
bool validate_curr_size(bool take_mutex=true)
Validate the curr_size member by re-calculating it.
Definition: trx0rseg.cc:1171
page_no_t last_page_no
Page number of the last not yet purged log header in the history list; FIL_NULL if all list purged.
Definition: trx0types.h:301
UT_LIST_BASE_NODE_T_EXTERN(trx_undo_t, undo_list) Undo_list
Definition: trx0types.h:280
Undo_list update_undo_list
List of update undo logs.
Definition: trx0types.h:284
Undo_list insert_undo_cached
List of insert undo log segments cached for fast reuse.
Definition: trx0types.h:295
void unlatch()
Exit the rseg->mutex.
Definition: trx0types.h:229
void latch()
Enter the rseg->mutex.
Definition: trx0types.h:223
Transaction savepoint.
Definition: trx0types.h:148
undo_no_t least_undo_no
least undo number to undo
Definition: trx0types.h:149
The transaction system central memory data structure.
Definition: trx0sys.h:453
Definition: trx0trx.h:675
Transaction undo log memory object; this is protected by the undo_mutex in the corresponding transact...
Definition: trx0undo.h:339
The read-write lock (for threads, not for database transactions)
static void rw_lock_s_unlock(rw_lock_t *L)
Definition: sync0rw.h:792
static void rw_lock_x_lock(rw_lock_t *M, ut::Location L)
Definition: sync0rw.h:766
static void rw_lock_s_lock(rw_lock_t *M, ut::Location L)
Definition: sync0rw.h:715
static void rw_lock_x_unlock(rw_lock_t *L)
Definition: sync0rw.h:795
static const uint32_t TRX_FORCE_ROLLBACK_MASK
For masking out the above flags.
Definition: trx0types.h:68
ib_mutex_t TrxMutex
Definition: trx0types.h:171
std::vector< trx_rseg_t *, ut::allocator< trx_rseg_t * > > Rsegs_Vector
Definition: trx0types.h:327
byte trx_undo_rec_t
Undo log record.
Definition: trx0types.h:167
Rsegs_Vector::iterator Rseg_Iterator
Definition: trx0types.h:328
trx_state_t
Transaction states (trx_t::state)
Definition: trx0types.h:80
@ TRX_STATE_FORCED_ROLLBACK
Same as not started but with additional semantics that it was rolled back asynchronously the last tim...
Definition: trx0types.h:86
@ TRX_STATE_ACTIVE
Definition: trx0types.h:88
@ TRX_STATE_COMMITTED_IN_MEMORY
Definition: trx0types.h:93
@ TRX_STATE_NOT_STARTED
Definition: trx0types.h:82
@ TRX_STATE_PREPARED
Support for 2PC/XA.
Definition: trx0types.h:91
constexpr trx_id_t TRX_ID_MAX
Maximum transaction identifier.
Definition: trx0types.h:145
static const ulint TRX_MAGIC_N
Random value to check for corruption of trx_t.
Definition: trx0types.h:58
trx_que_t
Transaction execution states when trx->state == TRX_STATE_ACTIVE.
Definition: trx0types.h:71
@ TRX_QUE_LOCK_WAIT
transaction is waiting for a lock
Definition: trx0types.h:73
@ TRX_QUE_RUNNING
transaction is running
Definition: trx0types.h:72
@ TRX_QUE_COMMITTING
transaction is committing
Definition: trx0types.h:76
@ TRX_QUE_ROLLING_BACK
transaction is rolling back
Definition: trx0types.h:75
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 row_id_t
Row identifier (DB_ROW_ID, DATA_ROW_ID)
Definition: trx0types.h:132
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:142
byte trx_upagef_t
Undo log page header.
Definition: trx0types.h:165
byte trx_usegf_t
Undo segment header.
Definition: trx0types.h:161
std::ostream & operator<<(std::ostream &out, const trx_rseg_t &rseg)
Definition: trx0types.h:323
byte trx_rsegsf_t
Rollback segment array header.
Definition: trx0types.h:157
static const uint32_t TRX_FORCE_ROLLBACK
Mark the transaction for forced rollback.
Definition: trx0types.h:65
byte trx_ulogf_t
Undo log header.
Definition: trx0types.h:163
std::array< trx_rseg_t *, N > Rsegs_array
Definition: trx0types.h:550
ib_mutex_t PQMutex
Definition: trx0types.h:173
byte trx_rsegf_t
Rollback segment header.
Definition: trx0types.h:159
ib_mutex_t RsegMutex
Definition: trx0types.h:170
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138
constexpr uint32_t TRX_SYS_PAGE_NO
Page number of the transaction system page.
Definition: trx0types.h:55
byte trx_sysf_t
File objects.
Definition: trx0types.h:155
static const uint32_t TRX_FORCE_ROLLBACK_DISABLE
If this flag is set then the transaction cannot be rolled back asynchronously.
Definition: trx0types.h:62
ib_mutex_t UndoMutex
Definition: trx0types.h:172
std::vector< TrxVersion, ut::allocator< TrxVersion > > hit_list_t
Definition: trx0types.h:642
static const space_id_t TRX_SYS_SPACE
Space id of the transaction system page (the system tablespace)
Definition: trx0types.h:52
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:140
ib_mutex_t TrxSysMutex
Definition: trx0types.h:174
trx_dict_op_t
Type of data dictionary operation.
Definition: trx0types.h:97
@ TRX_DICT_OP_TABLE
The transaction is creating a table or an index, or dropping a table.
Definition: trx0types.h:104
@ TRX_DICT_OP_NONE
The transaction is not modifying the data dictionary.
Definition: trx0types.h:99
@ TRX_DICT_OP_INDEX
The transaction is creating or dropping an index in an existing table.
Definition: trx0types.h:108
uint64_t ib_id_t
The generic InnoDB system object identifier data type.
Definition: univ.i:443
unsigned long int ulint
Definition: univ.i:406
constexpr ib_id_t IB_ID_MAX
Definition: univ.i:444
Utilities for byte operations.
#define UT_LOCATION_HERE
Definition: ut0core.h:47
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:69
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:57
#define UT_LIST_BASE_NODE_T_EXTERN(t, m)
A variant of UT_LIST_BASE_NODE_T to be used in rare cases where the full definition of t is not yet i...
Definition: ut0lst.h:279
#define mutex_exit(M)
Definition: ut0mutex.h:123
#define mutex_enter(M)
Definition: ut0mutex.h:117
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...