MySQL  8.0.20
Source Code Documentation
clone0api.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2018, 2019, Oracle and/or its affiliates. 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, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/clone0api.h
28  Innodb Clone Interface
29 
30  *******************************************************/
31 
32 #ifndef CLONE_API_INCLUDE
33 #define CLONE_API_INCLUDE
34 
35 #include "univ.i"
36 #ifndef UNIV_HOTBACKUP
37 #include "sql/handler.h"
38 
39 /** Get capability flags for clone operation
40 @param[out] flags capability flag */
42 
43 /** Begin copy from source database
44 @param[in] hton handlerton for SE
45 @param[in] thd server thread handle
46 @param[in,out] loc locator
47 @param[in,out] loc_len locator length
48 @param[out] task_id task identifier
49 @param[in] type clone type
50 @param[in] mode mode for starting clone
51 @return error code */
52 int innodb_clone_begin(handlerton *hton, THD *thd, const byte *&loc,
53  uint &loc_len, uint &task_id, Ha_clone_type type,
54  Ha_clone_mode mode);
55 
56 /** Copy data from source database in chunks via callback
57 @param[in] hton handlerton for SE
58 @param[in] thd server thread handle
59 @param[in] loc locator
60 @param[in] loc_len locator length in bytes
61 @param[in] task_id task identifier
62 @param[in] cbk callback interface for sending data
63 @return error code */
64 int innodb_clone_copy(handlerton *hton, THD *thd, const byte *loc, uint loc_len,
65  uint task_id, Ha_clone_cbk *cbk);
66 
67 /** Acknowledge data to source database
68 @param[in] hton handlerton for SE
69 @param[in] thd server thread handle
70 @param[in] loc locator
71 @param[in] loc_len locator length in bytes
72 @param[in] task_id task identifier
73 @param[in] in_err inform any error occurred
74 @param[in] cbk callback interface for receiving data
75 @return error code */
76 int innodb_clone_ack(handlerton *hton, THD *thd, const byte *loc, uint loc_len,
77  uint task_id, int in_err, Ha_clone_cbk *cbk);
78 
79 /** End copy from source database
80 @param[in] hton handlerton for SE
81 @param[in] thd server thread handle
82 @param[in] loc locator
83 @param[in] loc_len locator length in bytes
84 @param[in] task_id task identifier
85 @param[in] in_err error code when ending after error
86 @return error code */
87 int innodb_clone_end(handlerton *hton, THD *thd, const byte *loc, uint loc_len,
88  uint task_id, int in_err);
89 
90 /** Begin apply to destination database
91 @param[in] hton handlerton for SE
92 @param[in] thd server thread handle
93 @param[in,out] loc locator
94 @param[in,out] loc_len locator length
95 @param[out] task_id task identifier
96 @param[in] mode mode for starting clone
97 @param[in] data_dir target data directory
98 @return error code */
99 int innodb_clone_apply_begin(handlerton *hton, THD *thd, const byte *&loc,
100  uint &loc_len, uint &task_id, Ha_clone_mode mode,
101  const char *data_dir);
102 
103 /** Apply data to destination database in chunks via callback
104 @param[in] hton handlerton for SE
105 @param[in] thd server thread handle
106 @param[in] loc locator
107 @param[in] loc_len locator length in bytes
108 @param[in] task_id task identifier
109 @param[in] in_err inform any error occurred
110 @param[in] cbk callback interface for receiving data
111 @return error code */
112 int innodb_clone_apply(handlerton *hton, THD *thd, const byte *loc,
113  uint loc_len, uint task_id, int in_err,
114  Ha_clone_cbk *cbk);
115 
116 /** End apply to destination database
117 @param[in] hton handlerton for SE
118 @param[in] thd server thread handle
119 @param[in] loc locator
120 @param[in] loc_len locator length in bytes
121 @param[in] task_id task identifier
122 @param[in] in_err error code when ending after error
123 @return error code */
124 int innodb_clone_apply_end(handlerton *hton, THD *thd, const byte *loc,
125  uint loc_len, uint task_id, int in_err);
126 
127 /** Check and delete any old list files. */
128 void clone_init_list_files();
129 
130 /** Add fine name to clone list file for future replacement or rollback.
131 @param[in] list_file_name list file name where to add the file
132 @param[in] file_name file name to add to the list
133 @return error code */
134 int clone_add_to_list_file(const char *list_file_name, const char *file_name);
135 
136 /** Revert back clone changes in case of an error. */
137 void clone_files_error();
138 
139 #ifdef UNIV_DEBUG
140 /** Debug function to check and crash during recovery.
141 @param[in] is_cloned_db if cloned database recovery */
142 bool clone_check_recovery_crashpoint(bool is_cloned_db);
143 #endif
144 
145 /** Change cloned file states during recovery.
146 @param[in] finished if recovery is finishing */
147 void clone_files_recovery(bool finished);
148 
149 /** Update cloned GTIDs to recovery status file.
150 @param[in] gtids cloned GTIDs */
151 void clone_update_gtid_status(std::string &gtids);
152 
153 /** Initialize Clone system
154 @return inndodb error code */
156 
157 /** Uninitialize Clone system */
158 void clone_free();
159 
160 /** Mark clone system for abort to disallow database clone
161 @param[in] force abort running database clones
162 @return true if successful. */
163 bool clone_mark_abort(bool force);
164 
165 /** Mark clone system as active to allow database clone. */
166 void clone_mark_active();
167 
168 /** Check if active clone is running.
169 @return true, if any active clone is found. */
170 bool clone_check_active();
171 
172 /** Check for any active clone. If none, set a marker so that new clones
173 operation waits till the marker is freed.
174 @return true, if no active clone and marker is set successfully. */
175 bool clone_mark_wait();
176 
177 /** Free the wait marker set earlier and allow clone to proceed. */
178 void clone_mark_free();
179 
180 #else /* !UNIV_HOTBACKUP */
181 #define clone_mark_abort(_P_) /*clone_mark_abort()*/
182 #define clone_mark_active() /*clone_mark_active()*/
183 #endif /* !UNIV_HOTBACKUP */
184 
185 /** Fix cloned non-Innodb tables during recovery.
186 @param[in,out] thd current THD
187 @return true if error */
188 bool fix_cloned_tables(THD *thd);
189 
190 #endif /* CLONE_API_INCLUDE */
Ha_clone_mode
Clone start operation mode.
Definition: handler.h:901
int innodb_clone_apply_end(handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err)
End apply to destination database.
Definition: clone0api.cc:808
Ha_clone_type
Clone operation types.
Definition: handler.h:919
Definition: handler.h:968
int innodb_clone_apply_begin(handlerton *hton, THD *thd, const byte *&loc, uint &loc_len, uint &task_id, Ha_clone_mode mode, const char *data_dir)
Begin apply to destination database.
Definition: clone0api.cc:609
bool clone_check_active()
Check if active clone is running.
Definition: clone0api.cc:1504
bool clone_mark_abort(bool force)
Mark clone system for abort to disallow database clone.
Definition: clone0api.cc:1482
void clone_files_error()
Revert back clone changes in case of an error.
Definition: clone0api.cc:1285
int innodb_clone_copy(handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, Ha_clone_cbk *cbk)
Copy data from source database in chunks via callback.
Definition: clone0api.cc:409
void clone_mark_free()
Free the wait marker set earlier and allow clone to proceed.
Definition: clone0api.cc:1519
void clone_free()
Uninitialize Clone system.
Definition: clone0api.cc:1470
void clone_init_list_files()
Check and delete any old list files.
Definition: clone0api.cc:175
static int finished(pax_machine *p)
Definition: xcom_base.c:677
int innodb_clone_ack(handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk)
Acknowledge data to source database.
Definition: clone0api.cc:428
void clone_files_recovery(bool finished)
Change cloned file states during recovery.
Definition: clone0api.cc:1362
dberr_t
Definition: db0err.h:38
void clone_update_gtid_status(std::string &gtids)
Update cloned GTIDs to recovery status file.
Definition: clone0api.cc:1249
unsigned int uint
Definition: uca-dump.cc:29
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2269
int innodb_clone_apply(handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk)
Apply data to destination database in chunks via callback.
Definition: clone0api.cc:776
void clone_mark_active()
Mark clone system as active to allow database clone.
Definition: clone0api.cc:1496
int innodb_clone_begin(handlerton *hton, THD *thd, const byte *&loc, uint &loc_len, uint &task_id, Ha_clone_type type, Ha_clone_mode mode)
Begin copy from source database.
Definition: clone0api.cc:272
bool clone_mark_wait()
Check for any active clone.
Definition: clone0api.cc:1512
int innodb_clone_end(handlerton *hton, THD *thd, const byte *loc, uint loc_len, uint task_id, int in_err)
End copy from source database.
Definition: clone0api.cc:482
int clone_add_to_list_file(const char *list_file_name, const char *file_name)
Add fine name to clone list file for future replacement or rollback.
Definition: clone0api.cc:195
void innodb_clone_get_capability(Ha_clone_flagset &flags)
Get capability flags for clone operation.
Definition: clone0api.cc:264
dberr_t clone_init()
Initialize Clone system.
Definition: clone0api.cc:1447
bool fix_cloned_tables(THD *thd)
Fix cloned non-Innodb tables during recovery.
Definition: clone0api.cc:2096
static int flags[50]
Definition: hp_test1.cc:39
unsigned char byte
Blob class.
Definition: common.h:159
std::bitset< HA_CLONE_TYPE_MAX > Ha_clone_flagset
Definition: handler.h:943
bool clone_check_recovery_crashpoint(bool is_cloned_db)
Debug function to check and crash during recovery.
Definition: clone0api.cc:1348
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:765