Drizzled Public API Documentation

trx0sys.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2011, Innobase Oy. 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., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #pragma once
27 #ifndef trx0sys_h
28 #define trx0sys_h
29 
30 #include "univ.i"
31 
32 #include "trx0types.h"
33 #include "fsp0types.h"
34 #include "fil0fil.h"
35 #include "buf0buf.h"
36 #ifndef UNIV_HOTBACKUP
37 #include "mtr0mtr.h"
38 #include "ut0byte.h"
39 #include "mem0mem.h"
40 #include "sync0sync.h"
41 #include "ut0lst.h"
42 #include "ut0bh.h"
43 #include "read0types.h"
44 #include "page0types.h"
45 
46 #include <drizzled/atomics.h>
47 
50 
52 extern trx_sys_t* trx_sys;
53 
65 
66 /****************************************************************/
69 UNIV_INTERN
70 void
72 /*================================*/
73 /****************************************************************/
80 UNIV_INTERN
81 void
83 /*======================================*/
84  ibool restore_corrupt_pages);
85 /****************************************************************/
88 UNIV_INTERN
89 void
91 /*===============================================*/
92 /****************************************************************/
96 UNIV_INTERN
97 ibool
99 /*========================*/
100  ulint page_no);
101 /***************************************************************/
104 UNIV_INLINE
105 ibool
107 /*=============*/
108  ulint space,
109  ulint page_no);
110 /*****************************************************************/
113 UNIV_INTERN
114 void
116 /*==========================*/
117 /*****************************************************************/
119 UNIV_INTERN
120 void
121 trx_sys_create(void);
122 /*================*/
123 /****************************************************************/
126 UNIV_INTERN
127 ulint
129 /*====================*/
130  mtr_t* mtr);
131 /***************************************************************/
134 UNIV_INLINE
135 trx_rseg_t*
137 /*=================*/
138  trx_sys_t* sys,
139  ulint n);
140 /***************************************************************/
142 UNIV_INLINE
143 void
145 /*=================*/
146  trx_sys_t* sys,
147  ulint n,
148  trx_rseg_t* rseg);
150 /**********************************************************************/
153 UNIV_INLINE
154 trx_sysf_t*
156 /*=========*/
157  mtr_t* mtr);
158 /*****************************************************************/
162 UNIV_INLINE
163 ulint
165 /*====================*/
166  trx_sysf_t* sys_header,
167  ulint i,
168  mtr_t* mtr);
169 /*****************************************************************/
173 UNIV_INLINE
174 ulint
176 /*======================*/
177  trx_sysf_t* sys_header,
178  ulint i,
179  mtr_t* mtr);
180 /*****************************************************************/
183 UNIV_INLINE
184 void
186 /*====================*/
187  trx_sysf_t* sys_header,
188  ulint i,
189  ulint space,
190  mtr_t* mtr);
191 /*****************************************************************/
194 UNIV_INLINE
195 void
197 /*======================*/
198  trx_sysf_t* sys_header,
199  ulint i,
200  ulint page_no,
202  mtr_t* mtr);
203 /*****************************************************************/
206 UNIV_INLINE
207 trx_id_t
209 /*========================*/
210 #endif /* !UNIV_HOTBACKUP */
211 /*****************************************************************/
215 UNIV_INLINE
216 void
218 /*=============*/
219  byte* ptr,
220  trx_id_t id);
221 #ifndef UNIV_HOTBACKUP
222 /*****************************************************************/
227 UNIV_INLINE
228 trx_id_t
230 /*============*/
231  const byte* ptr);
232 /****************************************************************/
235 UNIV_INLINE
236 trx_t*
238 /*==========*/
239  trx_id_t trx_id);
240 /****************************************************************/
246 UNIV_INLINE
247 trx_id_t
249 /*=========================*/
250 /****************************************************************/
253 UNIV_INLINE
254 ibool
256 /*==========*/
257  trx_id_t trx_id);
258 /****************************************************************/
261 UNIV_INTERN
262 ibool
264 /*============*/
265  trx_t* in_trx);
266 /*****************************************************************/
268 UNIV_INTERN
269 void
270 trx_sys_flush_commit_id(uint64_t commit_id, ulint field, mtr_t* mtr);
271 /*****************************************************************/
273 UNIV_INTERN
274 void
276 /*****************************************************************/
279 UNIV_INTERN
280 void
282 /*====================================*/
283 /*****************************************************************/
285 UNIV_INTERN
286 void
288 /*==========================*/
289 /*****************************************************************/
291 UNIV_INTERN
292 void
294 /*===========================*/
295 /********************************************************************/
300 UNIV_INTERN
301 void
303 /*==============================*/
304 #ifndef UNIV_HOTBACKUP
305 /*****************************************************************/
307 UNIV_INTERN
308 void
309 trx_sys_close(void);
310 /*===============*/
311 #endif /* !UNIV_HOTBACKUP */
312 /*****************************************************************/
315 UNIV_INTERN
316 const char*
318 /*===========================*/
319  const ulint id);
320 /*****************************************************************/
324 UNIV_INTERN
325 ibool
327 /*========================*/
328  ulint format_id,
329  const char** name);
331 /*****************************************************************/
334 UNIV_INTERN
335 const char*
337 /*=============================*/
338 /*****************************************************************/
341 UNIV_INTERN
342 ulint
344 /*==========================*/
345  ulint max_format_id);
346 /********************************************************************/
350 UNIV_INTERN
351 ibool
353 /*============================*/
354  const char** name,
355  ulint format_id);
356 #else /* !UNIV_HOTBACKUP */
357 /*****************************************************************/
363 UNIV_INTERN
364 ibool
365 trx_sys_read_file_format_id(
366 /*========================*/
367  const char *pathname,
369  ulint *format_id);
371 /*****************************************************************/
374 UNIV_INTERN
375 ibool
376 trx_sys_read_pertable_file_format_id(
377 /*=================================*/
378  const char *pathname,
380  ulint *format_id);
382 /*****************************************************************/
385 UNIV_INTERN
386 const char*
388 /*===========================*/
389  const ulint id);
391 #endif /* !UNIV_HOTBACKUP */
392 /*********************************************************************
393 Creates the rollback segments */
394 UNIV_INTERN
395 void
397 /*=================*/
398  ulint n_rsegs);
400 /* The automatically created system rollback segment has this id */
401 #define TRX_SYS_SYSTEM_RSEG_ID 0
402 
403 /* Space id and page no where the trx system file copy resides */
404 #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
405 #include "fsp0fsp.h"
406 #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
407 
408 /* The offset of the transaction system header on the page */
409 #define TRX_SYS FSEG_PAGE_DATA
410 
412 /*------------------------------------------------------------- @{ */
413 #define TRX_SYS_TRX_ID_STORE 0
425 #define TRX_SYS_FSEG_HEADER 8
428 #define TRX_SYS_RSEGS (8 + FSEG_HEADER_SIZE)
429 
432 /*------------------------------------------------------------- @} */
433 
434 /* Max number of rollback segments: the number of segment specification slots
435 in the transaction system array; rollback segment id must fit in one (signed)
436 byte, therefore 128; each slot is currently 8 bytes in size. If you want
437 to raise the level to 256 then you will need to fix some assertions that
438 impose the 7 bit restriction. e.g., mach_write_to_3() */
439 #define TRX_SYS_N_RSEGS 128
440 /* Originally, InnoDB defined TRX_SYS_N_RSEGS as 256 but created only one
441 rollback segment. It initialized some arrays with this number of entries.
442 We must remember this limit in order to keep file compatibility. */
443 #define TRX_SYS_OLD_N_RSEGS 256
444 
448 #define TRX_SYS_MYSQL_LOG_NAME_LEN 512
449 
450 #define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
451 
454 #define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000)
455 
457 #define TRX_SYS_DRIZZLE_LOG_INFO (UNIV_PAGE_SIZE - 1000)
458 #define TRX_SYS_DRIZZLE_MAX_COMMIT_ID 8
460 #define TRX_SYS_DRIZZLE_LOG_NAME 12
463 /* @{ */
464 
465 #define TRX_SYS_DOUBLEWRITE (UNIV_PAGE_SIZE - 200)
466 /*-------------------------------------------------------------*/
467 #define TRX_SYS_DOUBLEWRITE_FSEG 0
470 #define TRX_SYS_DOUBLEWRITE_MAGIC FSEG_HEADER_SIZE
475 #define TRX_SYS_DOUBLEWRITE_BLOCK1 (4 + FSEG_HEADER_SIZE)
476 
482 #define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE)
483 
488 #define TRX_SYS_DOUBLEWRITE_REPEAT 12
501 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE)
502 
503 /*-------------------------------------------------------------*/
505 #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855
506 
507 #define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386
508 
510 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE
511 /* @} */
512 
513 #ifndef UNIV_HOTBACKUP
514 
515 /* @{ */
518 #define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16)
519 
522 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL
523 
524 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH 2745987765UL
527 #define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N \
528  ((ib_uint64_t) TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_HIGH << 32 \
529  | TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW)
530 /* @} */
536  ulint block1;
538  ulint block2;
539  ulint first_free;
541  byte* write_buf;
545  byte* write_buf_unaligned;
547  buf_page_t**
550 };
554 struct trx_sys_struct{
559  UT_LIST_BASE_NODE_T(trx_t) trx_list;
563  UT_LIST_BASE_NODE_T(trx_t) mysql_trx_list;
566  UT_LIST_BASE_NODE_T(trx_rseg_t) rseg_list;
572  trx_rseg_t* rseg_array[TRX_SYS_N_RSEGS];
575  ulint rseg_history_len;
582 };
583 
587 #define TRX_SYS_TRX_ID_WRITE_MARGIN 256
588 #endif /* !UNIV_HOTBACKUP */
589 
590 #ifndef UNIV_NONINL
591 #include "trx0sys.ic"
592 #endif
594 #endif
trx_sys_t * trx_sys
Definition: trx0sys.cc:61
trx_doublewrite_t * trx_doublewrite
Definition: trx0sys.cc:63
UNIV_INLINE ulint trx_sysf_rseg_get_space(trx_sysf_t *sys_header, ulint i, mtr_t *mtr)
UNIV_INTERN void trx_sys_create_rsegs(ulint n_rsegs)
Definition: trx0sys.cc:1217
UNIV_INTERN void trx_sys_file_format_tag_init(void)
Definition: trx0sys.cc:1132
UNIV_INLINE trx_id_t trx_sys_get_new_trx_id(void)
UNIV_INTERN void trx_sys_file_format_init(void)
Definition: trx0sys.cc:1189
UNIV_INLINE trx_t * trx_get_on_id(trx_id_t trx_id)
UNIV_INLINE trx_sysf_t * trx_sysf_get(mtr_t *mtr)
UNIV_INLINE ibool trx_sys_hdr_page(ulint space, ulint page_no)
trx_id_t max_trx_id
Definition: trx0sys.h:579
UNIV_INTERN void trx_sys_doublewrite_init_or_restore_pages(ibool restore_corrupt_pages)
Definition: trx0sys.cc:430
UNIV_INLINE void trx_write_trx_id(byte *ptr, trx_id_t id)
UNIV_INTERN void trx_sys_file_format_close(void)
Definition: trx0sys.cc:1207
UNIV_INTERN const char * trx_sys_file_format_max_get(void)
Definition: trx0sys.cc:1179
ibool trx_sys_multiple_tablespace_format
Definition: trx0sys.cc:74
trx_rseg_t * rseg
Definition: trx0rseg.h:189
UNIV_INTERN ibool trx_sys_file_format_max_upgrade(const char **name, ulint format_id)
Definition: trx0sys.cc:1151
ibool trx_doublewrite_must_reset_space_ids
Definition: trx0sys.cc:67
UNIV_INTERN void trx_sys_init_at_db_start(void)
Definition: trx0sys.cc:849
UNIV_INLINE void trx_sys_set_nth_rseg(trx_sys_t *sys, ulint n, trx_rseg_t *rseg)
trx_rseg_t * latest_rseg
Definition: trx0sys.h:593
UNIV_INTERN void trx_sys_mark_upgraded_to_multiple_tablespaces(void)
Definition: trx0sys.cc:217
UNIV_INTERN void trx_sys_print_mysql_master_log_pos(void)
UT_LIST_BASE_NODE_T(trx_t) trx_list
UNIV_INLINE void trx_sysf_rseg_set_page_no(trx_sysf_t *sys_header, ulint i, ulint page_no, mtr_t *mtr)
UNIV_INTERN void trx_sys_read_commit_id(void)
Definition: trx0sys.cc:697
UNIV_INTERN void trx_sys_flush_commit_id(uint64_t commit_id, ulint field, mtr_t *mtr)
Definition: trx0sys.cc:684
UNIV_INTERN ibool trx_in_trx_list(trx_t *in_trx)
Definition: trx0sys.cc:638
ibool trx_doublewrite_buf_is_being_created
Definition: trx0sys.cc:69
UNIV_INTERN void trx_sys_close(void)
Definition: trx0sys.cc:1452
ulint rseg_history_len
Definition: trx0sys.h:599
UNIV_INTERN ulint trx_sys_file_format_max_check(ulint max_format_id)
Definition: trx0sys.cc:1051
UNIV_INLINE trx_id_t trx_list_get_min_trx_id(void)
UNIV_INLINE ibool trx_is_active(trx_id_t trx_id)
UNIV_INTERN ulint trx_sysf_rseg_find_free(mtr_t *mtr)
Definition: trx0sys.cc:718
ib_id_t trx_id_t
Definition: trx0types.h:85
UNIV_INTERN void trx_sys_create(void)
Definition: trx0sys.cc:943
UNIV_INLINE trx_id_t trx_read_trx_id(const byte *ptr)
UNIV_INLINE ulint trx_sysf_rseg_get_page_no(trx_sysf_t *sys_header, ulint i, mtr_t *mtr)
buf_page_t ** buf_block_arr
Definition: trx0sys.h:572
UNIV_INLINE void trx_sysf_rseg_set_space(trx_sysf_t *sys_header, ulint i, ulint space, mtr_t *mtr)
UNIV_INTERN void trx_sys_create_doublewrite_buf(void)
Definition: trx0sys.cc:252
UNIV_INTERN const char * trx_sys_file_format_id_to_name(const ulint id)
Definition: trx0sys.cc:1036
drizzled::atomic< uint64_t > trx_sys_commit_id
Definition: trx0sys.cc:96
trx_rseg_t * rseg_array[TRX_SYS_N_RSEGS]
Definition: trx0sys.h:596
UNIV_INTERN ibool trx_doublewrite_page_inside(ulint page_no)
Definition: trx0sys.cc:153
UNIV_INTERN ibool trx_sys_file_format_max_set(ulint format_id, const char **name)
Definition: trx0sys.cc:1102
byte trx_sysf_t
Definition: trx0types.h:101
byte * write_buf_unaligned
Definition: trx0sys.h:569
UNIV_INLINE trx_rseg_t * trx_sys_get_nth_rseg(trx_sys_t *sys, ulint n)