CUBRID Engine  latest
boot_sr.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  * boot_sr.h - Boot managment in the server (interface)
22  *
23  * Note: See .c file for overview and description of the interface functions.
24  *
25  */
26 
27 #ifndef _BOOT_SR_H_
28 #define _BOOT_SR_H_
29 
30 #ident "$Id$"
31 
32 #include "config.h"
33 
34 #include <time.h>
35 
36 #include "boot.h"
37 #include "error_manager.h"
38 #include "storage_common.h"
39 #include "oid.h"
40 #include "disk_manager.h"
41 #include "log_comm.h"
42 #include "log_lsa.hpp"
43 #include "file_io.h"
44 #include "tde.h"
45 
46 #if defined (SERVER_MODE)
47 #define AUTO_ADD_VOL_EXPAND_NPAGES (20)
48 
49 typedef struct auto_addvol_job AUTO_ADDVOL_JOB;
50 struct auto_addvol_job
51 {
52  pthread_mutex_t lock;
53  pthread_cond_t cond;
54  DBDEF_VOL_EXT_INFO ext_info;
55  VOLID ret_volid;
56 };
57 
58 #define BOOT_AUTO_ADDVOL_JOB_INITIALIZER \
59  { PTHREAD_MUTEX_INITIALIZER, \
60  PTHREAD_COND_INITIALIZER, \
61  {NULL, NULL, NULL, 0, 0, 0, DISK_PERMVOL_DATA_PURPOSE, false},\
62  NULL_VOLID \
63  };
64 
65 #endif
66 
71 
75 
76 typedef struct check_args CHECK_ARGS;
77 
78 struct check_args
79 {
82 };
83 
84 #define BO_IS_SERVER_RESTARTED() \
85  (boot_Server_status == BOOT_SERVER_UP \
86  || boot_Server_status == BOOT_SERVER_MAINTENANCE)
87 
88 extern void boot_server_status (BOOT_SERVER_STATUS status);
89 
90 /* structure for passing arguments into boot_restart_server et. al. */
93 {
94  bool printtoc; /* True to show backup's table of contents */
95  time_t stopat; /* the recovery stop time if restarting from backup */
96  const char *backuppath; /* Pathname override for location of backup volumes */
97  int level; /* The backup level to use */
98  const char *verbose_file; /* restoredb verbose msg file */
99  bool newvolpath; /* true: restore the database and log volumes to the path specified in the
100  * database-loc-file */
102 
103  bool restore_slave; /* restore slave */
105  INT64 db_creation; /* database creation time */
106  LOG_LSA restart_repl_lsa; /* restart replication lsa after restoreslave */
107  char keys_file_path[PATH_MAX]; /* Master Key File (_keys) path for TDE. If it is not NULL, it is used, not the keys spcified system parameter or from default path */
108 };
109 
110 #if defined(SERVER_MODE)
111 /* in xserver_interface.h */
112 extern void boot_donot_shutdown_server_at_exit (void);
113 extern void xboot_notify_unregister_client (THREAD_ENTRY * thread_p, int tran_index);
114 #endif /* SERVER_MODE */
115 
116 extern const char *boot_db_name (void);
117 extern const char *boot_db_full_name (void);
118 #if !defined(CS_MODE)
119 extern const char *boot_get_lob_path (void);
120 #endif /* !CS_MODE */
121 int boot_find_root_heap (HFID * root_hfid_p);
122 
124 extern int boot_reset_db_parm (THREAD_ENTRY * thread_p);
125 
126 extern int boot_restart_server (THREAD_ENTRY * thread_p, bool print_restart, const char *db_name, bool from_backup,
127  CHECK_ARGS * check_coll_and_timezone, BO_RESTART_ARG * r_args, bool skip_vacuum);
128 extern int xboot_restart_from_backup (THREAD_ENTRY * thread_p, int print_restart, const char *db_name,
129  BO_RESTART_ARG * r_args);
131 extern bool xboot_shutdown_server (REFPTR (THREAD_ENTRY, thread_p), ER_FINAL_CODE is_er_final);
132 extern int xboot_copy (REFPTR (THREAD_ENTRY, thread_p), const char *from_dbname, const char *new_db_name,
133  const char *new_db_path, const char *new_log_path, const char *new_lob_path,
134  const char *new_db_server_host, const char *new_volext_path,
135  const char *fileof_vols_and_copypaths, bool new_db_overwrite);
136 extern int xboot_soft_rename (THREAD_ENTRY * thread_p, const char *old_db_name, const char *new_db_name,
137  const char *new_db_path, const char *new_log_path, const char *new_db_server_host,
138  const char *new_volext_path, const char *fileof_vols_and_renamepaths,
139  bool new_db_overwrite, bool extern_rename, bool force_delete);
140 extern int xboot_delete (const char *db_name, bool force_delete, BOOT_SERVER_SHUTDOWN_MODE shutdown_common_modules);
141 extern int xboot_emergency_patch (const char *db_name, bool recreate_log, DKNPAGES log_npages, const char *db_locale,
142  FILE * out_fp);
143 extern void boot_server_all_finalize (THREAD_ENTRY * thread_p, ER_FINAL_CODE is_er_final,
144  BOOT_SERVER_SHUTDOWN_MODE shutdown_common_modules);
145 extern int boot_compact_db (THREAD_ENTRY * thread_p, OID * class_oids, int n_classes, int space_to_process,
146  int instance_lock_timeout, int class_lock_timeout, bool delete_old_repr,
147  OID * last_processed_class_oid, OID * last_processed_oid, int *total_objects,
148  int *failed_objects, int *modified_objects, int *big_objects, int *initial_last_repr_id);
149 extern int boot_heap_compact_pages (THREAD_ENTRY * thread_p, OID * class_oid);
150 extern int boot_compact_start (THREAD_ENTRY * thread_p);
151 extern int boot_compact_stop (THREAD_ENTRY * thread_p);
152 extern bool boot_can_compact (THREAD_ENTRY * thread_p);
153 extern bool boot_set_skip_check_ct_classes (bool val);
154 extern const char *boot_client_type_to_string (BOOT_CLIENT_TYPE type);
155 
156 extern int boot_get_new_volume_name_and_id (THREAD_ENTRY * thread_p, DB_VOLTYPE voltype, const char *given_path,
157  const char *given_name, char *fullname_newvol_out,
158  VOLID * volid_newvol_out);
159 extern int boot_dbparm_save_volume (THREAD_ENTRY * thread_p, DB_VOLTYPE voltype, VOLID volid);
160 #endif /* _BOOT_SR_H_ */
LOG_LSA restart_repl_lsa
Definition: boot_sr.h:106
int xboot_restart_from_backup(THREAD_ENTRY *thread_p, int print_restart, const char *db_name, BO_RESTART_ARG *r_args)
Definition: boot_sr.c:2850
const char * verbose_file
Definition: boot_sr.h:98
const char * boot_client_type_to_string(BOOT_CLIENT_TYPE type)
Definition: boot_sr.c:5950
bool restore_slave
Definition: boot_sr.h:103
VOLID boot_find_next_permanent_volid(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:425
bool check_db_coll
Definition: boot_sr.h:80
INT64 db_creation
Definition: boot_sr.h:105
const char * boot_db_name(void)
Definition: boot_sr.c:459
boot_server_shutdown_mode
Definition: boot_sr.h:72
const char * backuppath
Definition: boot_sr.h:96
enum db_client_type BOOT_CLIENT_TYPE
PAGEID DKNPAGES
bool boot_set_skip_check_ct_classes(bool val)
Definition: boot_sr.c:5902
int boot_reset_db_parm(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:447
time_t stopat
Definition: boot_sr.h:95
const char * boot_get_lob_path(void)
Definition: boot_sr.c:479
int boot_get_new_volume_name_and_id(THREAD_ENTRY *thread_p, DB_VOLTYPE voltype, const char *given_path, const char *given_name, char *fullname_newvol_out, VOLID *volid_newvol_out)
Definition: boot_sr.c:5995
INT16 VOLID
void boot_server_all_finalize(THREAD_ENTRY *thread_p, ER_FINAL_CODE is_er_final, BOOT_SERVER_SHUTDOWN_MODE shutdown_common_modules)
Definition: boot_sr.c:3864
int xboot_emergency_patch(const char *db_name, bool recreate_log, DKNPAGES log_npages, const char *db_locale, FILE *out_fp)
Definition: boot_sr.c:5335
int boot_heap_compact_pages(THREAD_ENTRY *thread_p, OID *class_oid)
Definition: compactdb_sr.c:679
void THREAD_ENTRY
int boot_dbparm_save_volume(THREAD_ENTRY *thread_p, DB_VOLTYPE voltype, VOLID volid)
Definition: boot_sr.c:6069
enum boot_server_status BOOT_SERVER_STATUS
Definition: boot_sr.h:69
bool check_timezone
Definition: boot_sr.h:81
#define REFPTR(T, name)
Definition: porting.h:1089
bool is_restore_from_backup
Definition: boot_sr.h:104
BOOT_SERVER_STATUS boot_Server_status
Definition: boot_sr.c:148
static int total_objects
Definition: compactdb.c:56
int boot_compact_stop(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:724
static int failed_objects
Definition: compactdb.c:57
char * db_name
int xboot_soft_rename(THREAD_ENTRY *thread_p, const char *old_db_name, const char *new_db_name, const char *new_db_path, const char *new_log_path, const char *new_db_server_host, const char *new_volext_path, const char *fileof_vols_and_renamepaths, bool new_db_overwrite, bool extern_rename, bool force_delete)
Definition: boot_sr.c:4381
bool restore_upto_bktime
Definition: boot_sr.h:101
int xboot_copy(REFPTR(THREAD_ENTRY, thread_p), const char *from_dbname, const char *new_db_name, const char *new_db_path, const char *new_log_path, const char *new_lob_path, const char *new_db_server_host, const char *new_volext_path, const char *fileof_vols_and_copypaths, bool new_db_overwrite)
Definition: boot_sr.c:3975
DB_VOLTYPE
Definition: dbtype_def.h:192
enum boot_server_shutdown_mode BOOT_SERVER_SHUTDOWN_MODE
Definition: boot_sr.h:74
int boot_restart_server(THREAD_ENTRY *thread_p, bool print_restart, const char *db_name, bool from_backup, CHECK_ARGS *check_coll_and_timezone, BO_RESTART_ARG *r_args, bool skip_vacuum)
Definition: boot_sr.c:2046
int boot_reset_mk_after_restart_from_backup(THREAD_ENTRY *thread_p, BO_RESTART_ARG *r_args)
Definition: boot_sr.c:2941
boot_server_status
Definition: boot_sr.h:67
int xboot_delete(const char *db_name, bool force_delete, BOOT_SERVER_SHUTDOWN_MODE shutdown_common_modules)
Definition: boot_sr.c:4653
bool xboot_shutdown_server(REFPTR(THREAD_ENTRY, thread_p), ER_FINAL_CODE is_er_final)
Definition: boot_sr.c:3080
int boot_compact_db(THREAD_ENTRY *thread_p, OID *class_oids, int n_classes, int space_to_process, int instance_lock_timeout, int class_lock_timeout, bool delete_old_repr, OID *last_processed_class_oid, OID *last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects, int *big_objects, int *initial_last_repr_id)
Definition: compactdb_sr.c:516
const char * boot_db_full_name(void)
Definition: boot_sr.c:470
int boot_compact_start(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:694
bool printtoc
Definition: boot_sr.h:94
bool newvolpath
Definition: boot_sr.h:99
enum er_final_code ER_FINAL_CODE
int boot_find_root_heap(HFID *root_hfid_p)
Definition: boot_sr.c:325
bool boot_can_compact(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:753