1
/******************************************************
6
Created 3/26/1996 Heikki Tuuri
7
*******************************************************/
13
#include "trx0types.h"
16
/**********************************************************************
17
Gets a rollback segment header. */
22
/* out: rollback segment header, page
24
ulint space, /* in: space where placed */
25
ulint page_no, /* in: page number of the header */
26
mtr_t* mtr); /* in: mtr */
27
/**********************************************************************
28
Gets a newly created rollback segment header. */
33
/* out: rollback segment header, page
35
ulint space, /* in: space where placed */
36
ulint page_no, /* in: page number of the header */
37
mtr_t* mtr); /* in: mtr */
38
/*******************************************************************
39
Gets the file page number of the nth undo log slot. */
42
trx_rsegf_get_nth_undo(
43
/*===================*/
44
/* out: page number of the undo log segment */
45
trx_rsegf_t* rsegf, /* in: rollback segment header */
46
ulint n, /* in: index of slot */
47
mtr_t* mtr); /* in: mtr */
48
/*******************************************************************
49
Sets the file page number of the nth undo log slot. */
52
trx_rsegf_set_nth_undo(
53
/*===================*/
54
trx_rsegf_t* rsegf, /* in: rollback segment header */
55
ulint n, /* in: index of slot */
56
ulint page_no,/* in: page number of the undo log segment */
57
mtr_t* mtr); /* in: mtr */
58
/********************************************************************
59
Looks for a free slot for an undo log segment. */
62
trx_rsegf_undo_find_free(
63
/*=====================*/
64
/* out: slot index or ULINT_UNDEFINED if not
66
trx_rsegf_t* rsegf, /* in: rollback segment header */
67
mtr_t* mtr); /* in: mtr */
68
/**********************************************************************
69
Looks for a rollback segment, based on the rollback segment id. */
74
/* out: rollback segment */
75
ulint id); /* in: rollback segment id */
76
/********************************************************************
77
Creates a rollback segment header. This function is called only when
78
a new rollback segment is created in the database. */
81
trx_rseg_header_create(
82
/*===================*/
83
/* out: page number of the created segment,
85
ulint space, /* in: space id */
86
ulint max_size, /* in: max size in pages */
87
ulint* slot_no, /* out: rseg id == slot number in trx sys */
88
mtr_t* mtr); /* in: mtr */
89
/*************************************************************************
90
Creates the memory copies for rollback segments and initializes the
91
rseg list and array in trx_sys at a database startup. */
94
trx_rseg_list_and_array_init(
95
/*=========================*/
96
trx_sysf_t* sys_header, /* in: trx system header */
97
mtr_t* mtr); /* in: mtr */
98
/********************************************************************
99
Creates a new rollback segment to the database. */
104
/* out: the created segment object, NULL if
106
ulint space, /* in: space id */
107
ulint max_size, /* in: max size in pages */
108
ulint* id, /* out: rseg id */
109
mtr_t* mtr); /* in: mtr */
112
/* Number of undo log slots in a rollback segment file copy */
113
#define TRX_RSEG_N_SLOTS 1024
115
/* Maximum number of transactions supported by a single rollback segment */
116
#define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2)
118
/* The rollback segment memory object */
119
struct trx_rseg_struct{
120
/*--------------------------------------------------------*/
121
ulint id; /* rollback segment id == the index of
122
its slot in the trx system file copy */
123
mutex_t mutex; /* mutex protecting the fields in this
124
struct except id; NOTE that the latching
125
order must always be kernel mutex ->
127
ulint space; /* space where the rollback segment is
129
ulint page_no;/* page number of the rollback segment
131
ulint max_size;/* maximum allowed size in pages */
132
ulint curr_size;/* current size in pages */
133
/*--------------------------------------------------------*/
134
/* Fields for update undo logs */
135
UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_list;
136
/* List of update undo logs */
137
UT_LIST_BASE_NODE_T(trx_undo_t) update_undo_cached;
138
/* List of update undo log segments
139
cached for fast reuse */
140
/*--------------------------------------------------------*/
141
/* Fields for insert undo logs */
142
UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_list;
143
/* List of insert undo logs */
144
UT_LIST_BASE_NODE_T(trx_undo_t) insert_undo_cached;
145
/* List of insert undo log segments
146
cached for fast reuse */
147
/*--------------------------------------------------------*/
148
ulint last_page_no; /* Page number of the last not yet
149
purged log header in the history list;
150
FIL_NULL if all list purged */
151
ulint last_offset; /* Byte offset of the last not yet
153
dulint last_trx_no; /* Transaction number of the last not
155
ibool last_del_marks; /* TRUE if the last not yet purged log
157
/*--------------------------------------------------------*/
158
UT_LIST_NODE_T(trx_rseg_t) rseg_list;
159
/* the list of the rollback segment
163
/* Undo log segment slot in a rollback segment header */
164
/*-------------------------------------------------------------*/
165
#define TRX_RSEG_SLOT_PAGE_NO 0 /* Page number of the header page of
166
an undo log segment */
167
/*-------------------------------------------------------------*/
169
#define TRX_RSEG_SLOT_SIZE 4
171
/* The offset of the rollback segment header on its page */
172
#define TRX_RSEG FSEG_PAGE_DATA
174
/* Transaction rollback segment header */
175
/*-------------------------------------------------------------*/
176
#define TRX_RSEG_MAX_SIZE 0 /* Maximum allowed size for rollback
178
#define TRX_RSEG_HISTORY_SIZE 4 /* Number of file pages occupied
179
by the logs in the history list */
180
#define TRX_RSEG_HISTORY 8 /* The update undo logs for committed
182
#define TRX_RSEG_FSEG_HEADER (8 + FLST_BASE_NODE_SIZE)
183
/* Header for the file segment where
184
this page is placed */
185
#define TRX_RSEG_UNDO_SLOTS (8 + FLST_BASE_NODE_SIZE + FSEG_HEADER_SIZE)
186
/* Undo log segment slots */
187
/*-------------------------------------------------------------*/
190
#include "trx0rseg.ic"