1 /***************************************************************************** 2 3 Copyright (c) 1996, 2021, Oracle and/or its affiliates. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License, version 2.0, 7 as published by the Free Software Foundation. 8 9 This program is also distributed with certain software (including 10 but not limited to OpenSSL) that is licensed under separate terms, 11 as designated in a particular file or component or in included license 12 documentation. The authors of MySQL hereby grant you an additional 13 permission to link the program and your derivative works with the 14 separately licensed software that they have included with MySQL. 15 16 This program is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License, version 2.0, 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 Street, Suite 500, Boston, MA 02110-1335 USA 24 25 *****************************************************************************/ 26 27 /**************************************************//** 28 @file include/trx0sys.h 29 Transaction system 30 31 Created 3/26/1996 Heikki Tuuri 32 *******************************************************/ 33 34 #ifndef trx0sys_h 35 #define trx0sys_h 36 37 #include "univ.i" 38 39 #include "buf0buf.h" 40 #include "fil0fil.h" 41 #include "trx0types.h" 42 #ifndef UNIV_HOTBACKUP 43 #include "mem0mem.h" 44 #include "mtr0mtr.h" 45 #include "ut0byte.h" 46 #include "mem0mem.h" 47 #include "ut0lst.h" 48 #include "read0types.h" 49 #include "page0types.h" 50 #include "ut0mutex.h" 51 #include "trx0trx.h" 52 53 typedef UT_LIST_BASE_NODE_T(trx_t) trx_ut_list_t; 54 55 // Forward declaration 56 class MVCC; 57 class ReadView; 58 59 /** The transaction system */ 60 extern trx_sys_t* trx_sys; 61 62 /** Checks if a page address is the trx sys header page. 63 @param[in] page_id page id 64 @return true if trx sys header page */ 65 UNIV_INLINE 66 bool 67 trx_sys_hdr_page( 68 const page_id_t& page_id); 69 70 /*****************************************************************//** 71 Creates and initializes the central memory structures for the transaction 72 system. This is called when the database is started. 73 @return min binary heap of rsegs to purge */ 74 purge_pq_t* 75 trx_sys_init_at_db_start(void); 76 /*==========================*/ 77 /*****************************************************************//** 78 Creates the trx_sys instance and initializes purge_queue and mutex. */ 79 void 80 trx_sys_create(void); 81 /*================*/ 82 /*****************************************************************//** 83 Creates and initializes the transaction system at the database creation. */ 84 void 85 trx_sys_create_sys_pages(void); 86 /*==========================*/ 87 /****************************************************************//** 88 Looks for a free slot for a rollback segment in the trx system file copy. 89 @return slot index or ULINT_UNDEFINED if not found */ 90 ulint 91 trx_sysf_rseg_find_free( 92 /*====================*/ 93 mtr_t* mtr, /*!< in/out: mtr */ 94 bool include_tmp_slots, /*!< in: if true, report slots reserved 95 for temp-tablespace as free slots. */ 96 ulint nth_free_slots); /*!< in: allocate nth free slot. 97 0 means next free slot. */ 98 /***************************************************************//** 99 Gets the pointer in the nth slot of the rseg array. 100 @return pointer to rseg object, NULL if slot not in use */ 101 UNIV_INLINE 102 trx_rseg_t* 103 trx_sys_get_nth_rseg( 104 /*=================*/ 105 trx_sys_t* sys, /*!< in: trx system */ 106 ulint n, /*!< in: index of slot */ 107 bool is_redo_rseg); /*!< in: true if redo rseg. */ 108 /**********************************************************************//** 109 Gets a pointer to the transaction system file copy and x-locks its page. 110 @return pointer to system file copy, page x-locked */ 111 UNIV_INLINE 112 trx_sysf_t* 113 trx_sysf_get( 114 /*=========*/ 115 mtr_t* mtr); /*!< in: mtr */ 116 /*****************************************************************//** 117 Gets the space of the nth rollback segment slot in the trx system 118 file copy. 119 @return space id */ 120 UNIV_INLINE 121 ulint 122 trx_sysf_rseg_get_space( 123 /*====================*/ 124 trx_sysf_t* sys_header, /*!< in: trx sys file copy */ 125 ulint i, /*!< in: slot index == rseg id */ 126 mtr_t* mtr); /*!< in: mtr */ 127 /*****************************************************************//** 128 Gets the page number of the nth rollback segment slot in the trx system 129 file copy. 130 @return page number, FIL_NULL if slot unused */ 131 UNIV_INLINE 132 ulint 133 trx_sysf_rseg_get_page_no( 134 /*======================*/ 135 trx_sysf_t* sys_header, /*!< in: trx sys file copy */ 136 ulint i, /*!< in: slot index == rseg id */ 137 mtr_t* mtr); /*!< in: mtr */ 138 /*****************************************************************//** 139 Sets the space id of the nth rollback segment slot in the trx system 140 file copy. */ 141 UNIV_INLINE 142 void 143 trx_sysf_rseg_set_space( 144 /*====================*/ 145 trx_sysf_t* sys_header, /*!< in: trx sys file copy */ 146 ulint i, /*!< in: slot index == rseg id */ 147 ulint space, /*!< in: space id */ 148 mtr_t* mtr); /*!< in: mtr */ 149 /*****************************************************************//** 150 Sets the page number of the nth rollback segment slot in the trx system 151 file copy. */ 152 UNIV_INLINE 153 void 154 trx_sysf_rseg_set_page_no( 155 /*======================*/ 156 trx_sysf_t* sys_header, /*!< in: trx sys file copy */ 157 ulint i, /*!< in: slot index == rseg id */ 158 ulint page_no, /*!< in: page number, FIL_NULL if 159 the slot is reset to unused */ 160 mtr_t* mtr); /*!< in: mtr */ 161 /*****************************************************************//** 162 Allocates a new transaction id. 163 @return new, allocated trx id */ 164 UNIV_INLINE 165 trx_id_t 166 trx_sys_get_new_trx_id(); 167 /*===================*/ 168 /*****************************************************************//** 169 Determines the maximum transaction id. 170 @return maximum currently allocated trx id; will be stale after the 171 next call to trx_sys_get_new_trx_id() */ 172 UNIV_INLINE 173 trx_id_t 174 trx_sys_get_max_trx_id(void); 175 /*========================*/ 176 177 #ifdef UNIV_DEBUG 178 /* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */ 179 extern uint trx_rseg_n_slots_debug; 180 #endif 181 182 /*****************************************************************//** 183 Check if slot-id is reserved slot-id for noredo rsegs. */ 184 UNIV_INLINE 185 bool 186 trx_sys_is_noredo_rseg_slot( 187 /*========================*/ 188 ulint slot_id); /*!< in: slot_id to check */ 189 190 /*****************************************************************//** 191 Writes a trx id to an index page. In case that the id size changes in 192 some future version, this function should be used instead of 193 mach_write_... */ 194 UNIV_INLINE 195 void 196 trx_write_trx_id( 197 /*=============*/ 198 byte* ptr, /*!< in: pointer to memory where written */ 199 trx_id_t id); /*!< in: id */ 200 /*****************************************************************//** 201 Reads a trx id from an index page. In case that the id size changes in 202 some future version, this function should be used instead of 203 mach_read_... 204 @return id */ 205 UNIV_INLINE 206 trx_id_t 207 trx_read_trx_id( 208 /*============*/ 209 const byte* ptr); /*!< in: pointer to memory from where to read */ 210 /****************************************************************//** 211 Looks for the trx instance with the given id in the rw trx_list. 212 @return the trx handle or NULL if not found */ 213 UNIV_INLINE 214 trx_t* 215 trx_get_rw_trx_by_id( 216 /*=================*/ 217 trx_id_t trx_id);/*!< in: trx id to search for */ 218 /****************************************************************//** 219 Returns the minimum trx id in rw trx list. This is the smallest id for which 220 the trx can possibly be active. (But, you must look at the trx->state to 221 find out if the minimum trx id transaction itself is active, or already 222 committed.) 223 @return the minimum trx id, or trx_sys->max_trx_id if the trx list is empty */ 224 UNIV_INLINE 225 trx_id_t 226 trx_rw_min_trx_id(void); 227 /*===================*/ 228 /****************************************************************//** 229 Checks if a rw transaction with the given id is active. 230 @return transaction instance if active, or NULL */ 231 UNIV_INLINE 232 trx_t* 233 trx_rw_is_active_low( 234 /*=================*/ 235 trx_id_t trx_id, /*!< in: trx id of the transaction */ 236 ibool* corrupt); /*!< in: NULL or pointer to a flag 237 that will be set if corrupt */ 238 /****************************************************************//** 239 Checks if a rw transaction with the given id is active. If the caller is 240 not holding trx_sys->mutex, the transaction may already have been 241 committed. 242 @return transaction instance if active, or NULL; */ 243 UNIV_INLINE 244 trx_t* 245 trx_rw_is_active( 246 /*=============*/ 247 trx_id_t trx_id, /*!< in: trx id of the transaction */ 248 ibool* corrupt, /*!< in: NULL or pointer to a flag 249 that will be set if corrupt */ 250 bool do_ref_count); /*!< in: if true then increment the 251 trx_t::n_ref_count */ 252 #ifdef UNIV_DEBUG 253 /****************************************************************//** 254 Checks whether a trx is in on of rw_trx_list 255 @return TRUE if is in */ 256 bool 257 trx_in_rw_trx_list( 258 /*============*/ 259 const trx_t* in_trx) /*!< in: transaction */ 260 MY_ATTRIBUTE((warn_unused_result)); 261 #endif /* UNIV_DEBUG */ 262 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG 263 /***********************************************************//** 264 Assert that a transaction has been recovered. 265 @return TRUE */ 266 UNIV_INLINE 267 ibool 268 trx_assert_recovered( 269 /*=================*/ 270 trx_id_t trx_id) /*!< in: transaction identifier */ 271 MY_ATTRIBUTE((warn_unused_result)); 272 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ 273 /*****************************************************************//** 274 Updates the offset information about the end of the MySQL binlog entry 275 which corresponds to the transaction just being committed. In a MySQL 276 replication slave updates the latest master binlog position up to which 277 replication has proceeded. */ 278 void 279 trx_sys_update_mysql_binlog_offset( 280 /*===============================*/ 281 const char* file_name,/*!< in: MySQL log file name */ 282 int64_t offset, /*!< in: position in that log file */ 283 ulint field, /*!< in: offset of the MySQL log info field in 284 the trx sys header */ 285 mtr_t* mtr); /*!< in: mtr */ 286 /*****************************************************************//** 287 Prints to stderr the MySQL binlog offset info in the trx system header if 288 the magic number shows it valid. */ 289 void 290 trx_sys_print_mysql_binlog_offset(void); 291 /*===================================*/ 292 /*****************************************************************//** 293 Initializes the tablespace tag system. */ 294 void 295 trx_sys_file_format_init(void); 296 /*==========================*/ 297 /*****************************************************************//** 298 Closes the tablespace tag system. */ 299 void 300 trx_sys_file_format_close(void); 301 /*===========================*/ 302 /********************************************************************//** 303 Tags the system table space with minimum format id if it has not been 304 tagged yet. 305 WARNING: This function is only called during the startup and AFTER the 306 redo log application during recovery has finished. */ 307 void 308 trx_sys_file_format_tag_init(void); 309 /*==============================*/ 310 /*****************************************************************//** 311 Shutdown/Close the transaction system. */ 312 void 313 trx_sys_close(void); 314 /*===============*/ 315 /*****************************************************************//** 316 Get the name representation of the file format from its id. 317 @return pointer to the name */ 318 const char* 319 trx_sys_file_format_id_to_name( 320 /*===========================*/ 321 const ulint id); /*!< in: id of the file format */ 322 /*****************************************************************//** 323 Set the file format id unconditionally except if it's already the 324 same value. 325 @return TRUE if value updated */ 326 ibool 327 trx_sys_file_format_max_set( 328 /*========================*/ 329 ulint format_id, /*!< in: file format id */ 330 const char** name); /*!< out: max file format name or 331 NULL if not needed. */ 332 /********************************************************************* 333 Creates the rollback segments 334 @return number of rollback segments that are active. */ 335 ulint 336 trx_sys_create_rsegs( 337 /*=================*/ 338 ulint n_spaces, /*!< number of tablespaces for UNDO logs */ 339 ulint n_rsegs, /*!< number of rollback segments to create */ 340 ulint n_tmp_rsegs); /*!< number of rollback segments reserved for 341 temp-tables. */ 342 /*****************************************************************//** 343 Get the number of transaction in the system, independent of their state. 344 @return count of transactions in trx_sys_t::trx_list */ 345 UNIV_INLINE 346 ulint 347 trx_sys_get_n_rw_trx(void); 348 /*======================*/ 349 350 /********************************************************************* 351 Check if there are any active (non-prepared) transactions. 352 @return total number of active transactions or 0 if none */ 353 ulint 354 trx_sys_any_active_transactions(void); 355 /*=================================*/ 356 #else /* !UNIV_HOTBACKUP */ 357 /*****************************************************************//** 358 Prints to stderr the MySQL binlog info in the system header if the 359 magic number shows it valid. */ 360 void 361 trx_sys_print_mysql_binlog_offset_from_page( 362 /*========================================*/ 363 const byte* page); /*!< in: buffer containing the trx 364 system header page, i.e., page number 365 TRX_SYS_PAGE_NO in the tablespace */ 366 /*****************************************************************//** 367 Reads the file format id from the first system table space file. 368 Even if the call succeeds and returns TRUE, the returned format id 369 may be ULINT_UNDEFINED signalling that the format id was not present 370 in the data file. 371 @return TRUE if call succeeds */ 372 ibool 373 trx_sys_read_file_format_id( 374 /*========================*/ 375 const char *pathname, /*!< in: pathname of the first system 376 table space file */ 377 ulint *format_id); /*!< out: file format of the system table 378 space */ 379 /*****************************************************************//** 380 Reads the file format id from the given per-table data file. 381 @return TRUE if call succeeds */ 382 ibool 383 trx_sys_read_pertable_file_format_id( 384 /*=================================*/ 385 const char *pathname, /*!< in: pathname of a per-table 386 datafile */ 387 ulint *format_id); /*!< out: file format of the per-table 388 data file */ 389 #endif /* !UNIV_HOTBACKUP */ 390 /*****************************************************************//** 391 Get the name representation of the file format from its id. 392 @return pointer to the max format name */ 393 const char* 394 trx_sys_file_format_max_get(void); 395 /*=============================*/ 396 /*****************************************************************//** 397 Check for the max file format tag stored on disk. 398 @return DB_SUCCESS or error code */ 399 dberr_t 400 trx_sys_file_format_max_check( 401 /*==========================*/ 402 ulint max_format_id); /*!< in: the max format id to check */ 403 /********************************************************************//** 404 Update the file format tag in the system tablespace only if the given 405 format id is greater than the known max id. 406 @return TRUE if format_id was bigger than the known max id */ 407 ibool 408 trx_sys_file_format_max_upgrade( 409 /*============================*/ 410 const char** name, /*!< out: max file format name */ 411 ulint format_id); /*!< in: file format identifier */ 412 /*****************************************************************//** 413 Get the name representation of the file format from its id. 414 @return pointer to the name */ 415 const char* 416 trx_sys_file_format_id_to_name( 417 /*===========================*/ 418 const ulint id); /*!< in: id of the file format */ 419 420 /** 421 Add the transaction to the RW transaction set 422 @param trx transaction instance to add */ 423 UNIV_INLINE 424 void 425 trx_sys_rw_trx_add(trx_t* trx); 426 427 #ifdef UNIV_DEBUG 428 /*************************************************************//** 429 Validate the trx_sys_t::rw_trx_list. 430 @return true if the list is valid */ 431 bool 432 trx_sys_validate_trx_list(); 433 /*========================*/ 434 #endif /* UNIV_DEBUG */ 435 436 /** The automatically created system rollback segment has this id */ 437 #define TRX_SYS_SYSTEM_RSEG_ID 0 438 439 /** The offset of the transaction system header on the page */ 440 #define TRX_SYS FSEG_PAGE_DATA 441 442 /** Transaction system header */ 443 /*------------------------------------------------------------- @{ */ 444 #define TRX_SYS_TRX_ID_STORE 0 /*!< the maximum trx id or trx 445 number modulo 446 TRX_SYS_TRX_ID_UPDATE_MARGIN 447 written to a file page by any 448 transaction; the assignment of 449 transaction ids continues from 450 this number rounded up by 451 TRX_SYS_TRX_ID_UPDATE_MARGIN 452 plus 453 TRX_SYS_TRX_ID_UPDATE_MARGIN 454 when the database is 455 started */ 456 #define TRX_SYS_FSEG_HEADER 8 /*!< segment header for the 457 tablespace segment the trx 458 system is created into */ 459 #define TRX_SYS_RSEGS (8 + FSEG_HEADER_SIZE) 460 /*!< the start of the array of 461 rollback segment specification 462 slots */ 463 /*------------------------------------------------------------- @} */ 464 465 /* Max number of rollback segments: the number of segment specification slots 466 in the transaction system array; rollback segment id must fit in one (signed) 467 byte, therefore 128; each slot is currently 8 bytes in size. If you want 468 to raise the level to 256 then you will need to fix some assertions that 469 impose the 7 bit restriction. e.g., mach_write_to_3() */ 470 #define TRX_SYS_N_RSEGS 128 471 /* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one 472 rollback segment. It initialized some arrays with this number of entries. 473 We must remember this limit in order to keep file compatibility. */ 474 #define TRX_SYS_OLD_N_RSEGS 256 475 476 /** Maximum length of MySQL binlog file name, in bytes. */ 477 #define TRX_SYS_MYSQL_LOG_NAME_LEN 512 478 /** Contents of TRX_SYS_MYSQL_LOG_MAGIC_N_FLD */ 479 #define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344 480 481 #if UNIV_PAGE_SIZE_MIN < 4096 482 # error "UNIV_PAGE_SIZE_MIN < 4096" 483 #endif 484 /** The offset of the MySQL binlog offset info in the trx system header */ 485 #define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000) 486 #define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD 0 /*!< magic number which is 487 TRX_SYS_MYSQL_LOG_MAGIC_N 488 if we have valid data in the 489 MySQL binlog info */ 490 #define TRX_SYS_MYSQL_LOG_OFFSET_HIGH 4 /*!< high 4 bytes of the offset 491 within that file */ 492 #define TRX_SYS_MYSQL_LOG_OFFSET_LOW 8 /*!< low 4 bytes of the offset 493 within that file */ 494 #define TRX_SYS_MYSQL_LOG_NAME 12 /*!< MySQL log file name */ 495 496 /** Doublewrite buffer */ 497 /* @{ */ 498 /** The offset of the doublewrite buffer header on the trx system header page */ 499 #define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200) 500 /*-------------------------------------------------------------*/ 501 #define TRX_SYS_DOUBLEWRITE_FSEG 0 /*!< fseg header of the fseg 502 containing the doublewrite 503 buffer */ 504 #define TRX_SYS_DOUBLEWRITE_MAGIC FSEG_HEADER_SIZE 505 /*!< 4-byte magic number which 506 shows if we already have 507 created the doublewrite 508 buffer */ 509 #define TRX_SYS_DOUBLEWRITE_BLOCK1 (4 + FSEG_HEADER_SIZE) 510 /*!< page number of the 511 first page in the first 512 sequence of 64 513 (= FSP_EXTENT_SIZE) consecutive 514 pages in the doublewrite 515 buffer */ 516 #define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE) 517 /*!< page number of the 518 first page in the second 519 sequence of 64 consecutive 520 pages in the doublewrite 521 buffer */ 522 #define TRX_SYS_DOUBLEWRITE_REPEAT 12 /*!< we repeat 523 TRX_SYS_DOUBLEWRITE_MAGIC, 524 TRX_SYS_DOUBLEWRITE_BLOCK1, 525 TRX_SYS_DOUBLEWRITE_BLOCK2 526 so that if the trx sys 527 header is half-written 528 to disk, we still may 529 be able to recover the 530 information */ 531 /** If this is not yet set to TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N, 532 we must reset the doublewrite buffer, because starting from 4.1.x the 533 space id of a data page is stored into 534 FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID. */ 535 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE) 536 537 /*-------------------------------------------------------------*/ 538 /** Contents of TRX_SYS_DOUBLEWRITE_MAGIC */ 539 #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855 540 /** Contents of TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED */ 541 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386 542 543 /** Size of the doublewrite block in pages */ 544 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE 545 /* @} */ 546 547 /** File format tag */ 548 /* @{ */ 549 /** The offset of the file format tag on the trx system header page 550 (TRX_SYS_PAGE_NO of TRX_SYS_SPACE) */ 551 #define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16) 552 553 /** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format 554 identifier is added to this constant. */ 555 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL 556 /** Contents of TRX_SYS_FILE_FORMAT_TAG+4 when valid */ 557 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH 2745987765UL 558 /** Contents of TRX_SYS_FILE_FORMAT_TAG when valid. The file format 559 identifier is added to this 64-bit constant. */ 560 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N \ 561 ((ib_uint64_t) TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH << 32 \ 562 | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW) 563 /* @} */ 564 565 #ifndef UNIV_HOTBACKUP 566 /** The transaction system central memory data structure. */ 567 struct trx_sys_t { 568 569 TrxSysMutex mutex; /*!< mutex protecting most fields in 570 this structure except when noted 571 otherwise */ 572 573 MVCC* mvcc; /*!< Multi version concurrency control 574 manager */ 575 volatile trx_id_t 576 max_trx_id; /*!< The smallest number not yet 577 assigned as a transaction id or 578 transaction number. This is declared 579 volatile because it can be accessed 580 without holding any mutex during 581 AC-NL-RO view creation. */ 582 trx_ut_list_t serialisation_list; 583 /*!< Ordered on trx_t::no of all the 584 currenrtly active RW transactions */ 585 #ifdef UNIV_DEBUG 586 trx_id_t rw_max_trx_id; /*!< Max trx id of read-write 587 transactions which exist or existed */ 588 #endif /* UNIV_DEBUG */ 589 590 char pad1[64]; /*!< To avoid false sharing */ 591 trx_ut_list_t rw_trx_list; /*!< List of active and committed in 592 memory read-write transactions, sorted 593 on trx id, biggest first. Recovered 594 transactions are always on this list. */ 595 596 char pad2[64]; /*!< To avoid false sharing */ 597 trx_ut_list_t mysql_trx_list; /*!< List of transactions created 598 for MySQL. All user transactions are 599 on mysql_trx_list. The rw_trx_list 600 can contain system transactions and 601 recovered transactions that will not 602 be in the mysql_trx_list. 603 mysql_trx_list may additionally contain 604 transactions that have not yet been 605 started in InnoDB. */ 606 607 trx_ids_t rw_trx_ids; /*!< Array of Read write transaction IDs 608 for MVCC snapshot. A ReadView would take 609 a snapshot of these transactions whose 610 changes are not visible to it. We should 611 remove transactions from the list before 612 committing in memory and releasing locks 613 to ensure right order of removal and 614 consistent snapshot. */ 615 616 char pad3[64]; /*!< To avoid false sharing */ 617 trx_rseg_t* rseg_array[TRX_SYS_N_RSEGS]; 618 /*!< Pointer array to rollback 619 segments; NULL if slot not in use; 620 created and destroyed in 621 single-threaded mode; not protected 622 by any mutex, because it is read-only 623 during multi-threaded operation */ 624 ulint rseg_history_len; 625 /*!< Length of the TRX_RSEG_HISTORY 626 list (update undo logs for committed 627 transactions), protected by 628 rseg->mutex */ 629 630 trx_rseg_t* pending_purge_rseg_array[TRX_SYS_N_RSEGS]; 631 /*!< Pointer array to rollback segments 632 between slot-1..slot-srv_tmp_undo_logs 633 that are now replaced by non-redo 634 rollback segments. We need them for 635 scheduling purge if any of the rollback 636 segment has pending records to purge. */ 637 638 TrxIdSet rw_trx_set; /*!< Mapping from transaction id 639 to transaction instance */ 640 641 ulint n_prepared_trx; /*!< Number of transactions currently 642 in the XA PREPARED state */ 643 644 ulint n_prepared_recovered_trx; /*!< Number of transactions 645 currently in XA PREPARED state that are 646 also recovered. Such transactions cannot 647 be added during runtime. They can only 648 occur after recovery if mysqld crashed 649 while there were XA PREPARED 650 transactions. We disable query cache 651 if such transactions exist. */ 652 }; 653 654 /** When a trx id which is zero modulo this number (which must be a power of 655 two) is assigned, the field TRX_SYS_TRX_ID_STORE on the transaction system 656 page is updated */ 657 #define TRX_SYS_TRX_ID_WRITE_MARGIN ((trx_id_t) 256) 658 #endif /* !UNIV_HOTBACKUP */ 659 660 /** Test if trx_sys->mutex is owned. */ 661 #define trx_sys_mutex_own() (trx_sys->mutex.is_owned()) 662 663 /** Acquire the trx_sys->mutex. */ 664 #define trx_sys_mutex_enter() do { \ 665 mutex_enter(&trx_sys->mutex); \ 666 } while (0) 667 668 /** Release the trx_sys->mutex. */ 669 #define trx_sys_mutex_exit() do { \ 670 trx_sys->mutex.exit(); \ 671 } while (0) 672 673 #ifndef UNIV_NONINL 674 #include "trx0sys.ic" 675 #endif 676 677 #endif 678