drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
trx0sys.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1996, 2011, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
25
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
49extern drizzled::atomic<uint64_t> trx_sys_commit_id;
50
52extern trx_sys_t* trx_sys;
53
65
66/****************************************************************/
69UNIV_INTERN
70void
72/*================================*/
73/****************************************************************/
80UNIV_INTERN
81void
83/*======================================*/
84 ibool restore_corrupt_pages);
85/****************************************************************/
88UNIV_INTERN
89void
91/*===============================================*/
92/****************************************************************/
96UNIV_INTERN
97ibool
99/*========================*/
100 ulint page_no);
101/***************************************************************/
104UNIV_INLINE
105ibool
107/*=============*/
108 ulint space,
109 ulint page_no);
110/*****************************************************************/
113UNIV_INTERN
114void
116/*==========================*/
117/*****************************************************************/
119UNIV_INTERN
120void
121trx_sys_create(void);
122/*================*/
123/****************************************************************/
126UNIV_INTERN
127ulint
129/*====================*/
130 mtr_t* mtr);
131/***************************************************************/
134UNIV_INLINE
137/*=================*/
138 trx_sys_t* sys,
139 ulint n);
140/***************************************************************/
142UNIV_INLINE
143void
145/*=================*/
146 trx_sys_t* sys,
147 ulint n,
148 trx_rseg_t* rseg);
150/**********************************************************************/
153UNIV_INLINE
156/*=========*/
157 mtr_t* mtr);
158/*****************************************************************/
162UNIV_INLINE
163ulint
165/*====================*/
166 trx_sysf_t* sys_header,
167 ulint i,
168 mtr_t* mtr);
169/*****************************************************************/
173UNIV_INLINE
174ulint
176/*======================*/
177 trx_sysf_t* sys_header,
178 ulint i,
179 mtr_t* mtr);
180/*****************************************************************/
183UNIV_INLINE
184void
186/*====================*/
187 trx_sysf_t* sys_header,
188 ulint i,
189 ulint space,
190 mtr_t* mtr);
191/*****************************************************************/
194UNIV_INLINE
195void
197/*======================*/
198 trx_sysf_t* sys_header,
199 ulint i,
200 ulint page_no,
202 mtr_t* mtr);
203/*****************************************************************/
206UNIV_INLINE
209/*========================*/
210#endif /* !UNIV_HOTBACKUP */
211/*****************************************************************/
215UNIV_INLINE
216void
218/*=============*/
219 byte* ptr,
220 trx_id_t id);
221#ifndef UNIV_HOTBACKUP
222/*****************************************************************/
227UNIV_INLINE
230/*============*/
231 const byte* ptr);
232/****************************************************************/
235UNIV_INLINE
236trx_t*
238/*==========*/
239 trx_id_t trx_id);
240/****************************************************************/
246UNIV_INLINE
249/*=========================*/
250/****************************************************************/
253UNIV_INLINE
254ibool
256/*==========*/
257 trx_id_t trx_id);
258/****************************************************************/
261UNIV_INTERN
262ibool
264/*============*/
265 trx_t* in_trx);
266/*****************************************************************/
268UNIV_INTERN
269void
270trx_sys_flush_commit_id(uint64_t commit_id, ulint field, mtr_t* mtr);
271/*****************************************************************/
273UNIV_INTERN
274void
276/*****************************************************************/
279UNIV_INTERN
280void
282/*====================================*/
283/*****************************************************************/
285UNIV_INTERN
286void
288/*==========================*/
289/*****************************************************************/
291UNIV_INTERN
292void
294/*===========================*/
295/********************************************************************/
300UNIV_INTERN
301void
303/*==============================*/
304#ifndef UNIV_HOTBACKUP
305/*****************************************************************/
307UNIV_INTERN
308void
309trx_sys_close(void);
310/*===============*/
311#endif /* !UNIV_HOTBACKUP */
312/*****************************************************************/
315UNIV_INTERN
316const char*
318/*===========================*/
319 const ulint id);
320/*****************************************************************/
324UNIV_INTERN
325ibool
327/*========================*/
328 ulint format_id,
329 const char** name);
331/*****************************************************************/
334UNIV_INTERN
335const char*
337/*=============================*/
338/*****************************************************************/
341UNIV_INTERN
342ulint
344/*==========================*/
345 ulint max_format_id);
346/********************************************************************/
350UNIV_INTERN
351ibool
353/*============================*/
354 const char** name,
355 ulint format_id);
356#else /* !UNIV_HOTBACKUP */
357/*****************************************************************/
363UNIV_INTERN
364ibool
365trx_sys_read_file_format_id(
366/*========================*/
367 const char *pathname,
369 ulint *format_id);
371/*****************************************************************/
374UNIV_INTERN
375ibool
376trx_sys_read_pertable_file_format_id(
377/*=================================*/
378 const char *pathname,
380 ulint *format_id);
382/*****************************************************************/
385UNIV_INTERN
386const char*
388/*===========================*/
389 const ulint id);
390
391#endif /* !UNIV_HOTBACKUP */
392/*********************************************************************
393Creates the rollback segments */
394UNIV_INTERN
395void
397/*=================*/
398 ulint n_rsegs);
399
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)
432/*------------------------------------------------------------- @} */
433
434/* Max number of rollback segments: the number of segment specification slots
435in the transaction system array; rollback segment id must fit in one (signed)
436byte, therefore 128; each slot is currently 8 bytes in size. If you want
437to raise the level to 256 then you will need to fix some assertions that
438impose 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
441rollback segment. It initialized some arrays with this number of entries.
442We 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
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
461
463/* @{ */
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)
482#define TRX_SYS_DOUBLEWRITE_BLOCK2 (8 + FSEG_HEADER_SIZE)
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
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
515/* @{ */
518#define TRX_SYS_FILE_FORMAT_TAG (UNIV_PAGE_SIZE - 16)
519
522#define TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW 3645922177UL
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/* @} */
531
551
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
593
594#endif
struct buf_page_struct buf_page_t
Definition buf0types.h:31
buf_page_t ** buf_block_arr
Definition trx0sys.h:548
trx_id_t max_trx_id
Definition trx0sys.h:555
UT_LIST_BASE_NODE_T(read_view_t) view_list
trx_rseg_t * rseg_array[TRX_SYS_N_RSEGS]
Definition trx0sys.h:572
UT_LIST_BASE_NODE_T(trx_rseg_t) rseg_list
ulint rseg_history_len
Definition trx0sys.h:575
trx_rseg_t * latest_rseg
Definition trx0sys.h:569
UT_LIST_BASE_NODE_T(trx_t) mysql_trx_list
UT_LIST_BASE_NODE_T(trx_t) trx_list
#define mutex_t
Definition sync0types.h:31
UNIV_INTERN ibool trx_sys_file_format_max_set(ulint format_id, const char **name)
Definition trx0sys.cc:1102
UNIV_INTERN ulint trx_sysf_rseg_find_free(mtr_t *mtr)
Definition trx0sys.cc:718
ibool trx_doublewrite_buf_is_being_created
Definition trx0sys.cc:69
UNIV_INTERN ulint trx_sys_file_format_max_check(ulint max_format_id)
Definition trx0sys.cc:1051
UNIV_INTERN void trx_sys_file_format_close(void)
Definition trx0sys.cc:1207
UNIV_INTERN void trx_sys_mark_upgraded_to_multiple_tablespaces(void)
Definition trx0sys.cc:217
UNIV_INLINE trx_id_t trx_sys_get_new_trx_id(void)
UNIV_INTERN void trx_sys_create_doublewrite_buf(void)
Definition trx0sys.cc:252
UNIV_INTERN void trx_sys_read_commit_id(void)
Definition trx0sys.cc:697
UNIV_INTERN const char * trx_sys_file_format_max_get(void)
Definition trx0sys.cc:1179
UNIV_INLINE ulint trx_sysf_rseg_get_space(trx_sysf_t *sys_header, ulint i, mtr_t *mtr)
UNIV_INTERN const char * trx_sys_file_format_id_to_name(const ulint id)
Definition trx0sys.cc:1036
UNIV_INTERN void trx_sys_doublewrite_init_or_restore_pages(ibool restore_corrupt_pages)
Definition trx0sys.cc:430
UNIV_INLINE trx_rseg_t * trx_sys_get_nth_rseg(trx_sys_t *sys, ulint n)
UNIV_INTERN void trx_sys_init_at_db_start(void)
Definition trx0sys.cc:849
UNIV_INLINE void trx_sysf_rseg_set_page_no(trx_sysf_t *sys_header, ulint i, ulint page_no, mtr_t *mtr)
UNIV_INLINE ulint trx_sysf_rseg_get_page_no(trx_sysf_t *sys_header, ulint i, mtr_t *mtr)
ibool trx_sys_multiple_tablespace_format
Definition trx0sys.cc:74
UNIV_INLINE void trx_sysf_rseg_set_space(trx_sysf_t *sys_header, ulint i, ulint space, mtr_t *mtr)
UNIV_INLINE trx_id_t trx_read_trx_id(const byte *ptr)
UNIV_INTERN void trx_sys_create(void)
Definition trx0sys.cc:943
UNIV_INLINE void trx_write_trx_id(byte *ptr, trx_id_t id)
UNIV_INLINE trx_id_t trx_list_get_min_trx_id(void)
ibool trx_doublewrite_must_reset_space_ids
Definition trx0sys.cc:67
UNIV_INLINE trx_sysf_t * trx_sysf_get(mtr_t *mtr)
UNIV_INLINE void trx_sys_set_nth_rseg(trx_sys_t *sys, ulint n, trx_rseg_t *rseg)
UNIV_INLINE ibool trx_is_active(trx_id_t trx_id)
trx_doublewrite_t * trx_doublewrite
Definition trx0sys.cc:63
UNIV_INTERN ibool trx_in_trx_list(trx_t *in_trx)
Definition trx0sys.cc:638
UNIV_INTERN void trx_sys_close(void)
Definition trx0sys.cc:1452
UNIV_INTERN ibool trx_sys_file_format_max_upgrade(const char **name, ulint format_id)
Definition trx0sys.cc:1151
UNIV_INTERN void trx_sys_flush_commit_id(uint64_t commit_id, ulint field, mtr_t *mtr)
Definition trx0sys.cc:684
UNIV_INLINE trx_t * trx_get_on_id(trx_id_t trx_id)
UNIV_INLINE ibool trx_sys_hdr_page(ulint space, ulint page_no)
trx_sys_t * trx_sys
Definition trx0sys.cc:61
UNIV_INTERN ibool trx_doublewrite_page_inside(ulint page_no)
Definition trx0sys.cc:153
UNIV_INTERN void trx_sys_print_mysql_master_log_pos(void)
UNIV_INTERN void trx_sys_file_format_init(void)
Definition trx0sys.cc:1189
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
drizzled::atomic< uint64_t > trx_sys_commit_id
Definition trx0sys.cc:96
struct trx_doublewrite_struct trx_doublewrite_t
Definition trx0types.h:46
struct trx_sys_struct trx_sys_t
Definition trx0types.h:44
ib_id_t trx_id_t
Definition trx0types.h:85
byte trx_sysf_t
Definition trx0types.h:101
struct trx_rseg_struct trx_rseg_t
Definition trx0types.h:50