MySQL  8.0.20
Source Code Documentation
trx0sys.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/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 instance with the given id in the rw trx_list.
166  @return the trx handle or NULL if not found */
167 UNIV_INLINE
168 trx_t *trx_get_rw_trx_by_id(trx_id_t trx_id); /*!< in: trx id to search for */
169 /** Returns the minimum trx id in rw trx list. This is the smallest id for which
170  the trx can possibly be active. (But, you must look at the trx->state to
171  find out if the minimum trx id transaction itself is active, or already
172  committed.)
173  @return the minimum trx id, or trx_sys->max_trx_id if the trx list is empty */
174 UNIV_INLINE
176 
177 /** Checks if a rw transaction with the given id is active.
178 @param[in] trx_id trx id of the transaction
179 @param[in] corrupt NULL or pointer to a flag that will be set if
180  corrupt
181 @return transaction instance if active, or NULL */
182 UNIV_INLINE
183 trx_t *trx_rw_is_active_low(trx_id_t trx_id, ibool *corrupt);
184 
185 /** Checks if a rw transaction with the given id is active.
186 Please note, that positive result means only that the trx was active
187 at some moment during the call, but it might have already become
188 TRX_STATE_COMMITTED_IN_MEMORY before the call returns to the caller, as this
189 transition is protected by trx->mutex and trx_sys->mutex, but it is impossible
190 for the caller to hold any of these mutexes when calling this function as the
191 function itself internally acquires trx_sys->mutex which would cause recurrent
192 mutex acquisition if caller already had trx_sys->mutex, or latching order
193 violation in case of holding trx->mutex.
194 @param[in] trx_id trx id of the transaction
195 @param[in] corrupt NULL or pointer to a flag that will be set if
196  corrupt
197 @param[in] do_ref_count if true then increment the trx_t::n_ref_count
198 @return transaction instance if active, or NULL; */
199 UNIV_INLINE
200 trx_t *trx_rw_is_active(trx_id_t trx_id, ibool *corrupt, bool do_ref_count);
201 
202 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
203 /** Assert that a transaction has been recovered.
204  @return true */
205 UNIV_INLINE
206 ibool trx_assert_recovered(trx_id_t trx_id) /*!< in: transaction identifier */
207  MY_ATTRIBUTE((warn_unused_result));
208 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
209 
210 /** Persist transaction number limit below which all transaction GTIDs
211 are persisted to disk table.
212 @param[in] gtid_trx_no transaction number */
213 void trx_sys_persist_gtid_num(trx_id_t gtid_trx_no);
214 
215 /** @return oldest transaction number yet to be committed. */
217 
218 /** Get a list of all binlog prepared transactions.
219 @param[out] trx_ids all prepared transaction IDs. */
220 void trx_sys_get_binlog_prepared(std::vector<trx_id_t> &trx_ids);
221 
222 /** Get current binary log positions stored.
223 @param[out] file binary log file name
224 @param[out] offset binary log file offset */
225 void trx_sys_read_binlog_position(char *file, uint64_t &offset);
226 
227 /** Update binary log position if not already updated. This is called
228 by clone to update any stale binary log position if any transaction
229 is yet to update the binary log position in SE.
230 @param[in] last_file last noted binary log file name
231 @param[in] last_offset last noted binary log offset
232 @param[in] file current binary log file name
233 @param[in] offset current binary log file offset
234 @return true, if binary log position is updated with current. */
235 bool trx_sys_write_binlog_position(const char *last_file, uint64_t last_offset,
236  const char *file, uint64_t offset);
237 
238 /** Updates the offset information about the end of the MySQL binlog entry
239 which corresponds to the transaction being committed, external XA transaction
240 being prepared or rolled back. In a MySQL replication slave updates the latest
241 master binlog position up to which replication has proceeded.
242 @param[in] trx current transaction
243 @param[in,out] mtr mini transaction for update */
245 
246 /** Shutdown/Close the transaction system. */
247 void trx_sys_close(void);
248 
249 /** Determine if there are incomplete transactions in the system.
250 @return whether incomplete transactions need rollback */
251 UNIV_INLINE
252 bool trx_sys_need_rollback();
253 
254 /*********************************************************************
255 Check if there are any active (non-prepared) transactions.
256 @return total number of active transactions or 0 if none */
258 #endif /* !UNIV_HOTBACKUP */
259 /**
260 Add the transaction to the RW transaction set
261 @param trx transaction instance to add */
262 UNIV_INLINE
263 void trx_sys_rw_trx_add(trx_t *trx);
264 
265 #ifdef UNIV_DEBUG
266 /** Validate the trx_sys_t::rw_trx_list.
267  @return true if the list is valid */
269 #endif /* UNIV_DEBUG */
270 
271 /** Initialize trx_sys_undo_spaces, called once during srv_start(). */
273 
274 /** Free the resources occupied by trx_sys_undo_spaces,
275 called once during thread de-initialization. */
277 
278 /** The automatically created system rollback segment has this id */
279 #define TRX_SYS_SYSTEM_RSEG_ID 0
280 
281 /** The offset of the transaction system header on the page */
282 #define TRX_SYS FSEG_PAGE_DATA
283 
284 /** Transaction system header */
285 /*------------------------------------------------------------- @{ */
286 #define TRX_SYS_TRX_ID_STORE \
287  0 /*!< the maximum trx id or trx \
288  number modulo \
289  TRX_SYS_TRX_ID_UPDATE_MARGIN \
290  written to a file page by any \
291  transaction; the assignment of \
292  transaction ids continues from \
293  this number rounded up by \
294  TRX_SYS_TRX_ID_UPDATE_MARGIN \
295  plus \
296  TRX_SYS_TRX_ID_UPDATE_MARGIN \
297  when the database is \
298  started */
299 #define TRX_SYS_FSEG_HEADER \
300  8 /*!< segment header for the \
301  tablespace segment the trx \
302  system is created into */
303 #define TRX_SYS_RSEGS (8 + FSEG_HEADER_SIZE)
304 /*!< the start of the array of
305 rollback segment specification
306 slots */
307 /*------------------------------------------------------------- @} */
308 
309 /* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one
310 rollback segment. It initialized some arrays with this number of entries.
311 We must remember this limit in order to keep file compatibility. */
312 #define TRX_SYS_OLD_N_RSEGS 256
313 
314 /* The system temporary tablespace was originally allocated rseg_id slot
315 numbers 1 through 32 in the TRX_SYS page. But those slots were not used
316 because those Rollback segments were recreated at startup and after any
317 crash. These slots are now used for redo-enabled rollback segments.
318 The default number of rollback segments in the temporary tablespace
319 remains the same. */
320 #define TRX_SYS_OLD_TMP_RSEGS 32
321 
322 /** Maximum length of MySQL binlog file name, in bytes. */
323 #define TRX_SYS_MYSQL_LOG_NAME_LEN 512
324 /** Contents of TRX_SYS_MYSQL_LOG_MAGIC_N_FLD */
325 #define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
326 
327 #if UNIV_PAGE_SIZE_MIN < 4096
328 #error "UNIV_PAGE_SIZE_MIN < 4096"
329 #endif
330 /** The offset of the MySQL binlog offset info in the trx system header */
331 #define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000)
332 #define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD \
333  0 /*!< magic number which is \
334  TRX_SYS_MYSQL_LOG_MAGIC_N \
335  if we have valid data in the \
336  MySQL binlog info */
337 #define TRX_SYS_MYSQL_LOG_OFFSET_HIGH \
338  4 /*!< high 4 bytes of the offset \
339  within that file */
340 #define TRX_SYS_MYSQL_LOG_OFFSET_LOW \
341  8 /*!< low 4 bytes of the offset \
342  within that file */
343 #define TRX_SYS_MYSQL_LOG_NAME 12 /*!< MySQL log file name */
345 /** Reserve next 8 bytes for transaction number up to which GTIDs
346 are persisted to table */
347 #define TRX_SYS_TRX_NUM_GTID \
348  (TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME + TRX_SYS_MYSQL_LOG_NAME_LEN)
349 #define TRX_SYS_TRX_NUM_END = (TRX_SYS_TRX_NUM_GTID + 8)
350 
351 /** Doublewrite buffer */
352 /* @{ */
353 /** The offset of the doublewrite buffer header on the trx system header page */
354 #define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200)
355 /*-------------------------------------------------------------*/
356 #define TRX_SYS_DOUBLEWRITE_FSEG \
357  0 /*!< fseg header of the fseg \
358  containing the doublewrite \
359  buffer */
360 #define TRX_SYS_DOUBLEWRITE_MAGIC FSEG_HEADER_SIZE
361 /*!< 4-byte magic number which
362 shows if we already have
363 created the doublewrite
364 buffer */
365 #define TRX_SYS_DOUBLEWRITE_BLOCK1 (4 + FSEG_HEADER_SIZE)
366 /*!< page number of the
367 first page in the first
368 sequence of 64
369 (= FSP_EXTENT_SIZE) consecutive
370 pages in the doublewrite
371 buffer */
372 #define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE)
373 /*!< page number of the
374 first page in the second
375 sequence of 64 consecutive
376 pages in the doublewrite
377 buffer */
378 #define TRX_SYS_DOUBLEWRITE_REPEAT \
379  12 /*!< we repeat \
380  TRX_SYS_DOUBLEWRITE_MAGIC, \
381  TRX_SYS_DOUBLEWRITE_BLOCK1, \
382  TRX_SYS_DOUBLEWRITE_BLOCK2 \
383  so that if the trx sys \
384  header is half-written \
385  to disk, we still may \
386  be able to recover the \
387  information */
388 /** If this is not yet set to TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N,
389 we must reset the doublewrite buffer, because starting from 4.1.x the
390 space id of a data page is stored into
391 FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID. */
392 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE)
393 
394 /*-------------------------------------------------------------*/
395 /** Contents of TRX_SYS_DOUBLEWRITE_MAGIC */
396 #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855
397 /** Contents of TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED */
398 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386
399 
400 /** Size of the doublewrite block in pages */
401 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE
402 /* @} */
403 
404 /** List of undo tablespace IDs. */
405 class Space_Ids : public std::vector<space_id_t, ut_allocator<space_id_t>> {
406  public:
407  void sort() { std::sort(begin(), end()); }
408 
409  bool contains(space_id_t id) {
410  if (size() == 0) {
411  return (false);
412  }
413 
414  iterator it = std::find(begin(), end(), id);
415 
416  return (it != end());
417  }
418 
419  iterator find(space_id_t id) { return (std::find(begin(), end(), id)); }
420 };
421 
422 #ifndef UNIV_HOTBACKUP
423 /** The transaction system central memory data structure. */
424 struct trx_sys_t {
425  TrxSysMutex mutex; /*!< mutex protecting most fields in
426  this structure except when noted
427  otherwise */
428 
429  MVCC *mvcc; /*!< Multi version concurrency control
430  manager */
431  volatile trx_id_t max_trx_id; /*!< The smallest number not yet
432  assigned as a transaction id or
433  transaction number. This is declared
434  volatile because it can be accessed
435  without holding any mutex during
436  AC-NL-RO view creation. */
437  std::atomic<trx_id_t> min_active_id;
438  /*!< Minimal transaction id which is
439  still in active state. */
440  trx_ut_list_t serialisation_list;
441  /*!< Ordered on trx_t::no of all the
442  currenrtly active RW transactions */
443 #ifdef UNIV_DEBUG
444  trx_id_t rw_max_trx_no; /*!< Max trx number of read-write
445  transactions added for purge. */
446 #endif /* UNIV_DEBUG */
448  char pad1[64]; /*!< To avoid false sharing */
449  trx_ut_list_t rw_trx_list; /*!< List of active and committed in
450  memory read-write transactions, sorted
451  on trx id, biggest first. Recovered
452  transactions are always on this list. */
454  char pad2[64]; /*!< To avoid false sharing */
455  trx_ut_list_t mysql_trx_list; /*!< List of transactions created
456  for MySQL. All user transactions are
457  on mysql_trx_list. The rw_trx_list
458  can contain system transactions and
459  recovered transactions that will not
460  be in the mysql_trx_list.
461  mysql_trx_list may additionally contain
462  transactions that have not yet been
463  started in InnoDB. */
464 
465  trx_ids_t rw_trx_ids; /*!< Array of Read write transaction IDs
466  for MVCC snapshot. A ReadView would take
467  a snapshot of these transactions whose
468  changes are not visible to it. We should
469  remove transactions from the list before
470  committing in memory and releasing locks
471  to ensure right order of removal and
472  consistent snapshot. */
473 
474  char pad3[64]; /*!< To avoid false sharing */
475 
476  Rsegs rsegs; /*!< Vector of pointers to rollback
477  segments. These rsegs are iterated
478  and added to the end under a read
479  lock. They are deleted under a write
480  lock while the vector is adjusted.
481  They are created and destroyed in
482  single-threaded mode. */
484  Rsegs tmp_rsegs; /*!< Vector of pointers to rollback
485  segments within the temp tablespace;
486  This vector is created and destroyed
487  in single-threaded mode so it is not
488  protected by any mutex because it is
489  read-only during multi-threaded
490  operation. */
491 
492  ulint rseg_history_len;
493  /*!< Length of the TRX_RSEG_HISTORY
494  list (update undo logs for committed
495  transactions), protected by
496  rseg->mutex */
497 
498  TrxIdSet rw_trx_set; /*!< Mapping from transaction id
499  to transaction instance */
500 
501  ulint n_prepared_trx; /*!< Number of transactions currently
502  in the XA PREPARED state */
503 
504  bool found_prepared_trx; /*!< True if XA PREPARED trxs are
505  found. */
506 };
507 
508 #endif /* !UNIV_HOTBACKUP */
509 
510 /** A list of undo tablespace IDs found in the TRX_SYS page.
511 This cannot be part of the trx_sys_t object because it is initialized before
512 that object is created. These are the old type of undo tablespaces that do not
513 have space_IDs in the reserved range nor contain an RSEG_ARRAY page. */
515 
516 /** When a trx id which is zero modulo this number (which must be a power of
517 two) is assigned, the field TRX_SYS_TRX_ID_STORE on the transaction system
518 page is updated */
519 #define TRX_SYS_TRX_ID_WRITE_MARGIN ((trx_id_t)256)
521 /** Test if trx_sys->mutex is owned. */
522 #define trx_sys_mutex_own() (trx_sys->mutex.is_owned())
523 
524 /** Acquire the trx_sys->mutex. */
525 #define trx_sys_mutex_enter() \
526  do { \
527  mutex_enter(&trx_sys->mutex); \
528  } while (0)
530 /** Release the trx_sys->mutex. */
531 #define trx_sys_mutex_exit() \
532  do { \
533  trx_sys->mutex.exit(); \
534  } while (0)
535 
536 #include "trx0sys.ic"
537 
538 #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:311
trx_sys_t * trx_sys
The transaction system.
Definition: trx0sys.cc:57
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:127
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:503
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:290
This is a wrapper for a std::vector of trx_rseg_t object pointers.
Definition: trx0types.h:299
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:800
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:153
Space_Ids * trx_sys_undo_spaces
A list of undo tablespace IDs found in the TRX_SYS page.
Definition: trx0sys.cc:696
void trx_sys_undo_spaces_deinit()
Free the resources occupied by trx_sys_undo_spaces, called once during thread de-initialization.
Definition: trx0sys.cc:707
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:447
typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t
void trx_sys_get_binlog_prepared(std::vector< trx_id_t > &trx_ids)
Get a list of all binlog prepared transactions.
Definition: trx0sys.cc:137
void trx_sys_read_binlog_position(char *file, uint64_t &offset)
Get current binary log positions stored.
Definition: trx0sys.cc:222
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:274
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:412
bool trx_sys_validate_trx_list()
Validate the trx_sys_t::rw_trx_list.
Definition: trx0sys.cc:682
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:545
ulint trx_sys_any_active_transactions(void)
Definition: trx0sys.cc:621
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:116
Utilities for byte operations.
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 instance with the given id in the rw trx_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:94
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:328
The memory management.
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
List of undo tablespace IDs.
Definition: trx0sys.h:433
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:699
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.
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:533
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:452
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:435
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:437
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:2211
UNIV_INLINE trx_id_t trx_rw_min_trx_id(void)
Returns the minimum trx id in rw trx list.