MySQL  8.0.21
Source Code Documentation
trx0sys.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2020, 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/trx0sys.h
28  Transaction system
29 
30  Created 3/26/1996 Heikki Tuuri
31  *******************************************************/
32 
33 #ifndef trx0sys_h
34 #define trx0sys_h
35 
36 #include "univ.i"
37 
38 #include "buf0buf.h"
39 #include "fil0fil.h"
40 #include "trx0types.h"
41 #ifndef UNIV_HOTBACKUP
42 #include "mem0mem.h"
43 #include "mtr0mtr.h"
44 #include "page0types.h"
45 #include "ut0byte.h"
46 #include "ut0lst.h"
47 #include "ut0mutex.h"
48 #endif /* !UNIV_HOTBACKUP */
49 #include <atomic>
50 #include <vector>
51 #include "trx0trx.h"
52 
53 #ifndef UNIV_HOTBACKUP
54 typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t;
55 
56 // Forward declaration
57 class MVCC;
58 class ReadView;
59 
60 /** The transaction system */
61 extern trx_sys_t *trx_sys;
62 
63 /** Checks if a page address is the trx sys header page.
64 @param[in] page_id page id
65 @return true if trx sys header page */
66 UNIV_INLINE
67 bool trx_sys_hdr_page(const page_id_t &page_id);
68 
69 /** Creates and initializes the central memory structures for the transaction
70  system. This is called when the database is started.
71  @return min binary heap of rsegs to purge */
73 /** Creates the trx_sys instance and initializes purge_queue and mutex. */
74 void trx_sys_create(void);
75 /** Creates and initializes the transaction system at the database creation. */
76 void trx_sys_create_sys_pages(void);
77 
78 /** Find the page number in the TRX_SYS page for a given slot/rseg_id
79 @param[in] rseg_id slot number in the TRX_SYS page rseg array
80 @return page number from the TRX_SYS page rseg array */
82 
83 /** Look for a free slot for a rollback segment in the trx system file copy.
84 @param[in,out] mtr mtr
85 @return slot index or ULINT_UNDEFINED if not found */
86 ulint trx_sysf_rseg_find_free(mtr_t *mtr);
87 
88 /** Gets a pointer to the transaction system file copy and x-locks its page.
89  @return pointer to system file copy, page x-locked */
90 UNIV_INLINE
91 trx_sysf_t *trx_sysf_get(mtr_t *mtr); /*!< in: mtr */
92 
93 /** Gets the space of the nth rollback segment slot in the trx system
94 file copy.
95 @param[in] sys_header trx sys file copy
96 @param[in] i slot index == rseg id
97 @param[in] mtr mtr
98 @return space id */
99 UNIV_INLINE
100 space_id_t trx_sysf_rseg_get_space(trx_sysf_t *sys_header, ulint i, mtr_t *mtr);
101 
102 /** Gets the page number of the nth rollback segment slot in the trx system
103 file copy.
104 @param[in] sys_header trx sys file copy
105 @param[in] i slot index == rseg id
106 @param[in] mtr mtr
107 @return page number, FIL_NULL if slot unused */
108 UNIV_INLINE
109 page_no_t trx_sysf_rseg_get_page_no(trx_sysf_t *sys_header, ulint i,
110  mtr_t *mtr);
111 
112 /** Sets the space id of the nth rollback segment slot in the trx system
113 file copy.
114 @param[in] sys_header trx sys file copy
115 @param[in] i slot index == rseg id
116 @param[in] space space id
117 @param[in] mtr mtr */
118 UNIV_INLINE
119 void trx_sysf_rseg_set_space(trx_sysf_t *sys_header, ulint i, space_id_t space,
120  mtr_t *mtr);
121 
122 /** Set the page number of the nth rollback segment slot in the trx system
123 file copy.
124 @param[in] sys_header trx sys file copy
125 @param[in] i slot index == rseg id
126 @param[in] page_no page number, FIL_NULL if the slot is reset to
127  unused
128 @param[in] mtr mtr */
129 UNIV_INLINE
130 void trx_sysf_rseg_set_page_no(trx_sysf_t *sys_header, ulint i,
131  page_no_t page_no, mtr_t *mtr);
132 
133 /** Allocates a new transaction id.
134  @return new, allocated trx id */
135 UNIV_INLINE
137 /** Determines the maximum transaction id.
138  @return maximum currently allocated trx id; will be stale after the
139  next call to trx_sys_get_new_trx_id() */
140 UNIV_INLINE
142 
143 #ifdef UNIV_DEBUG
144 /* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */
146 #endif
147 #endif /* !UNIV_HOTBACKUP */
148 
149 /** Writes a trx id to an index page. In case that the id size changes in some
150 future version, this function should be used instead of mach_write_...
151 @param[in] ptr pointer to memory where written
152 @param[in] id id */
153 UNIV_INLINE
154 void trx_write_trx_id(byte *ptr, trx_id_t id);
155 
156 #ifndef UNIV_HOTBACKUP
157 /** Reads a trx id from an index page. In case that the id size changes in
158  some future version, this function should be used instead of
159  mach_read_...
160  @return id */
161 UNIV_INLINE
163  const byte *ptr); /*!< in: pointer to memory from where to read */
164 
165 /** Looks for the trx handle with the given id in rw trxs list.
166  The caller must be holding trx_sys->mutex.
167  @param[in] trx_id trx id to search for
168  @return the trx handle or NULL if not found */
169 UNIV_INLINE
171 
172 /** Returns the minimum trx id in rw trx list. This is the smallest id for which
173  the trx can possibly be active. (But, you must look at the trx->state to
174  find out if the minimum trx id transaction itself is active, or already
175  committed.)
176  @return the minimum trx id, or trx_sys->max_trx_id if the trx list is empty */
177 UNIV_INLINE
179 
180 /** Checks if a rw transaction with the given id is active.
181 @param[in] trx_id trx id of the transaction
182 @param[in] corrupt NULL or pointer to a flag that will be set if
183  corrupt
184 @return transaction instance if active, or NULL */
185 UNIV_INLINE
186 trx_t *trx_rw_is_active_low(trx_id_t trx_id, ibool *corrupt);
187 
188 /** Checks if a rw transaction with the given id is active.
189 Please note, that positive result means only that the trx was active
190 at some moment during the call, but it might have already become
191 TRX_STATE_COMMITTED_IN_MEMORY before the call returns to the caller, as this
192 transition is protected by trx->mutex and trx_sys->mutex, but it is impossible
193 for the caller to hold any of these mutexes when calling this function as the
194 function itself internally acquires trx_sys->mutex which would cause recurrent
195 mutex acquisition if caller already had trx_sys->mutex, or latching order
196 violation in case of holding trx->mutex.
197 @param[in] trx_id trx id of the transaction
198 @param[in] corrupt NULL or pointer to a flag that will be set if
199  corrupt
200 @param[in] do_ref_count if true then increment the trx_t::n_ref_count
201 @return transaction instance if active, or NULL; */
202 UNIV_INLINE
203 trx_t *trx_rw_is_active(trx_id_t trx_id, ibool *corrupt, bool do_ref_count);
204 
205 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
206 /** Assert that a transaction has been recovered.
207  @return true */
208 UNIV_INLINE
209 ibool trx_assert_recovered(trx_id_t trx_id) /*!< in: transaction identifier */
210  MY_ATTRIBUTE((warn_unused_result));
211 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
212 
213 /** Persist transaction number limit below which all transaction GTIDs
214 are persisted to disk table.
215 @param[in] gtid_trx_no transaction number */
216 void trx_sys_persist_gtid_num(trx_id_t gtid_trx_no);
217 
218 /** @return oldest transaction number yet to be committed. */
220 
221 /** Get a list of all binlog prepared transactions.
222 @param[out] trx_ids all prepared transaction IDs. */
223 void trx_sys_get_binlog_prepared(std::vector<trx_id_t> &trx_ids);
224 
225 /** Get current binary log positions stored.
226 @param[out] file binary log file name
227 @param[out] offset binary log file offset */
228 void trx_sys_read_binlog_position(char *file, uint64_t &offset);
229 
230 /** Update binary log position if not already updated. This is called
231 by clone to update any stale binary log position if any transaction
232 is yet to update the binary log position in SE.
233 @param[in] last_file last noted binary log file name
234 @param[in] last_offset last noted binary log offset
235 @param[in] file current binary log file name
236 @param[in] offset current binary log file offset
237 @return true, if binary log position is updated with current. */
238 bool trx_sys_write_binlog_position(const char *last_file, uint64_t last_offset,
239  const char *file, uint64_t offset);
240 
241 /** Updates the offset information about the end of the MySQL binlog entry
242 which corresponds to the transaction being committed, external XA transaction
243 being prepared or rolled back. In a MySQL replication slave updates the latest
244 master binlog position up to which replication has proceeded.
245 @param[in] trx current transaction
246 @param[in,out] mtr mini transaction for update */
248 
249 /** Shutdown/Close the transaction system. */
250 void trx_sys_close(void);
251 
252 /** Determine if there are incomplete transactions in the system.
253 @return whether incomplete transactions need rollback */
254 UNIV_INLINE
255 bool trx_sys_need_rollback();
256 
257 /** Reads number of recovered transactions which have state
258 equal to TRX_STATE_ACTIVE (so are not prepared transactions).
259 @return number of active recovered transactions */
261 
262 /** Validates lists of transactions at the very beginning of the
263 pre-dd-shutdown phase. */
265 
266 /** Validates lists of transactions at the very end of the
267 pre-dd-shutdown phase. */
269 
270 /** Validates lists of transactions after all background threads
271 of InnoDB exited during shutdown of MySQL. */
273 
274 #endif /* !UNIV_HOTBACKUP */
275 /**
276 Add the transaction to the RW transaction set
277 @param trx transaction instance to add */
278 UNIV_INLINE
279 void trx_sys_rw_trx_add(trx_t *trx);
280 
281 #ifdef UNIV_DEBUG
282 /** Validate the trx_sys_t::rw_trx_list.
283  @return true if the list is valid */
285 #endif /* UNIV_DEBUG */
286 
287 /** Initialize trx_sys_undo_spaces, called once during srv_start(). */
289 
290 /** Free the resources occupied by trx_sys_undo_spaces,
291 called once during thread de-initialization. */
293 
294 /** The automatically created system rollback segment has this id */
295 #define TRX_SYS_SYSTEM_RSEG_ID 0
296 
297 /** The offset of the transaction system header on the page */
298 #define TRX_SYS FSEG_PAGE_DATA
299 
300 /** Transaction system header */
301 /*------------------------------------------------------------- @{ */
302 #define TRX_SYS_TRX_ID_STORE \
303  0 /*!< the maximum trx id or trx \
304  number modulo \
305  TRX_SYS_TRX_ID_UPDATE_MARGIN \
306  written to a file page by any \
307  transaction; the assignment of \
308  transaction ids continues from \
309  this number rounded up by \
310  TRX_SYS_TRX_ID_UPDATE_MARGIN \
311  plus \
312  TRX_SYS_TRX_ID_UPDATE_MARGIN \
313  when the database is \
314  started */
315 #define TRX_SYS_FSEG_HEADER \
316  8 /*!< segment header for the \
317  tablespace segment the trx \
318  system is created into */
319 #define TRX_SYS_RSEGS (8 + FSEG_HEADER_SIZE)
320 /*!< the start of the array of
321 rollback segment specification
322 slots */
323 /*------------------------------------------------------------- @} */
324 
325 /* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one
326 rollback segment. It initialized some arrays with this number of entries.
327 We must remember this limit in order to keep file compatibility. */
328 constexpr size_t TRX_SYS_OLD_N_RSEGS = 256;
329 
330 /* The system temporary tablespace was originally allocated rseg_id slot
331 numbers 1 through 32 in the TRX_SYS page. But those slots were not used
332 because those Rollback segments were recreated at startup and after any
333 crash. These slots are now used for redo-enabled rollback segments.
334 The default number of rollback segments in the temporary tablespace
335 remains the same. */
336 constexpr size_t TRX_SYS_OLD_TMP_RSEGS = 32;
337 
338 /** Maximum length of MySQL binlog file name, in bytes. */
339 #define TRX_SYS_MYSQL_LOG_NAME_LEN 512
340 /** Contents of TRX_SYS_MYSQL_LOG_MAGIC_N_FLD */
341 #define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
342 
343 #if UNIV_PAGE_SIZE_MIN < 4096
344 #error "UNIV_PAGE_SIZE_MIN < 4096"
345 #endif
346 /** The offset of the MySQL binlog offset info in the trx system header */
347 #define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000)
348 #define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD \
349  0 /*!< magic number which is \
350  TRX_SYS_MYSQL_LOG_MAGIC_N \
351  if we have valid data in the \
352  MySQL binlog info */
353 #define TRX_SYS_MYSQL_LOG_OFFSET_HIGH \
354  4 /*!< high 4 bytes of the offset \
355  within that file */
356 #define TRX_SYS_MYSQL_LOG_OFFSET_LOW \
357  8 /*!< low 4 bytes of the offset \
358  within that file */
359 #define TRX_SYS_MYSQL_LOG_NAME 12 /*!< MySQL log file name */
361 /** Reserve next 8 bytes for transaction number up to which GTIDs
362 are persisted to table */
363 #define TRX_SYS_TRX_NUM_GTID \
364  (TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME + TRX_SYS_MYSQL_LOG_NAME_LEN)
365 #define TRX_SYS_TRX_NUM_END = (TRX_SYS_TRX_NUM_GTID + 8)
366 
367 /** Doublewrite buffer */
368 /* @{ */
369 /** The offset of the doublewrite buffer header on the trx system header page */
370 #define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200)
371 /*-------------------------------------------------------------*/
372 #define TRX_SYS_DOUBLEWRITE_FSEG \
373  0 /*!< fseg header of the fseg \
374  containing the doublewrite \
375  buffer */
376 #define TRX_SYS_DOUBLEWRITE_MAGIC FSEG_HEADER_SIZE
377 /*!< 4-byte magic number which
378 shows if we already have
379 created the doublewrite
380 buffer */
381 #define TRX_SYS_DOUBLEWRITE_BLOCK1 (4 + FSEG_HEADER_SIZE)
382 /*!< page number of the
383 first page in the first
384 sequence of 64
385 (= FSP_EXTENT_SIZE) consecutive
386 pages in the doublewrite
387 buffer */
388 #define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE)
389 /*!< page number of the
390 first page in the second
391 sequence of 64 consecutive
392 pages in the doublewrite
393 buffer */
394 #define TRX_SYS_DOUBLEWRITE_REPEAT \
395  12 /*!< we repeat \
396  TRX_SYS_DOUBLEWRITE_MAGIC, \
397  TRX_SYS_DOUBLEWRITE_BLOCK1, \
398  TRX_SYS_DOUBLEWRITE_BLOCK2 \
399  so that if the trx sys \
400  header is half-written \
401  to disk, we still may \
402  be able to recover the \
403  information */
404 /** If this is not yet set to TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N,
405 we must reset the doublewrite buffer, because starting from 4.1.x the
406 space id of a data page is stored into
407 FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID. */
408 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE)
409 
410 /*-------------------------------------------------------------*/
411 /** Contents of TRX_SYS_DOUBLEWRITE_MAGIC */
412 #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855
413 /** Contents of TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED */
414 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386
415 
416 /** Size of the doublewrite block in pages */
417 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE
418 /* @} */
419 
420 /** List of undo tablespace IDs. */
421 class Space_Ids : public std::vector<space_id_t, ut_allocator<space_id_t>> {
422  public:
423  void sort() { std::sort(begin(), end()); }
424 
425  bool contains(space_id_t id) {
426  if (size() == 0) {
427  return (false);
428  }
429 
430  iterator it = std::find(begin(), end(), id);
431 
432  return (it != end());
433  }
434 
435  iterator find(space_id_t id) { return (std::find(begin(), end(), id)); }
436 };
437 
438 #ifndef UNIV_HOTBACKUP
439 /** The transaction system central memory data structure. */
440 struct trx_sys_t {
441  TrxSysMutex mutex; /*!< mutex protecting most fields in
442  this structure except when noted
443  otherwise */
444 
445  MVCC *mvcc; /*!< Multi version concurrency control
446  manager */
447  volatile trx_id_t max_trx_id; /*!< The smallest number not yet
448  assigned as a transaction id or
449  transaction number. This is declared
450  volatile because it can be accessed
451  without holding any mutex during
452  AC-NL-RO view creation. */
453  std::atomic<trx_id_t> min_active_id;
454  /*!< Minimal transaction id which is
455  still in active state. */
456  trx_ut_list_t serialisation_list;
457  /*!< Ordered on trx_t::no of all the
458  currenrtly active RW transactions */
459 #ifdef UNIV_DEBUG
460  trx_id_t rw_max_trx_no; /*!< Max trx number of read-write
461  transactions added for purge. */
462 #endif /* UNIV_DEBUG */
464  char pad1[64]; /*!< To avoid false sharing */
465  trx_ut_list_t rw_trx_list; /*!< List of active and committed in
466  memory read-write transactions, sorted
467  on trx id, biggest first. Recovered
468  transactions are always on this list. */
470  char pad2[64]; /*!< To avoid false sharing */
471  trx_ut_list_t mysql_trx_list; /*!< List of transactions created
472  for MySQL. All user transactions are
473  on mysql_trx_list. The rw_trx_list
474  can contain system transactions and
475  recovered transactions that will not
476  be in the mysql_trx_list.
477  mysql_trx_list may additionally contain
478  transactions that have not yet been
479  started in InnoDB. */
480 
481  trx_ids_t rw_trx_ids; /*!< Array of Read write transaction IDs
482  for MVCC snapshot. A ReadView would take
483  a snapshot of these transactions whose
484  changes are not visible to it. We should
485  remove transactions from the list before
486  committing in memory and releasing locks
487  to ensure right order of removal and
488  consistent snapshot. */
489 
490  char pad3[64]; /*!< To avoid false sharing */
491 
492  Rsegs rsegs; /*!< Vector of pointers to rollback
493  segments. These rsegs are iterated
494  and added to the end under a read
495  lock. They are deleted under a write
496  lock while the vector is adjusted.
497  They are created and destroyed in
498  single-threaded mode. */
500  Rsegs tmp_rsegs; /*!< Vector of pointers to rollback
501  segments within the temp tablespace;
502  This vector is created and destroyed
503  in single-threaded mode so it is not
504  protected by any mutex because it is
505  read-only during multi-threaded
506  operation. */
507 
508  ulint rseg_history_len;
509  /*!< Length of the TRX_RSEG_HISTORY
510  list (update undo logs for committed
511  transactions), protected by
512  rseg->mutex */
513 
514  TrxIdSet rw_trx_set; /*!< Mapping from transaction id
515  to transaction instance */
516 
517  ulint n_prepared_trx; /*!< Number of transactions currently
518  in the XA PREPARED state */
519 
520  bool found_prepared_trx; /*!< True if XA PREPARED trxs are
521  found. */
522 };
523 
524 #endif /* !UNIV_HOTBACKUP */
525 
526 /** A list of undo tablespace IDs found in the TRX_SYS page.
527 This cannot be part of the trx_sys_t object because it is initialized before
528 that object is created. These are the old type of undo tablespaces that do not
529 have space_IDs in the reserved range nor contain an RSEG_ARRAY page. */
531 
532 /** When a trx id which is zero modulo this number (which must be a power of
533 two) is assigned, the field TRX_SYS_TRX_ID_STORE on the transaction system
534 page is updated */
535 #define TRX_SYS_TRX_ID_WRITE_MARGIN ((trx_id_t)256)
537 /** Test if trx_sys->mutex is owned. */
538 #define trx_sys_mutex_own() (trx_sys->mutex.is_owned())
539 
540 /** Acquire the trx_sys->mutex. */
541 #define trx_sys_mutex_enter() \
542  do { \
543  mutex_enter(&trx_sys->mutex); \
544  } while (0)
546 /** Release the trx_sys->mutex. */
547 #define trx_sys_mutex_exit() \
548  do { \
549  trx_sys->mutex.exit(); \
550  } while (0)
551 
552 #include "trx0sys.ic"
553 
554 #endif
page_no_t trx_sysf_rseg_find_page_no(ulint rseg_id)
Find the page number in the TRX_SYS page for a given slot/rseg_id.
Definition: trx0sys.cc:312
trx_sys_t * trx_sys
The transaction system.
Definition: trx0sys.cc:58
UNIV_INLINE trx_t * trx_rw_is_active_low(trx_id_t trx_id, ibool *corrupt)
Checks if a rw transaction with the given id is active.
trx_id_t trx_sys_oldest_trx_no()
Definition: trx0sys.cc:128
The MVCC read view manager.
Definition: read0read.h:43
void trx_sys_create(void)
Creates the trx_sys instance and initializes purge_queue and mutex.
Definition: trx0sys.cc:504
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:291
This is a wrapper for a std::vector of trx_rseg_t object pointers.
Definition: trx0types.h:299
constexpr size_t TRX_SYS_OLD_N_RSEGS
Definition: trx0sys.h:341
uint32 page_no_t
Page number.
Definition: api0api.h:57
UNIV_INLINE 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.
List utilities.
UNIV_INLINE trx_sysf_t * trx_sysf_get(mtr_t *mtr)
Gets a pointer to the transaction system file copy and x-locks its page.
The low-level file system.
UNIV_INLINE void trx_write_trx_id(byte *ptr, trx_id_t id)
Writes a trx id to an index page.
std::vector< T, ut_allocator< T > > vector
Specialization of vector which uses ut_allocator.
Definition: ut0new.h:1307
Definition: trx0trx.h:829
Read view lists the trx ids of those transactions for which a consistent read should not see the modi...
Definition: read0types.h:47
pthread_mutex_t mutex
Definition: memcached.c:384
Page identifier.
Definition: buf0types.h:158
Space_Ids * trx_sys_undo_spaces
A list of undo tablespace IDs found in the TRX_SYS page.
Definition: trx0sys.cc:693
void trx_sys_undo_spaces_deinit()
Free the resources occupied by trx_sys_undo_spaces, called once during thread de-initialization.
Definition: trx0sys.cc:704
UNIV_INLINE bool trx_sys_hdr_page(const page_id_t &page_id)
Checks if a page address is the trx sys header page.
iterator find(space_id_t id)
Definition: trx0sys.h:463
typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t
constexpr size_t TRX_SYS_OLD_TMP_RSEGS
Definition: trx0sys.h:349
void trx_sys_get_binlog_prepared(std::vector< trx_id_t > &trx_ids)
Get a list of all binlog prepared transactions.
Definition: trx0sys.cc:138
void trx_sys_read_binlog_position(char *file, uint64_t &offset)
Get current binary log positions stored.
Definition: trx0sys.cc:223
Index page routines.
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:275
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:612
std::priority_queue< TrxUndoRsegs, std::vector< TrxUndoRsegs, ut_allocator< TrxUndoRsegs > >, TrxUndoRsegs > purge_pq_t
Definition: trx0types.h:584
purge_pq_t * trx_sys_init_at_db_start(void)
Creates and initializes the central memory structures for the transaction system. ...
Definition: trx0sys.cc:413
bool trx_sys_validate_trx_list()
Validate the trx_sys_t::rw_trx_list.
Definition: trx0sys.cc:679
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:632
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:188
void trx_sys_close(void)
Shutdown/Close the transaction system.
Definition: trx0sys.cc:546
unsigned int uint
Definition: uca-dump.cc:29
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:117
Utilities for byte operations.
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:640
Transaction system global type definitions.
std::set< TrxTrack, TrxTrackCmp, ut_allocator< TrxTrack > > TrxIdSet
Definition: trx0types.h:620
UNIV_INLINE trx_t * trx_get_rw_trx_by_id(trx_id_t trx_id)
Looks for the trx handle with the given id in rw trxs list.
Policy based mutexes.
UNIV_INLINE ibool trx_assert_recovered(trx_id_t trx_id)
Assert that a transaction has been recovered.
uint trx_rseg_n_slots_debug
Definition: trx0sys.cc:95
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:329
The memory management.
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
List of undo tablespace IDs.
Definition: trx0sys.h:449
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:144
UNIV_INLINE trx_id_t trx_read_trx_id(const byte *ptr)
Reads a trx id from an index page.
UNIV_INLINE trx_id_t trx_sys_get_max_trx_id(void)
Determines the maximum transaction id.
UNIV_INLINE space_id_t trx_sysf_rseg_get_space(trx_sysf_t *sys_header, ulint i, mtr_t *mtr)
Gets the space of the nth rollback segment slot in the trx system file copy.
void trx_sys_undo_spaces_init()
Initialize trx_sys_undo_spaces, called once during srv_start().
Definition: trx0sys.cc:696
UNIV_INLINE 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.
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:600
std::vector< trx_id_t, ut_allocator< trx_id_t > > trx_ids_t
Definition: trx0types.h:586
UNIV_INLINE trx_id_t trx_sys_get_new_trx_id()
Allocates a new transaction id.
Mini-transaction buffer.
The transaction.
Definition: os0file.h:85
void trx_sys_create_sys_pages(void)
Creates and initializes the transaction system at the database creation.
Definition: trx0sys.cc:534
UNIV_INLINE bool trx_sys_need_rollback()
Determine if there are incomplete transactions in the system.
The transaction system central memory data structure.
Definition: trx0sys.h:468
UNIV_INLINE void trx_sys_rw_trx_add(trx_t *trx)
Add the transaction to the RW transaction set.
unsigned char byte
Blob class.
Definition: common.h:159
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:169
The database buffer pool high-level routines.
void sort()
Definition: trx0sys.h:451
ib_mutex_t TrxSysMutex
Definition: trx0types.h:180
UNIV_INLINE trx_t * trx_rw_is_active(trx_id_t trx_id, ibool *corrupt, bool do_ref_count)
Checks if a rw transaction with the given id is active.
bool contains(space_id_t id)
Definition: trx0sys.h:453
UNIV_INLINE 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. ...
byte trx_sysf_t
File objects.
Definition: trx0types.h:161
const byte * find(const Pages *pages, const page_id_t &page_id) noexcept
Find a doublewrite copy of a page.
Definition: buf0dblwr.cc:2223
UNIV_INLINE trx_id_t trx_rw_min_trx_id(void)
Returns the minimum trx id in rw trx list.