MySQL  8.0.19
Source Code Documentation
trx0types.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/trx0types.h
28  Transaction system global type definitions
29 
30  Created 3/26/1996 Heikki Tuuri
31  *******************************************************/
32 
33 #ifndef trx0types_h
34 #define trx0types_h
35 
36 #include "page0size.h"
37 #include "sync0rw.h"
38 #include "ut0byte.h"
39 #include "ut0mutex.h"
40 #include "ut0new.h"
41 
42 #include <atomic>
43 #include <queue>
44 #include <set>
45 #include <vector>
46 
47 //#include <unordered_set>
48 
49 /** printf(3) format used for printing DB_TRX_ID and other system fields */
50 #define TRX_ID_FMT IB_ID_FMT
51 
52 /** maximum length that a formatted trx_t::id could take, not including
53 the terminating NUL character. */
54 static const ulint TRX_ID_MAX_LEN = 17;
55 
56 /** Space id of the transaction system page (the system tablespace) */
57 static const space_id_t TRX_SYS_SPACE = 0;
58 
59 /** Page number of the transaction system page */
60 #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
61 
62 /** Random value to check for corruption of trx_t */
63 static const ulint TRX_MAGIC_N = 91118598;
64 
65 /** If this flag is set then the transaction cannot be rolled back
66 asynchronously. */
67 static const ib_uint32_t TRX_FORCE_ROLLBACK_DISABLE = 1 << 29;
68 
69 /** Was the transaction rolled back asynchronously or by the
70 owning thread. This flag is relevant only if TRX_FORCE_ROLLBACK
71 is set. */
72 static const ib_uint32_t TRX_FORCE_ROLLBACK_ASYNC = 1 << 30;
73 
74 /** Mark the transaction for forced rollback */
75 static const ib_uint32_t TRX_FORCE_ROLLBACK = 1 << 31;
76 
77 /** For masking out the above four flags */
78 static const ib_uint32_t TRX_FORCE_ROLLBACK_MASK = 0x1FFFFFFF;
79 
80 /** Transaction execution states when trx->state == TRX_STATE_ACTIVE */
81 enum trx_que_t {
82  TRX_QUE_RUNNING, /*!< transaction is running */
83  TRX_QUE_LOCK_WAIT, /*!< transaction is waiting for
84  a lock */
85  TRX_QUE_ROLLING_BACK, /*!< transaction is rolling back */
86  TRX_QUE_COMMITTING /*!< transaction is committing */
87 };
88 
89 /** Transaction states (trx_t::state) */
91 
93 
94  /** Same as not started but with additional semantics that it
95  was rolled back asynchronously the last time it was active. */
97 
99 
100  /** Support for 2PC/XA */
102 
104 };
105 
106 /** Type of data dictionary operation */
108  /** The transaction is not modifying the data dictionary. */
110  /** The transaction is creating a table or an index, or
111  dropping a table. The table must be dropped in crash
112  recovery. This and TRX_DICT_OP_NONE are the only possible
113  operation modes in crash recovery. */
115  /** The transaction is creating or dropping an index in an
116  existing table. In crash recovery, the data dictionary
117  must be locked, but the table must not be dropped. */
119 };
120 
121 /** Memory objects */
122 /* @{ */
123 /** Transaction */
124 struct trx_t;
125 /** The locks and state of an active transaction */
126 struct trx_lock_t;
127 /** Transaction system */
128 struct trx_sys_t;
129 /** Signal */
130 struct trx_sig_t;
131 /** Rollback segment */
132 struct trx_rseg_t;
133 /** Transaction undo log */
134 struct trx_undo_t;
135 /** The control structure used in the purge operation */
136 struct trx_purge_t;
137 /** Rollback command node in a query graph */
138 struct roll_node_t;
139 /** Commit command node in a query graph */
140 struct commit_node_t;
141 /** SAVEPOINT command node in a query graph */
143 /* @} */
144 
145 /** Row identifier (DB_ROW_ID, DATA_ROW_ID) */
146 typedef ib_id_t row_id_t;
147 /** Transaction identifier (DB_TRX_ID, DATA_TRX_ID) */
148 typedef ib_id_t trx_id_t;
149 /** Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR) */
150 typedef ib_id_t roll_ptr_t;
151 /** Undo number */
152 typedef ib_id_t undo_no_t;
153 
154 /** Maximum transaction identifier */
155 #define TRX_ID_MAX IB_ID_MAX
156 
157 /** Transaction savepoint */
158 struct trx_savept_t {
159  undo_no_t least_undo_no; /*!< least undo number to undo */
160 };
161 
162 /** File objects */
163 /* @{ */
164 /** Transaction system header */
165 typedef byte trx_sysf_t;
166 /** Rollback segment array header */
167 typedef byte trx_rsegsf_t;
168 /** Rollback segment header */
169 typedef byte trx_rsegf_t;
170 /** Undo segment header */
171 typedef byte trx_usegf_t;
172 /** Undo log header */
173 typedef byte trx_ulogf_t;
174 /** Undo log page header */
175 typedef byte trx_upagef_t;
176 /** Undo log record */
177 typedef byte trx_undo_rec_t;
178 /* @} */
179 
180 typedef ib_mutex_t RsegMutex;
181 typedef ib_mutex_t TrxMutex;
182 typedef ib_mutex_t UndoMutex;
183 typedef ib_mutex_t PQMutex;
184 typedef ib_mutex_t TrxSysMutex;
185 
186 /** The rollback segment memory object */
187 struct trx_rseg_t {
188  /*--------------------------------------------------------*/
189  /** rollback segment id == the index of its slot in the trx
190  system file copy */
191  ulint id;
192 
193  /** mutex protecting the fields in this struct except id,space,page_no
194  which are constant */
196 
197  /** space ID where the rollback segment header is placed */
199 
200  /** page number of the rollback segment header */
202 
203  /** page size of the relevant tablespace */
205 
206  /** maximum allowed size in pages */
207  ulint max_size;
208 
209  /** current size in pages */
210  ulint curr_size;
211 
212  /*--------------------------------------------------------*/
213  /* Fields for update undo logs */
214  /** List of update undo logs */
215  UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_list;
216 
217  /** List of update undo log segments cached for fast reuse */
218  UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_cached;
219 
220  /*--------------------------------------------------------*/
221  /* Fields for insert undo logs */
222  /** List of insert undo logs */
223  UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_list;
224 
225  /** List of insert undo log segments cached for fast reuse */
226  UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_cached;
227 
228  /*--------------------------------------------------------*/
229 
230  /** Page number of the last not yet purged log header in the history
231  list; FIL_NULL if all list purged */
233 
234  /** Byte offset of the last not yet purged log header */
235  ulint last_offset;
236 
237  /** Transaction number of the last not yet purged log */
239 
240  /** TRUE if the last not yet purged log needs purging */
242 
243  /** Reference counter to track rseg allocated transactions. */
244  std::atomic<ulint> trx_ref_count;
245 };
246 
247 using Rsegs_Vector = std::vector<trx_rseg_t *, ut_allocator<trx_rseg_t *>>;
248 using Rseg_Iterator = Rsegs_Vector::iterator;
249 
250 /** This is a wrapper for a std::vector of trx_rseg_t object pointers. */
251 class Rsegs {
252  public:
253  /** Default constructor */
255 #ifndef UNIV_HOTBACKUP
256  init();
257 #endif /* !UNIV_HOTBACKUP */
258  }
259 
260  ~Rsegs() {
261 #ifndef UNIV_HOTBACKUP
262  deinit();
263 #endif /* !UNIV_HOTBACKUP */
264  }
265 
266  /** Initialize */
267  void init();
268 
269  /** De-initialize */
270  void deinit();
271 
272  /** Clear the vector of cached rollback segments leaving the
273  reserved space allocated. */
274  void clear();
275 
276  /** Add rollback segment.
277  @param[in] rseg rollback segment to add. */
278  void push_back(trx_rseg_t *rseg) { m_rsegs.push_back(rseg); }
279 
280  /** Number of registered rsegs.
281  @return size of rseg list. */
282  ulint size() { return (m_rsegs.size()); }
283 
284  /** beginning iterator
285  @return an iterator to the first element */
286  Rseg_Iterator begin() { return (m_rsegs.begin()); }
287 
288  /** ending iterator
289  @return an iterator to the end */
290  Rseg_Iterator end() { return (m_rsegs.end()); }
291 
292  /** Find the rseg at the given slot in this vector.
293  @param[in] slot a slot within the vector.
294  @return an iterator to the end */
295  trx_rseg_t *at(ulint slot) { return (m_rsegs.at(slot)); }
296 
297  /** Find an rseg in the std::vector that uses the rseg_id given.
298  @param[in] rseg_id A slot in a durable array such as
299  the TRX_SYS page or RSEG_ARRAY page.
300  @return a pointer to an trx_rseg_t that uses the rseg_id. */
301  trx_rseg_t *find(ulint rseg_id);
302 
303  /** Sort the vector on trx_rseg_t::id */
304  void sort() {
305  if (m_rsegs.empty()) {
306  return;
307  }
308 
309  std::sort(
310  m_rsegs.begin(), m_rsegs.end(),
311  [](trx_rseg_t *lhs, trx_rseg_t *rhs) { return (rhs->id > lhs->id); });
312  }
313 
314  /** Get a shared lock on m_rsegs. */
316 
317  /** Get a shared lock on m_rsegs. */
319 
320  /** Get a shared lock on m_rsegs. */
322 
323  /** Get a shared lock on m_rsegs. */
325 
326  /** Return whether the undo tablespace is active.
327  @return true if active */
328  bool is_active() { return (m_state == ACTIVE); }
329 
330  /** Return whether the undo tablespace is inactive due to
331  implicit selection by the purge thread.
332  @return true if marked for truncation by the purge thread */
334 
335  /** Return whether the undo tablespace was made inactive by
336  ALTER TABLESPACE.
337  @return true if altered */
339 
340  /** Return whether the undo tablespace is empty and ready
341  to be dropped.
342  @return true if empty */
343  bool is_empty() { return (m_state == EMPTY); }
344 
345  /** Return whether the undo tablespace is being initialized.
346  @return true if empty */
347  bool is_init() { return (m_state == INIT); }
348 
349  /** Set the state of the rollback segments in this undo tablespace
350  to ACTIVE for use by new transactions. */
351  void set_active() { m_state = ACTIVE; }
352 
353  /** Set the state of the rollback segments in this undo
354  tablespace to inactive_implicit. This means that it will be
355  truncated and then made active again by the purge thread.
356  It will not be used for new transactions until it becomes
357  active again. */
361  }
362 
363  /** Make the undo tablespace inactive so that it will not be
364  used for new transactions. The purge thread will clear out
365  all the undo logs, truncate it, and then mark it empty. */
367 
368  /** Set the state of the undo tablespace to empty so that it
369  can be dropped. */
370  void set_empty() {
372  m_state == INIT || m_state == EMPTY);
373  m_state = EMPTY;
374  }
375 
376  /** std::vector of rollback segments */
378 
379  private:
380  /** RW lock to protect m_rsegs vector, m_active, and each
381  trx_rseg_t::trx_ref_count within it.
382  m_rsegs: x for adding elements, s for scanning, size etc.
383  m_active: x for modification, s for read
384  each trx_rseg_t::trx_ref_count within m_rsegs
385  s and atomic increment for modification, x for read */
387 
388  /* The four states of an undo tablespace.
389  INIT: The initial state of an undo space that is being created or opened.
390  ACTIVE: The rollback segments in this tablespace can be allocated to new
391  transactions. The undo tablespace is ready for undo logs.
392  INACTIVE_IMPLICIT: These rollback segments are no longer being used by new
393  transactions. They arre 'inactive'. The truncate process
394  is happening. This undo tablespace was selected by the
395  purge thread implicitly. When the truncation process
396  is complete, the next state is ACTIVE.
397  INACTIVE_EXPLICIT: These rollback segments are no longer being used by new
398  transactions. They arre 'inactive'. The truncate process
399  is happening. This undo tablespace was selected by the
400  an ALTER UNDO TABLESPACE SET INACTIVE command. When the
401  truncation process is complete, the next state is EMPTY.
402  EMPTY: The undo tablespace has been truncated but is no longer
403  active. It is ready to be either dropped or set active
404  explicitly. This state is also used when the undo tablespace and
405  its rollback segments are being inititalized.
406 
407  These states are changed under an exclusive lock on m_latch and are read
408  under a shared lock.
409 
410  The following actions can cause changes in these states:
411  Init: Implicit undo spaces are created at startup.
412  Create: Explicit undo tablespace creation at runtime.
413  Mark: Purge thread implicitly selects an undo space to truncate.
414  SetInactive: This ALTER UNDO TABLESPACE causes an explicit truncation.
415  SetActive: This ALTER UNDO TABLESPACE changes the target state from
416  EMPTY to ACTIVE.
417  Trucate: The truncate process is completed by the purge thread.
418  Drop: Delete an EMPTY undo tablespace
419  Crash: A crash occurs
420  Fixup: At startup, if an undo space was being truncated with a crash.
421  SaveDDState: At startup, once the DD is available the state saved there
422  will be applied. INACTIVE_IMPLICIT is never saved to the DD.
423  So the DD state INACTIVE means INACTIVE_EXPLICIT.
424  See apply_dd_undo_state()
425 
426  State changes allowed: (Actions on states not mentioned are not allowed.)
427  Init from null -> INIT -> ACTIVE see srv_start()
428  from null -> INIT -> EMPTY see trx_rsegs_init()
429  Create from null -> EMPTY -> ACTIVE
430  Mark from INACTIVE_EXPLICIT -> INACTIVE_EXPLICIT -> Truncate
431  from ACTIVE -> INACTIVE_IMPLICIT -> Truncate
432  SetInactive from ACTIVE -> INACTIVE_EXPLICIT -> Mark
433  from INACTIVE_IMPLICIT -> INACTIVE_EXPLICIT
434  from INACTIVE_EXPLICIT -> INACTIVE_EXPLICIT
435  from EMPTY -> EMPTY
436  SetActive from ACTIVE -> ACTIVE
437  from INACTIVE_IMPLICIT -> INACTIVE_IMPLICIT
438  from INACTIVE_EXPLICIT -> INACTIVE_IMPLICIT
439  from EMPTY -> ACTIVE
440  Truncate from INACTIVE_IMPLICIT -> ACTIVE
441  from INACTIVE_EXPLICIT -> EMPTY
442  Drop if ACTIVE -> error returned
443  if INACTIVE_IMPLICIT -> error returned
444  if INACTIVE_EXPLICIT -> error returned
445  from EMPTY -> null
446  Crash if ACTIVE, at startup: ACTIVE
447  if INACTIVE_IMPLICIT, at startup: Fixup
448  if INACTIVE_EXPLICIT, at startup: Fixup
449  if EMPTY, at startup: EMPTY
450  Fixup from INACTIVE_IMPLICIT before crash -> INACTIVE_IMPLICIT -> Mark
451  from INACTIVE_EXPLICIT before crash -> INACTIVE_IMPLICIT -> Mark
452  SaveDDState from ACTIVE before crash -> ACTIVE
453  from INACTIVE_IMPLICIT before crash -> ACTIVE
454  from INACTIVE_EXPLICIT before crash -> INACTIVE_EXPLICIT -> Mark
455  from EMPTY -> EMPTY
456  */
463  };
464 
465  /** The current state of this undo tablespace. */
467 };
468 
469 /** Rollback segements from a given transaction with trx-no
470 scheduled for purge. */
472  public:
473  /** Default constructor */
475 
476  explicit TrxUndoRsegs(trx_id_t trx_no) : m_trx_no(trx_no) {
477  // Do nothing
478  }
479 
480  /** Get transaction number
481  @return trx_id_t - get transaction number. */
482  trx_id_t get_trx_no() const { return (m_trx_no); }
483 
484  /** Add rollback segment.
485  @param rseg rollback segment to add. */
486  void push_back(trx_rseg_t *rseg) { m_rsegs.push_back(rseg); }
487 
488  /** Erase the element pointed by given iterator.
489  @param[in] it iterator */
490  void erase(Rseg_Iterator &it) { m_rsegs.erase(it); }
491 
492  /** Number of registered rsegs.
493  @return size of rseg list. */
494  ulint size() const { return (m_rsegs.size()); }
495 
496  /**
497  @return an iterator to the first element */
498  Rseg_Iterator begin() { return (m_rsegs.begin()); }
499 
500  /**
501  @return an iterator to the end */
502  Rseg_Iterator end() { return (m_rsegs.end()); }
503 
504  /** Append rollback segments from referred instance to current
505  instance. */
506  void append(const TrxUndoRsegs &append_from) {
507  ut_ad(get_trx_no() == append_from.get_trx_no());
508 
509  m_rsegs.insert(m_rsegs.end(), append_from.m_rsegs.begin(),
510  append_from.m_rsegs.end());
511  }
512 
513  /** Compare two TrxUndoRsegs based on trx_no.
514  @param lhs first element to compare
515  @param rhs second element to compare
516  @return true if elem1 > elem2 else false.*/
517  bool operator()(const TrxUndoRsegs &lhs, const TrxUndoRsegs &rhs) {
518  return (lhs.m_trx_no > rhs.m_trx_no);
519  }
520 
521  /** Compiler defined copy-constructor/assignment operator
522  should be fine given that there is no reference to a memory
523  object outside scope of class object.*/
524 
525  private:
526  /** The rollback segments transaction number. */
528 
529  /** Rollback segments of a transaction, scheduled for purge. */
531 };
532 
533 typedef std::priority_queue<
534  TrxUndoRsegs, std::vector<TrxUndoRsegs, ut_allocator<TrxUndoRsegs>>,
535  TrxUndoRsegs>
537 
538 typedef std::vector<trx_id_t, ut_allocator<trx_id_t>> trx_ids_t;
539 
540 /** Mapping read-write transactions from id to transaction instance, for
541 creating read views and during trx id lookup for MVCC and locking. */
542 struct TrxTrack {
543  explicit TrxTrack(trx_id_t id, trx_t *trx = NULL) : m_id(id), m_trx(trx) {
544  // Do nothing
545  }
546 
549 };
550 
551 struct TrxTrackHash {
552  size_t operator()(const TrxTrack &key) const { return (size_t(key.m_id)); }
553 };
554 
555 /**
556 Comparator for TrxMap */
558  bool operator()(const TrxTrack &lhs, const TrxTrack &rhs) const {
559  return (lhs.m_id == rhs.m_id);
560  }
561 };
562 
563 /**
564 Comparator for TrxMap */
565 struct TrxTrackCmp {
566  bool operator()(const TrxTrack &lhs, const TrxTrack &rhs) const {
567  return (lhs.m_id < rhs.m_id);
568  }
569 };
570 
571 // typedef std::unordered_set<TrxTrack, TrxTrackHash, TrxTrackHashCmp> TrxIdSet;
572 typedef std::set<TrxTrack, TrxTrackCmp, ut_allocator<TrxTrack>> TrxIdSet;
573 
574 struct TrxVersion {
575  TrxVersion(trx_t *trx);
576 
578  ulint m_version;
579 };
580 
581 typedef std::vector<TrxVersion, ut_allocator<TrxVersion>> hit_list_t;
582 #endif /* trx0types_h */
page_no_t
uint32 page_no_t
Page number.
Definition: api0api.h:57
trx_sysf_t
byte trx_sysf_t
File objects.
Definition: trx0types.h:165
trx_rseg_t::curr_size
ulint curr_size
current size in pages
Definition: trx0types.h:210
trx_rsegf_t
byte trx_rsegf_t
Rollback segment header.
Definition: trx0types.h:169
trx_rsegsf_t
byte trx_rsegsf_t
Rollback segment array header.
Definition: trx0types.h:167
roll_ptr_t
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:150
Rsegs::is_active
bool is_active()
Return whether the undo tablespace is active.
Definition: trx0types.h:328
TRX_ID_MAX_LEN
static const ulint TRX_ID_MAX_LEN
maximum length that a formatted trx_t::id could take, not including the terminating NUL character.
Definition: trx0types.h:54
Rsegs::set_active
void set_active()
Set the state of the rollback segments in this undo tablespace to ACTIVE for use by new transactions.
Definition: trx0types.h:351
Rsegs::INIT
@ INIT
Definition: trx0types.h:458
TrxUndoRsegs::operator()
bool operator()(const TrxUndoRsegs &lhs, const TrxUndoRsegs &rhs)
Compare two TrxUndoRsegs based on trx_no.
Definition: trx0types.h:517
trx_usegf_t
byte trx_usegf_t
Undo segment header.
Definition: trx0types.h:171
undo_no_t
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:152
trx_undo_t
Transaction undo log memory object; this is protected by the undo_mutex in the corresponding transact...
Definition: trx0undo.h:328
Rsegs::sort
void sort()
Sort the vector on trx_rseg_t::id.
Definition: trx0types.h:304
TrxTrack::m_id
trx_id_t m_id
Definition: trx0types.h:547
NULL
#define NULL
Definition: types.h:55
trx_id_t
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:148
Rsegs::set_inactive_implicit
void set_inactive_implicit()
Set the state of the rollback segments in this undo tablespace to inactive_implicit.
Definition: trx0types.h:358
UndoMutex
ib_mutex_t UndoMutex
Definition: trx0types.h:182
PQMutex
ib_mutex_t PQMutex
Definition: trx0types.h:183
trx_lock_t
Latching protocol for trx_lock_t::que_state.
Definition: trx0trx.h:545
ut_ad
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
Rsegs::set_empty
void set_empty()
Set the state of the undo tablespace to empty so that it can be dropped.
Definition: trx0types.h:370
Rsegs::at
trx_rseg_t * at(ulint slot)
Find the rseg at the given slot in this vector.
Definition: trx0types.h:295
Rsegs::find
trx_rseg_t * find(ulint rseg_id)
Find an rseg in the std::vector that uses the rseg_id given.
Definition: trx0rseg.cc:499
TRX_STATE_PREPARED
@ TRX_STATE_PREPARED
Support for 2PC/XA.
Definition: trx0types.h:101
trx_rseg_t::mutex
RsegMutex mutex
mutex protecting the fields in this struct except id,space,page_no which are constant
Definition: trx0types.h:195
TRX_DICT_OP_INDEX
@ TRX_DICT_OP_INDEX
The transaction is creating or dropping an index in an existing table.
Definition: trx0types.h:118
hit_list_t
std::vector< TrxVersion, ut_allocator< TrxVersion > > hit_list_t
Definition: trx0types.h:581
Rseg_Iterator
Rsegs_Vector::iterator Rseg_Iterator
Definition: trx0types.h:248
trx_rseg_t::id
ulint id
rollback segment id == the index of its slot in the trx system file copy
Definition: trx0types.h:191
Rsegs::x_lock
void x_lock()
Get a shared lock on m_rsegs.
Definition: trx0types.h:321
TRX_DICT_OP_NONE
@ TRX_DICT_OP_NONE
The transaction is not modifying the data dictionary.
Definition: trx0types.h:109
TRX_SYS_SPACE
static const space_id_t TRX_SYS_SPACE
Space id of the transaction system page (the system tablespace)
Definition: trx0types.h:57
TRX_FORCE_ROLLBACK_MASK
static const ib_uint32_t TRX_FORCE_ROLLBACK_MASK
For masking out the above four flags.
Definition: trx0types.h:78
RsegMutex
ib_mutex_t RsegMutex
Definition: trx0types.h:180
Rsegs::m_latch
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:386
roll_node_t
Rollback command node in a query graph.
Definition: trx0roll.h:154
trx_rseg_t::page_size
page_size_t page_size
page size of the relevant tablespace
Definition: trx0types.h:204
TRX_QUE_LOCK_WAIT
@ TRX_QUE_LOCK_WAIT
transaction is waiting for a lock
Definition: trx0types.h:83
TRX_DICT_OP_TABLE
@ TRX_DICT_OP_TABLE
The transaction is creating a table or an index, or dropping a table.
Definition: trx0types.h:114
key
static const char * key
Definition: suite_stubs.c:14
commit_node_t
Commit command node in a query graph.
Definition: trx0trx.h:1240
rw_lock_x_lock
#define rw_lock_x_lock(M)
Definition: sync0rw.h:288
trx_rseg_t::max_size
ulint max_size
maximum allowed size in pages
Definition: trx0types.h:207
TrxSysMutex
ib_mutex_t TrxSysMutex
Definition: trx0types.h:184
TRX_STATE_NOT_STARTED
@ TRX_STATE_NOT_STARTED
Definition: trx0types.h:92
Rsegs::~Rsegs
~Rsegs()
Definition: trx0types.h:260
TrxVersion::m_version
ulint m_version
Definition: trx0types.h:578
Rsegs::EMPTY
@ EMPTY
Definition: trx0types.h:462
TrxUndoRsegs::push_back
void push_back(trx_rseg_t *rseg)
Add rollback segment.
Definition: trx0types.h:486
Rsegs
This is a wrapper for a std::vector of trx_rseg_t object pointers.
Definition: trx0types.h:251
TRX_FORCE_ROLLBACK_ASYNC
static const ib_uint32_t TRX_FORCE_ROLLBACK_ASYNC
Was the transaction rolled back asynchronously or by the owning thread.
Definition: trx0types.h:72
TrxTrack
Mapping read-write transactions from id to transaction instance, for creating read views and during t...
Definition: trx0types.h:542
TrxUndoRsegs::get_trx_no
trx_id_t get_trx_no() const
Get transaction number.
Definition: trx0types.h:482
trx_rseg_t
The rollback segment memory object.
Definition: trx0types.h:187
TrxTrack::TrxTrack
TrxTrack(trx_id_t id, trx_t *trx=NULL)
Definition: trx0types.h:543
TrxUndoRsegs::end
Rseg_Iterator end()
Definition: trx0types.h:502
trx_savept_t
Transaction savepoint.
Definition: trx0types.h:158
Rsegs::Rsegs
Rsegs()
Default constructor.
Definition: trx0types.h:254
Rsegs::m_rsegs
Rsegs_Vector m_rsegs
std::vector of rollback segments
Definition: trx0types.h:377
purge_pq_t
std::priority_queue< TrxUndoRsegs, std::vector< TrxUndoRsegs, ut_allocator< TrxUndoRsegs > >, TrxUndoRsegs > purge_pq_t
Definition: trx0types.h:536
trx_sys_t
The transaction system central memory data structure.
Definition: trx0sys.h:424
TrxUndoRsegs::append
void append(const TrxUndoRsegs &append_from)
Append rollback segments from referred instance to current instance.
Definition: trx0types.h:506
Rsegs::is_init
bool is_init()
Return whether the undo tablespace is being initialized.
Definition: trx0types.h:347
TrxUndoRsegs::TrxUndoRsegs
TrxUndoRsegs()
Default constructor.
Definition: trx0types.h:474
page_size_t
Page size descriptor.
Definition: page0size.h:50
page0size.h
TrxTrackHashCmp
Comparator for TrxMap.
Definition: trx0types.h:557
Rsegs::s_unlock
void s_unlock()
Get a shared lock on m_rsegs.
Definition: trx0types.h:318
rw_lock_x_unlock
#define rw_lock_x_unlock(L)
Definition: sync0rw.h:313
TrxTrackHashCmp::operator()
bool operator()(const TrxTrack &lhs, const TrxTrack &rhs) const
Definition: trx0types.h:558
TrxTrackCmp
Comparator for TrxMap.
Definition: trx0types.h:565
Rsegs::is_empty
bool is_empty()
Return whether the undo tablespace is empty and ready to be dropped.
Definition: trx0types.h:343
TrxUndoRsegs::erase
void erase(Rseg_Iterator &it)
Erase the element pointed by given iterator.
Definition: trx0types.h:490
TRX_MAGIC_N
static const ulint TRX_MAGIC_N
Random value to check for corruption of trx_t.
Definition: trx0types.h:63
TrxUndoRsegs
Rollback segements from a given transaction with trx-no scheduled for purge.
Definition: trx0types.h:471
TrxTrack::m_trx
trx_t * m_trx
Definition: trx0types.h:548
TrxTrackHash
Definition: trx0types.h:551
Rsegs::is_inactive_explicit
bool is_inactive_explicit()
Return whether the undo tablespace was made inactive by ALTER TABLESPACE.
Definition: trx0types.h:338
trx_rseg_t::UT_LIST_BASE_NODE_T
UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_list
List of update undo logs.
TrxTrackHash::operator()
size_t operator()(const TrxTrack &key) const
Definition: trx0types.h:552
TrxVersion::m_trx
trx_t * m_trx
Definition: trx0types.h:577
Rsegs::x_unlock
void x_unlock()
Get a shared lock on m_rsegs.
Definition: trx0types.h:324
Rsegs_Vector
std::vector< trx_rseg_t *, ut_allocator< trx_rseg_t * > > Rsegs_Vector
Definition: trx0types.h:247
Rsegs::deinit
void deinit()
De-initialize.
Definition: trx0rseg.cc:477
Rsegs::size
ulint size()
Number of registered rsegs.
Definition: trx0types.h:282
trx_rseg_t::trx_ref_count
std::atomic< ulint > trx_ref_count
Reference counter to track rseg allocated transactions.
Definition: trx0types.h:244
TrxUndoRsegs::begin
Rseg_Iterator begin()
Definition: trx0types.h:498
Rsegs::s_lock
void s_lock()
Get a shared lock on m_rsegs.
Definition: trx0types.h:315
ut0new.h
Rsegs::INACTIVE_EXPLICIT
@ INACTIVE_EXPLICIT
Definition: trx0types.h:461
TrxUndoRsegs::m_trx_no
trx_id_t m_trx_no
Compiler defined copy-constructor/assignment operator should be fine given that there is no reference...
Definition: trx0types.h:527
Rsegs::init
void init()
Initialize.
Definition: trx0rseg.cc:468
TrxIdSet
std::set< TrxTrack, TrxTrackCmp, ut_allocator< TrxTrack > > TrxIdSet
Definition: trx0types.h:572
TrxUndoRsegs::m_rsegs
Rsegs_Vector m_rsegs
Rollback segments of a transaction, scheduled for purge.
Definition: trx0types.h:530
Rsegs::INACTIVE_IMPLICIT
@ INACTIVE_IMPLICIT
Definition: trx0types.h:460
trx_rseg_t::last_del_marks
ibool last_del_marks
TRUE if the last not yet purged log needs purging.
Definition: trx0types.h:241
trx_rseg_t::last_page_no
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:232
Rsegs::is_inactive_implicit
bool is_inactive_implicit()
Return whether the undo tablespace is inactive due to implicit selection by the purge thread.
Definition: trx0types.h:333
TRX_FORCE_ROLLBACK
static const ib_uint32_t TRX_FORCE_ROLLBACK
Mark the transaction for forced rollback.
Definition: trx0types.h:75
trx_rseg_t::last_offset
ulint last_offset
Byte offset of the last not yet purged log header.
Definition: trx0types.h:235
Rsegs::clear
void clear()
Clear the vector of cached rollback segments leaving the reserved space allocated.
Definition: trx0rseg.cc:487
trx_state_t
trx_state_t
Transaction states (trx_t::state)
Definition: trx0types.h:90
Rsegs::begin
Rseg_Iterator begin()
beginning iterator
Definition: trx0types.h:286
TrxVersion::TrxVersion
TrxVersion(trx_t *trx)
Constructor.
Definition: trx0trx.cc:88
trx_que_t
trx_que_t
Transaction execution states when trx->state == TRX_STATE_ACTIVE.
Definition: trx0types.h:81
Rsegs::undo_space_states
undo_space_states
Definition: trx0types.h:457
trx_rseg_t::page_no
page_no_t page_no
page number of the rollback segment header
Definition: trx0types.h:201
TrxMutex
ib_mutex_t TrxMutex
Definition: trx0types.h:181
TrxVersion
Definition: trx0types.h:574
TRX_QUE_RUNNING
@ TRX_QUE_RUNNING
transaction is running
Definition: trx0types.h:82
trx_rseg_t::space_id
space_id_t space_id
space ID where the rollback segment header is placed
Definition: trx0types.h:198
trx_rseg_t::last_trx_no
trx_id_t last_trx_no
Transaction number of the last not yet purged log.
Definition: trx0types.h:238
row_id_t
ib_id_t row_id_t
Row identifier (DB_ROW_ID, DATA_ROW_ID)
Definition: trx0types.h:142
trx_ids_t
std::vector< trx_id_t, ut_allocator< trx_id_t > > trx_ids_t
Definition: trx0types.h:538
trx_dict_op_t
trx_dict_op_t
Type of data dictionary operation.
Definition: trx0types.h:107
trx_ulogf_t
byte trx_ulogf_t
Undo log header.
Definition: trx0types.h:173
ut0mutex.h
rw_lock_s_lock
#define rw_lock_s_lock(M)
Definition: sync0rw.h:253
space_id_t
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
Rsegs::m_state
enum undo_space_states m_state
The current state of this undo tablespace.
Definition: trx0types.h:466
rw_lock_t
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:555
Rsegs::set_inactive_explicit
void set_inactive_explicit()
Make the undo tablespace inactive so that it will not be used for new transactions.
Definition: trx0types.h:366
trx_undo_rec_t
byte trx_undo_rec_t
Undo log record.
Definition: trx0types.h:177
TRX_STATE_ACTIVE
@ TRX_STATE_ACTIVE
Definition: trx0types.h:98
Rsegs::end
Rseg_Iterator end()
ending iterator
Definition: trx0types.h:290
TRX_STATE_COMMITTED_IN_MEMORY
@ TRX_STATE_COMMITTED_IN_MEMORY
Definition: trx0types.h:103
trx_upagef_t
byte trx_upagef_t
Undo log page header.
Definition: trx0types.h:175
rw_lock_s_unlock
#define rw_lock_s_unlock(L)
Definition: sync0rw.h:312
TrxUndoRsegs::TrxUndoRsegs
TrxUndoRsegs(trx_id_t trx_no)
Definition: trx0types.h:476
TRX_QUE_ROLLING_BACK
@ TRX_QUE_ROLLING_BACK
transaction is rolling back
Definition: trx0types.h:85
sync0rw.h
trx_named_savept_t
A savepoint set with SQL's "SAVEPOINT savepoint_id" command.
Definition: trx0roll.h:166
TrxTrackCmp::operator()
bool operator()(const TrxTrack &lhs, const TrxTrack &rhs) const
Definition: trx0types.h:566
Rsegs::push_back
void push_back(trx_rseg_t *rseg)
Add rollback segment.
Definition: trx0types.h:278
TRX_QUE_COMMITTING
@ TRX_QUE_COMMITTING
transaction is committing
Definition: trx0types.h:86
Rsegs::ACTIVE
@ ACTIVE
Definition: trx0types.h:459
TrxUndoRsegs::size
ulint size() const
Number of registered rsegs.
Definition: trx0types.h:494
id
unsigned long id[MAX_DEAD]
Definition: xcom_base.c:426
TRX_STATE_FORCED_ROLLBACK
@ TRX_STATE_FORCED_ROLLBACK
Same as not started but with additional semantics that it was rolled back asynchronously the last tim...
Definition: trx0types.h:96
trx_savept_t::least_undo_no
undo_no_t least_undo_no
least undo number to undo
Definition: trx0types.h:159
trx_purge_t
The control structure used in the purge operation.
Definition: trx0purge.h:952
trx_t
Definition: trx0trx.h:780
TRX_FORCE_ROLLBACK_DISABLE
static const ib_uint32_t TRX_FORCE_ROLLBACK_DISABLE
If this flag is set then the transaction cannot be rolled back asynchronously.
Definition: trx0types.h:67
ut0byte.h