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