CUBRID Engine  latest
recovery.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * recovery.h: recovery functions (at server)
22  */
23 
24 #ifndef _RECOVERY_H_
25 #define _RECOVERY_H_
26 
27 #ident "$Id$"
28 
29 #include "error_manager.h"
30 #include "log_comm.h"
31 #include "log_lsa.hpp"
32 #include "thread_compat.hpp"
33 
34 #include <stdio.h>
35 
36 typedef enum
37 {
38  /*
39  * RULE *********************************************
40  *
41  * NEW ENTRIES SHOULD BE ADDED AT THE BOTTON OF THE FILE TO AVOID FULL RECOMPILATIONS (e.g., the file can be utimed)
42  * and to AVOID OLD DATABASES TO BE RECOVERED UNDER OLD FILE */
53 
54  RVFL_DESTROY = 10, /* Use for undo/postpone */
56  RVFL_ALLOC = 12,
77 
80  RVHF_STATS = 35,
81  RVHF_CHAIN = 36,
95  RVHF_INSERT_NEWHOME = 50, /* Same as RVHF_INSERT but no replication */
99 
100  RVOVF_NEWPAGE_INSERT = 54, /* required for HA */
104 
113 
140 
146 
148 
155 
170 
172 
174 
179 
183 
186 
188 
190 } LOG_RCVINDEX;
191 
192 /*
193  * RECOVERY STRUCTURE SEEN BY RECOVERY FUNCTIONS
194  */
195 typedef struct log_rcv LOG_RCV;
196 struct log_rcv
197 { /* Recovery information */
198  MVCCID mvcc_id; /* mvcc id */
199  PAGE_PTR pgptr; /* Page to recover. Page should not be free by recovery functions, however it should be
200  * set dirty whenever is needed */
201  PGLENGTH offset; /* Offset/slot of data in the above page to recover */
202  int length; /* Length of data */
203  const char *data; /* Replacement data. Pointer becomes invalid once the recovery of the data is finished */
204  LOG_LSA reference_lsa; /* Next LSA used by compensate/postpone. */
205 };
206 
207 /*
208  * STRUCTURE ENTRY OF RECOVERY FUNCTIONS
209  */
210 
211 struct rvfun
212 {
213  LOG_RCVINDEX recv_index; /* For verification */
214  const char *recv_string;
215  int (*undofun) (THREAD_ENTRY * thread_p, LOG_RCV * logrcv);
216  int (*redofun) (THREAD_ENTRY * thread_p, LOG_RCV * logrcv);
217  void (*dump_undofun) (FILE * fp, int length, void *data);
218  void (*dump_redofun) (FILE * fp, int length, void *data);
219 };
220 
221 extern struct rvfun RV_fun[];
222 
223 extern const char *rv_rcvindex_string (LOG_RCVINDEX rcvindex);
224 #if !defined (NDEBUG)
225 extern void rv_check_rvfuns (void);
226 #endif /* !NDEBUG */
227 
228 #define RCV_IS_BTREE_LOGICAL_LOG(idx) \
229  ((idx) == RVBT_DELETE_OBJECT_PHYSICAL \
230  || (idx) == RVBT_MVCC_DELETE_OBJECT \
231  || (idx) == RVBT_MVCC_INSERT_OBJECT \
232  || (idx) == RVBT_NON_MVCC_INSERT_OBJECT \
233  || (idx) == RVBT_MARK_DELETED \
234  || (idx) == RVBT_DELETE_OBJECT_POSTPONE \
235  || (idx) == RVBT_MVCC_INSERT_OBJECT_UNQ \
236  || (idx) == RVBT_MVCC_NOTIFY_VACUUM \
237  || (idx) == RVBT_ONLINE_INDEX_UNDO_TRAN_DELETE \
238  || (idx) == RVBT_ONLINE_INDEX_UNDO_TRAN_INSERT)
239 
240 #define RCV_IS_LOGICAL_COMPENSATE_MANUAL(idx) \
241  (RCV_IS_BTREE_LOGICAL_LOG(idx) \
242  || (idx) == RVFL_ALLOC \
243  || (idx) == RVFL_USER_PAGE_MARK_DELETE \
244  || (idx) == RVPGBUF_DEALLOC \
245  || (idx) == RVFL_TRACKER_HEAP_REUSE \
246  || (idx) == RVFL_TRACKER_UNREGISTER)
247 #define RCV_IS_LOGICAL_RUN_POSTPONE_MANUAL(idx) \
248  ((idx) == RVFL_DEALLOC \
249  || (idx) == RVHF_MARK_DELETED \
250  || (idx) == RVBT_DELETE_OBJECT_POSTPONE)
251 
252 #define RCV_IS_LOGICAL_LOG(vpid, idx) \
253  (((vpid)->volid == NULL_VOLID) \
254  || ((vpid)->pageid == NULL_PAGEID) \
255  || RCV_IS_BTREE_LOGICAL_LOG (idx) \
256  || (idx) == RVBT_MVCC_INCREMENTS_UPD \
257  || (idx) == RVPGBUF_FLUSH_PAGE \
258  || (idx) == RVFL_DESTROY \
259  || (idx) == RVFL_ALLOC \
260  || (idx) == RVFL_DEALLOC \
261  || (idx) == RVVAC_NOTIFY_DROPPED_FILE \
262  || (idx) == RVPGBUF_DEALLOC \
263  || (idx) == RVES_NOTIFY_VACUUM \
264  || (idx) == RVHF_MARK_DELETED \
265  || (idx) == RVFL_TRACKER_HEAP_REUSE \
266  || (idx) == RVFL_TRACKER_UNREGISTER)
267 
268 #define RCV_IS_NEW_PAGE_INIT(idx) \
269  ((idx) == RVPGBUF_NEW_PAGE \
270  || (idx) == RVDK_FORMAT \
271  || (idx) == RVDK_INITMAP \
272  || (idx) == RVHF_NEWPAGE \
273  || (idx) == RVEH_INIT_BUCKET \
274  || (idx) == RVEH_INIT_NEW_DIR_PAGE \
275  || (idx) == RVBT_GET_NEWPAGE \
276  || (idx) == RVCT_NEWPAGE \
277  || (idx) == RVHF_CREATE_HEADER)
278 
279 #endif /* _RECOVERY_H_ */
PGLENGTH offset
Definition: recovery.h:201
char * PAGE_PTR
LOG_RCVINDEX
Definition: recovery.h:36
const char * rv_rcvindex_string(LOG_RCVINDEX rcvindex)
Definition: recovery.c:846
MVCCID mvcc_id
Definition: recovery.h:198
void THREAD_ENTRY
struct rvfun RV_fun[]
Definition: recovery.c:49
PAGE_PTR pgptr
Definition: recovery.h:199
const char * recv_string
Definition: recovery.h:214
void rv_check_rvfuns(void)
Definition: recovery.c:861
int length
Definition: recovery.h:202
UINT64 MVCCID
LOG_LSA reference_lsa
Definition: recovery.h:204
const char * data
Definition: recovery.h:203
LOG_RCVINDEX recv_index
Definition: recovery.h:213
INT16 PGLENGTH