InnoDB Plugin  1.0
trx0sys.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2012, 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 as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #ifndef trx0sys_h
27 #define trx0sys_h
28 
29 #include "univ.i"
30 
31 #include "trx0types.h"
32 #include "fsp0types.h"
33 #include "fil0fil.h"
34 #include "buf0buf.h"
35 #ifndef UNIV_HOTBACKUP
36 #include "mtr0mtr.h"
37 #include "ut0byte.h"
38 #include "mem0mem.h"
39 #include "sync0sync.h"
40 #include "ut0lst.h"
41 #include "ut0bh.h"
42 #include "read0types.h"
43 #include "page0types.h"
44 #include "ut0bh.h"
45 
46 typedef UT_LIST_BASE_NODE_T(trx_t) trx_list_t;
47 
50 /* @{ */
52 extern char trx_sys_mysql_master_log_name[];
56 extern ib_int64_t trx_sys_mysql_master_log_pos;
57 /* @} */
58 
62 /* @{ */
64 extern char trx_sys_mysql_bin_log_name[];
66 extern ib_int64_t trx_sys_mysql_bin_log_pos;
67 /* @} */
68 
70 extern trx_sys_t* trx_sys;
71 
72 /***************************************************************/
75 UNIV_INLINE
76 ibool
78 /*=============*/
79  ulint space,
80  ulint page_no);
81 /*****************************************************************/
85 UNIV_INTERN
86 ib_bh_t*
88 /*==========================*/
89 /*****************************************************************/
91 UNIV_INTERN
92 void
93 trx_sys_create(void);
94 /*================*/
95 /*****************************************************************/
97 UNIV_INTERN
98 void
100 /*==========================*/
101 /****************************************************************/
104 UNIV_INTERN
105 ulint
107 /*====================*/
108  mtr_t* mtr);
109 /***************************************************************/
112 UNIV_INLINE
113 trx_rseg_t*
115 /*=================*/
116  trx_sys_t* sys,
117  ulint n);
118 /**********************************************************************/
121 UNIV_INLINE
122 trx_sysf_t*
124 /*=========*/
125  mtr_t* mtr);
126 /*****************************************************************/
130 UNIV_INLINE
131 ulint
133 /*====================*/
134  trx_sysf_t* sys_header,
135  ulint i,
136  mtr_t* mtr);
137 /*****************************************************************/
141 UNIV_INLINE
142 ulint
144 /*======================*/
145  trx_sysf_t* sys_header,
146  ulint i,
147  mtr_t* mtr);
148 /*****************************************************************/
151 UNIV_INLINE
152 void
154 /*====================*/
155  trx_sysf_t* sys_header,
156  ulint i,
157  ulint space,
158  mtr_t* mtr);
159 /*****************************************************************/
162 UNIV_INLINE
163 void
165 /*======================*/
166  trx_sysf_t* sys_header,
167  ulint i,
168  ulint page_no,
170  mtr_t* mtr);
171 /*****************************************************************/
174 UNIV_INLINE
175 trx_id_t
177 /*========================*/
178 /*****************************************************************/
182 UNIV_INLINE
183 trx_id_t
185 /*========================*/
186 
187 #ifdef UNIV_DEBUG
188 /* Flag to control TRX_RSEG_N_SLOTS behavior debugging. */
189 extern uint trx_rseg_n_slots_debug;
190 #endif
191 
192 /*****************************************************************/
196 UNIV_INLINE
197 void
199 /*=============*/
200  byte* ptr,
201  trx_id_t id);
202 /*****************************************************************/
207 UNIV_INLINE
208 trx_id_t
210 /*============*/
211  const byte* ptr);
212 /****************************************************************/
218 UNIV_INLINE
219 trx_t*
221 /*=================*/
222  trx_id_t trx_id);
223 /****************************************************************/
229 UNIV_INLINE
230 trx_id_t
231 trx_rw_min_trx_id(void);
232 /*===================*/
233 /****************************************************************/
240 UNIV_INLINE
241 trx_t*
243 /*=================*/
244  trx_id_t trx_id,
245  ibool* corrupt);
247 /****************************************************************/
254 UNIV_INLINE
255 trx_t*
257 /*=============*/
258  trx_id_t trx_id,
259  ibool* corrupt);
261 #ifdef UNIV_DEBUG
262 /****************************************************************/
265 UNIV_INTERN
266 ibool
268 /*============*/
269  const trx_t* in_trx)
270  __attribute__((nonnull, warn_unused_result));
271 #endif /* UNIV_DEBUG */
272 #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
273 /***********************************************************/
276 UNIV_INLINE
277 ibool
279 /*=================*/
280  trx_id_t trx_id)
281  __attribute__((warn_unused_result));
282 #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
283 /*****************************************************************/
288 UNIV_INTERN
289 void
291 /*===============================*/
292  const char* file_name,
293  ib_int64_t offset,
294  ulint field,
296  mtr_t* mtr);
297 /*****************************************************************/
300 UNIV_INTERN
301 void
303 /*===================================*/
304 /*****************************************************************/
307 UNIV_INTERN
308 void
310 /*====================================*/
311 /*****************************************************************/
313 UNIV_INTERN
314 void
316 /*==========================*/
317 /*****************************************************************/
319 UNIV_INTERN
320 void
322 /*===========================*/
323 /********************************************************************/
328 UNIV_INTERN
329 void
331 /*==============================*/
332 /*****************************************************************/
334 UNIV_INTERN
335 void
336 trx_sys_close(void);
337 /*===============*/
338 /*****************************************************************/
341 UNIV_INTERN
342 const char*
344 /*===========================*/
345  const ulint id);
346 /*****************************************************************/
350 UNIV_INTERN
351 ibool
353 /*========================*/
354  ulint format_id,
355  const char** name);
357 /*********************************************************************
358 Creates the rollback segments
359 @return number of rollback segments that are active. */
360 UNIV_INTERN
361 ulint
363 /*=================*/
364  ulint n_spaces,
365  ulint n_rsegs);
366 /*****************************************************************/
369 UNIV_INLINE
370 ulint
372 /*======================*/
373 
374 /*********************************************************************
375 Check if there are any active (non-prepared) transactions.
376 @return total number of active transactions or 0 if none */
377 UNIV_INTERN
378 ulint
379 trx_sys_any_active_transactions(void);
380 /*=================================*/
381 #else /* !UNIV_HOTBACKUP */
382 /*****************************************************************/
385 UNIV_INTERN
386 void
387 trx_sys_print_mysql_binlog_offset_from_page(
388 /*========================================*/
389  const byte* page);
392 /*****************************************************************/
398 UNIV_INTERN
399 ibool
400 trx_sys_read_file_format_id(
401 /*========================*/
402  const char *pathname,
404  ulint *format_id);
406 /*****************************************************************/
409 UNIV_INTERN
410 ibool
411 trx_sys_read_pertable_file_format_id(
412 /*=================================*/
413  const char *pathname,
415  ulint *format_id);
417 #endif /* !UNIV_HOTBACKUP */
418 /*****************************************************************/
421 UNIV_INTERN
422 const char*
424 /*=============================*/
425 /*****************************************************************/
428 UNIV_INTERN
429 dberr_t
431 /*==========================*/
432  ulint max_format_id);
433 /********************************************************************/
437 UNIV_INTERN
438 ibool
440 /*============================*/
441  const char** name,
442  ulint format_id);
443 /*****************************************************************/
446 UNIV_INTERN
447 const char*
449 /*===========================*/
450  const ulint id);
452 #ifdef UNIV_DEBUG
453 /*************************************************************/
455 UNIV_INTERN
456 ibool
458 /*===========================*/
459 #endif /* UNIV_DEBUG */
460 
461 /* The automatically created system rollback segment has this id */
462 #define TRX_SYS_SYSTEM_RSEG_ID 0
463 
464 /* Space id and page no where the trx system file copy resides */
465 #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
466 #include "fsp0fsp.h"
467 #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
468 
469 /* The offset of the transaction system header on the page */
470 #define TRX_SYS FSEG_PAGE_DATA
471 
473 /*------------------------------------------------------------- @{ */
474 #define TRX_SYS_TRX_ID_STORE 0
486 #define TRX_SYS_FSEG_HEADER 8
489 #define TRX_SYS_RSEGS (8 + FSEG_HEADER_SIZE)
490 
493 /*------------------------------------------------------------- @} */
494 
495 /* Max number of rollback segments: the number of segment specification slots
496 in the transaction system array; rollback segment id must fit in one (signed)
497 byte, therefore 128; each slot is currently 8 bytes in size. If you want
498 to raise the level to 256 then you will need to fix some assertions that
499 impose the 7 bit restriction. e.g., mach_write_to_3() */
500 #define TRX_SYS_N_RSEGS 128
501 /* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one
502 rollback segment. It initialized some arrays with this number of entries.
503 We must remember this limit in order to keep file compatibility. */
504 #define TRX_SYS_OLD_N_RSEGS 256
505 
509 #define TRX_SYS_MYSQL_LOG_NAME_LEN 512
510 
511 #define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
512 
513 #if UNIV_PAGE_SIZE_MIN < 4096
514 # error "UNIV_PAGE_SIZE_MIN < 4096"
515 #endif
516 
518 #define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000)
519 
521 #define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000)
522 #define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD 0
526 #define TRX_SYS_MYSQL_LOG_OFFSET_HIGH 4
528 #define TRX_SYS_MYSQL_LOG_OFFSET_LOW 8
530 #define TRX_SYS_MYSQL_LOG_NAME 12
533 /* @{ */
534 
535 #define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200)
536 /*-------------------------------------------------------------*/
537 #define TRX_SYS_DOUBLEWRITE_FSEG 0
540 #define TRX_SYS_DOUBLEWRITE_MAGIC FSEG_HEADER_SIZE
541 
545 #define TRX_SYS_DOUBLEWRITE_BLOCK1 (4 + FSEG_HEADER_SIZE)
546 
552 #define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE)
553 
558 #define TRX_SYS_DOUBLEWRITE_REPEAT 12
571 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE)
572 
573 /*-------------------------------------------------------------*/
575 #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855
576 
577 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386
578 
580 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE
581 /* @} */
582 
584 /* @{ */
587 #define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16)
588 
591 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL
592 
593 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH 2745987765UL
594 
596 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N \
597  ((ib_uint64_t) TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH << 32 \
598  | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW)
599 /* @} */
600 
601 #ifndef UNIV_HOTBACKUP
602 
603 struct trx_sys_t{
604 
621 #ifdef UNIV_DEBUG
624 #endif
625  trx_list_t rw_trx_list;
629  trx_list_t ro_trx_list;
636  trx_list_t mysql_trx_list;
648  trx_rseg_t* const rseg_array[TRX_SYS_N_RSEGS];
659  UT_LIST_BASE_NODE_T(read_view_t) view_list;
662 };
663 
667 #define TRX_SYS_TRX_ID_WRITE_MARGIN 256
668 #endif /* !UNIV_HOTBACKUP */
669 
670 #ifndef UNIV_NONINL
671 #include "trx0sys.ic"
672 #endif
673 
674 #endif