2
by kinoyasu
The first usable version. |
1 |
/******************************************************
|
2 |
XtraBackup: The another hot backup tool for InnoDB
|
|
3 |
(c) 2009 Percona Inc.
|
|
4 |
Created 3/3/2009 Yasufumi Kinoshita
|
|
174.1.1
by Stewart Smith
add COPYING file with GPLv2 license. xtrabackup is under GPLv2 as documented on https://launchpad.net/percona-xtrabackup and http://www.percona.com/docs/wiki/percona-xtrabackup:start |
5 |
|
6 |
This program is free software; you can redistribute it and/or modify
|
|
7 |
it under the terms of the GNU General Public License as published by
|
|
8 |
the Free Software Foundation; version 2 of the License.
|
|
9 |
||
10 |
This program is distributed in the hope that it will be useful,
|
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
GNU General Public License for more details.
|
|
14 |
||
15 |
You should have received a copy of the GNU General Public License
|
|
16 |
along with this program; if not, write to the Free Software
|
|
17 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
||
2
by kinoyasu
The first usable version. |
19 |
*******************************************************/
|
20 |
||
74.1.1
by Aleksandr Kuzminsky
XTRABACKUP_VERSION can be re-defined with gcc's -D option |
21 |
#ifndef XTRABACKUP_VERSION
|
22 |
#define XTRABACKUP_VERSION "undefined"
|
|
23 |
#endif
|
|
77.1.1
by Aleksandr Kuzminsky
1) xtrabackup prints source code revision number set via XTRABACKUP_REVISION |
24 |
#ifndef XTRABACKUP_REVISION
|
25 |
#define XTRABACKUP_REVISION "undefined"
|
|
26 |
#endif
|
|
1
by kinoyasu
initial registration |
27 |
|
28 |
//#define XTRABACKUP_TARGET_IS_PLUGIN
|
|
29 |
||
30 |
#include <my_base.h> |
|
31 |
#include <my_getopt.h> |
|
32 |
#include <mysql_version.h> |
|
11
by kinoyasu
fix tribials |
33 |
#include <mysql_com.h> |
1
by kinoyasu
initial registration |
34 |
|
18
by kinoyasu
supporting MySQL 5.1 |
35 |
#if (MYSQL_VERSION_ID < 50100)
|
94
by kinoyasu
Windows conscious experimental change |
36 |
#define G_PTR gptr
|
18
by kinoyasu
supporting MySQL 5.1 |
37 |
#else /* MYSQL_VERSION_ID < 51000 */ |
94
by kinoyasu
Windows conscious experimental change |
38 |
#define G_PTR uchar*
|
18
by kinoyasu
supporting MySQL 5.1 |
39 |
#endif
|
40 |
||
1
by kinoyasu
initial registration |
41 |
#include <univ.i> |
42 |
#include <os0file.h> |
|
43 |
#include <os0thread.h> |
|
44 |
#include <srv0start.h> |
|
45 |
#include <srv0srv.h> |
|
46 |
#include <trx0roll.h> |
|
47 |
#include <trx0trx.h> |
|
48 |
#include <trx0sys.h> |
|
49 |
#include <mtr0mtr.h> |
|
50 |
#include <row0ins.h> |
|
51 |
#include <row0mysql.h> |
|
52 |
#include <row0sel.h> |
|
53 |
#include <row0upd.h> |
|
54 |
#include <log0log.h> |
|
55 |
#include <lock0lock.h> |
|
56 |
#include <dict0crea.h> |
|
57 |
#include <btr0cur.h> |
|
58 |
#include <btr0btr.h> |
|
59 |
#include <fsp0fsp.h> |
|
60 |
#include <sync0sync.h> |
|
61 |
#include <fil0fil.h> |
|
62 |
#include <trx0xa.h> |
|
63 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
64 |
#ifdef INNODB_VERSION_SHORT
|
65 |
#include <ibuf0ibuf.h> |
|
66 |
#endif
|
|
67 |
||
68 |
#ifndef INNODB_VERSION_SHORT
|
|
69 |
#define IB_INT64 ib_longlong
|
|
70 |
#define LSN64 dulint
|
|
71 |
#define MACH_READ_64 mach_read_from_8
|
|
72 |
#define MACH_WRITE_64 mach_write_to_8
|
|
200
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
73 |
#define OS_MUTEX_CREATE() os_mutex_create(NULL)
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
74 |
#else
|
75 |
#define IB_INT64 ib_int64_t
|
|
76 |
#define LSN64 ib_uint64_t
|
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
77 |
#if (MYSQL_VERSION_ID < 50500)
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
78 |
#define MACH_READ_64 mach_read_ull
|
79 |
#define MACH_WRITE_64 mach_write_ull
|
|
200
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
80 |
#define OS_MUTEX_CREATE() os_mutex_create(NULL)
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
81 |
#else
|
82 |
#define MACH_READ_64 mach_read_from_8
|
|
83 |
#define MACH_WRITE_64 mach_write_to_8
|
|
201
by Alexey Kopytov
Fixed the broken 5.5 build introduced by revision 200. |
84 |
#define OS_MUTEX_CREATE() os_mutex_create()
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
85 |
#endif
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
86 |
#define ut_dulint_zero 0
|
87 |
#define ut_dulint_cmp(A, B) (A > B ? 1 : (A == B ? 0 : -1))
|
|
88 |
#define ut_dulint_add(A, B) (A + B)
|
|
89 |
#define ut_dulint_minus(A, B) (A - B)
|
|
90 |
#define ut_dulint_align_down(A, B) (A & ~((ib_int64_t)B - 1))
|
|
91 |
#define ut_dulint_align_up(A, B) ((A + B - 1) & ~((ib_int64_t)B - 1))
|
|
92 |
#endif
|
|
93 |
||
96
by kinoyasu
Windows conscious change more |
94 |
#ifdef __WIN__
|
95 |
#define SRV_PATH_SEPARATOR '\\'
|
|
96 |
#define SRV_PATH_SEPARATOR_STR "\\"
|
|
97 |
#else
|
|
98 |
#define SRV_PATH_SEPARATOR '/'
|
|
99 |
#define SRV_PATH_SEPARATOR_STR "/"
|
|
100 |
#endif
|
|
101 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
102 |
#ifndef UNIV_PAGE_SIZE_MAX
|
103 |
#define UNIV_PAGE_SIZE_MAX UNIV_PAGE_SIZE
|
|
104 |
#endif
|
|
105 |
#ifndef UNIV_PAGE_SIZE_SHIFT_MAX
|
|
106 |
#define UNIV_PAGE_SIZE_SHIFT_MAX UNIV_PAGE_SIZE_SHIFT
|
|
107 |
#endif
|
|
108 |
||
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
109 |
#if MYSQL_VERSION_ID >= 50507
|
110 |
/*
|
|
111 |
As of MySQL 5.5.7, InnoDB uses thd_wait plugin service.
|
|
112 |
We have to provide mock functions to avoid linker errors.
|
|
113 |
*/
|
|
114 |
#include <mysql/plugin.h> |
|
115 |
#include <mysql/service_thd_wait.h> |
|
116 |
||
117 |
void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type) |
|
118 |
{
|
|
119 |
return; |
|
120 |
}
|
|
121 |
||
122 |
void thd_wait_end(MYSQL_THD thd) |
|
123 |
{
|
|
124 |
return; |
|
125 |
}
|
|
126 |
||
127 |
#endif /* MYSQL_VERSION_ID >= 50507 */ |
|
128 |
||
85
by kinoyasu
new option --stats to gather index stats |
129 |
/* prototypes for static functions in original */
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
130 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
131 |
page_t* |
132 |
btr_node_ptr_get_child( |
|
133 |
/*===================*/
|
|
134 |
/* out: child page, x-latched */
|
|
135 |
rec_t* node_ptr,/* in: node pointer */ |
|
136 |
const ulint* offsets,/* in: array returned by rec_get_offsets() */ |
|
137 |
mtr_t* mtr); /* in: mtr */ |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
138 |
#else
|
139 |
buf_block_t* |
|
140 |
btr_node_ptr_get_child( |
|
141 |
/*===================*/
|
|
142 |
const rec_t* node_ptr,/*!< in: node pointer */ |
|
143 |
dict_index_t* index, /*!< in: index */ |
|
144 |
const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ |
|
145 |
mtr_t* mtr); /*!< in: mtr */ |
|
146 |
||
147 |
buf_block_t* |
|
148 |
btr_root_block_get( |
|
149 |
/*===============*/
|
|
150 |
dict_index_t* index, /*!< in: index tree */ |
|
151 |
mtr_t* mtr); /*!< in: mtr */ |
|
152 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
153 |
|
154 |
int
|
|
155 |
fil_file_readdir_next_file( |
|
156 |
/*=======================*/
|
|
157 |
/* out: 0 if ok, -1 if error even after the
|
|
158 |
retries, 1 if at the end of the directory */
|
|
159 |
ulint* err, /* out: this is set to DB_ERROR if an error |
|
160 |
was encountered, otherwise not changed */
|
|
161 |
const char* dirname,/* in: directory name or path */ |
|
162 |
os_file_dir_t dir, /* in: directory stream */ |
|
163 |
os_file_stat_t* info); /* in/out: buffer where the info is returned */ |
|
164 |
||
165 |
ibool
|
|
166 |
recv_check_cp_is_consistent( |
|
167 |
/*========================*/
|
|
168 |
/* out: TRUE if ok */
|
|
169 |
byte* buf); /* in: buffer containing checkpoint info */ |
|
170 |
||
171 |
ulint
|
|
172 |
recv_find_max_checkpoint( |
|
173 |
/*=====================*/
|
|
174 |
/* out: error code or DB_SUCCESS */
|
|
175 |
log_group_t** max_group, /* out: max group */ |
|
176 |
ulint* max_field); /* out: LOG_CHECKPOINT_1 or |
|
177 |
LOG_CHECKPOINT_2 */
|
|
178 |
||
179 |
ibool
|
|
180 |
log_block_checksum_is_ok_or_old_format( |
|
181 |
/*===================================*/
|
|
182 |
/* out: TRUE if ok, or if the log block may be in the
|
|
183 |
format of InnoDB version < 3.23.52 */
|
|
184 |
byte* block); /* in: pointer to a log block */ |
|
185 |
||
186 |
ulint
|
|
187 |
open_or_create_log_file( |
|
188 |
/*====================*/
|
|
189 |
/* out: DB_SUCCESS or error code */
|
|
190 |
ibool create_new_db, /* in: TRUE if we should create a |
|
191 |
new database */
|
|
192 |
ibool* log_file_created, /* out: TRUE if new log file |
|
193 |
created */
|
|
194 |
ibool log_file_has_been_opened,/* in: TRUE if a log file has been |
|
195 |
opened before: then it is an error
|
|
196 |
to try to create another log file */
|
|
197 |
ulint k, /* in: log group number */ |
|
198 |
ulint i); /* in: log file number in group */ |
|
199 |
||
200 |
ulint
|
|
201 |
open_or_create_data_files( |
|
202 |
/*======================*/
|
|
203 |
/* out: DB_SUCCESS or error code */
|
|
204 |
ibool* create_new_db, /* out: TRUE if new database should be |
|
205 |
created */
|
|
154
by Yasufumi Kinoshita
fix bug611960 |
206 |
#ifdef XTRADB_BASED
|
207 |
ibool* create_new_doublewrite_file, |
|
208 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
209 |
#ifdef UNIV_LOG_ARCHIVE
|
210 |
ulint* min_arch_log_no,/* out: min of archived log numbers in data |
|
211 |
files */
|
|
212 |
ulint* max_arch_log_no,/* out: */ |
|
213 |
#endif /* UNIV_LOG_ARCHIVE */ |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
214 |
LSN64* min_flushed_lsn,/* out: min of flushed lsn values in data |
85
by kinoyasu
new option --stats to gather index stats |
215 |
files */
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
216 |
LSN64* max_flushed_lsn,/* out: */ |
85
by kinoyasu
new option --stats to gather index stats |
217 |
ulint* sum_of_new_sizes);/* out: sum of sizes of the new files added */ |
218 |
||
219 |
void
|
|
220 |
os_file_set_nocache( |
|
221 |
/*================*/
|
|
222 |
int fd, /* in: file descriptor to alter */ |
|
223 |
const char* file_name, /* in: used in the diagnostic message */ |
|
224 |
const char* operation_name); /* in: used in the diagnostic message, |
|
225 |
we call os_file_set_nocache()
|
|
226 |
immediately after opening or creating
|
|
227 |
a file, so this is either "open" or
|
|
228 |
"create" */
|
|
229 |
||
52
by kinoyasu
add to use posix_fadvise() if possible |
230 |
#include <fcntl.h> |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
231 |
#include <regex.h> |
232 |
||
52
by kinoyasu
add to use posix_fadvise() if possible |
233 |
#ifdef POSIX_FADV_NORMAL
|
234 |
#define USE_POSIX_FADVISE
|
|
235 |
#endif
|
|
236 |
||
1
by kinoyasu
initial registration |
237 |
/* ==start === definition at fil0fil.c === */
|
14
by kinoyasu
using rsync for incremental backup |
238 |
// ##################################################################
|
239 |
// NOTE: We should check the following definitions fit to the source.
|
|
240 |
// ##################################################################
|
|
1
by kinoyasu
initial registration |
241 |
|
14
by kinoyasu
using rsync for incremental backup |
242 |
#ifndef INNODB_VERSION_SHORT
|
243 |
//5.0 5.1
|
|
1
by kinoyasu
initial registration |
244 |
/* File node of a tablespace or the log data space */
|
245 |
struct fil_node_struct { |
|
246 |
fil_space_t* space; /* backpointer to the space where this node |
|
247 |
belongs */
|
|
248 |
char* name; /* path to the file */ |
|
249 |
ibool open; /* TRUE if file open */ |
|
250 |
os_file_t handle; /* OS handle to the file, if file open */ |
|
251 |
ibool is_raw_disk;/* TRUE if the 'file' is actually a raw |
|
252 |
device or a raw disk partition */
|
|
253 |
ulint size; /* size of the file in database pages, 0 if |
|
254 |
not known yet; the possible last incomplete
|
|
255 |
megabyte may be ignored if space == 0 */
|
|
256 |
ulint n_pending; |
|
257 |
/* count of pending i/o's on this file;
|
|
258 |
closing of the file is not allowed if
|
|
259 |
this is > 0 */
|
|
260 |
ulint n_pending_flushes; |
|
261 |
/* count of pending flushes on this file;
|
|
262 |
closing of the file is not allowed if
|
|
263 |
this is > 0 */
|
|
264 |
ib_longlong modification_counter;/* when we write to the file we |
|
265 |
increment this by one */
|
|
266 |
ib_longlong flush_counter;/* up to what modification_counter value |
|
267 |
we have flushed the modifications to disk */
|
|
268 |
UT_LIST_NODE_T(fil_node_t) chain; |
|
269 |
/* link field for the file chain */
|
|
270 |
UT_LIST_NODE_T(fil_node_t) LRU; |
|
271 |
/* link field for the LRU list */
|
|
272 |
ulint magic_n; |
|
273 |
};
|
|
274 |
||
275 |
struct fil_space_struct { |
|
276 |
char* name; /* space name = the path to the first file in |
|
277 |
it */
|
|
278 |
ulint id; /* space id */ |
|
279 |
ib_longlong tablespace_version; |
|
280 |
/* in DISCARD/IMPORT this timestamp is used to
|
|
281 |
check if we should ignore an insert buffer
|
|
282 |
merge request for a page because it actually
|
|
283 |
was for the previous incarnation of the
|
|
284 |
space */
|
|
285 |
ibool mark; /* this is set to TRUE at database startup if |
|
286 |
the space corresponds to a table in the InnoDB
|
|
287 |
data dictionary; so we can print a warning of
|
|
288 |
orphaned tablespaces */
|
|
289 |
ibool stop_ios;/* TRUE if we want to rename the .ibd file of |
|
290 |
tablespace and want to stop temporarily
|
|
291 |
posting of new i/o requests on the file */
|
|
292 |
ibool stop_ibuf_merges; |
|
293 |
/* we set this TRUE when we start deleting a
|
|
294 |
single-table tablespace */
|
|
295 |
ibool is_being_deleted; |
|
296 |
/* this is set to TRUE when we start
|
|
297 |
deleting a single-table tablespace and its
|
|
298 |
file; when this flag is set no further i/o
|
|
299 |
or flush requests can be placed on this space,
|
|
300 |
though there may be such requests still being
|
|
301 |
processed on this space */
|
|
302 |
ulint purpose;/* FIL_TABLESPACE, FIL_LOG, or FIL_ARCH_LOG */ |
|
303 |
UT_LIST_BASE_NODE_T(fil_node_t) chain; |
|
304 |
/* base node for the file chain */
|
|
305 |
ulint size; /* space size in pages; 0 if a single-table |
|
306 |
tablespace whose size we do not know yet;
|
|
307 |
last incomplete megabytes in data files may be
|
|
308 |
ignored if space == 0 */
|
|
309 |
ulint n_reserved_extents; |
|
310 |
/* number of reserved free extents for
|
|
311 |
ongoing operations like B-tree page split */
|
|
312 |
ulint n_pending_flushes; /* this is > 0 when flushing |
|
313 |
the tablespace to disk; dropping of the
|
|
314 |
tablespace is forbidden if this is > 0 */
|
|
315 |
ulint n_pending_ibuf_merges;/* this is > 0 when merging |
|
316 |
insert buffer entries to a page so that we
|
|
317 |
may need to access the ibuf bitmap page in the
|
|
318 |
tablespade: dropping of the tablespace is
|
|
319 |
forbidden if this is > 0 */
|
|
320 |
hash_node_t hash; /* hash chain node */ |
|
321 |
hash_node_t name_hash;/* hash chain the name_hash table */ |
|
322 |
rw_lock_t latch; /* latch protecting the file space storage |
|
323 |
allocation */
|
|
324 |
UT_LIST_NODE_T(fil_space_t) unflushed_spaces; |
|
325 |
/* list of spaces with at least one unflushed
|
|
326 |
file we have written to */
|
|
327 |
ibool is_in_unflushed_spaces; /* TRUE if this space is |
|
328 |
currently in the list above */
|
|
329 |
UT_LIST_NODE_T(fil_space_t) space_list; |
|
330 |
/* list of all spaces */
|
|
331 |
ibuf_data_t* ibuf_data; |
|
332 |
/* insert buffer data */
|
|
333 |
ulint magic_n; |
|
334 |
};
|
|
335 |
typedef struct fil_system_struct fil_system_t; |
|
336 |
struct fil_system_struct { |
|
337 |
mutex_t mutex; /* The mutex protecting the cache */ |
|
338 |
hash_table_t* spaces; /* The hash table of spaces in the |
|
339 |
system; they are hashed on the space
|
|
340 |
id */
|
|
341 |
hash_table_t* name_hash; /* hash table based on the space |
|
342 |
name */
|
|
343 |
UT_LIST_BASE_NODE_T(fil_node_t) LRU; |
|
344 |
/* base node for the LRU list of the
|
|
345 |
most recently used open files with no
|
|
346 |
pending i/o's; if we start an i/o on
|
|
347 |
the file, we first remove it from this
|
|
348 |
list, and return it to the start of
|
|
349 |
the list when the i/o ends;
|
|
350 |
log files and the system tablespace are
|
|
351 |
not put to this list: they are opened
|
|
352 |
after the startup, and kept open until
|
|
353 |
shutdown */
|
|
354 |
UT_LIST_BASE_NODE_T(fil_space_t) unflushed_spaces; |
|
355 |
/* base node for the list of those
|
|
356 |
tablespaces whose files contain
|
|
357 |
unflushed writes; those spaces have
|
|
358 |
at least one file node where
|
|
359 |
modification_counter > flush_counter */
|
|
360 |
ulint n_open; /* number of files currently open */ |
|
361 |
ulint max_n_open; /* n_open is not allowed to exceed |
|
362 |
this */
|
|
363 |
ib_longlong modification_counter;/* when we write to a file we |
|
364 |
increment this by one */
|
|
365 |
ulint max_assigned_id;/* maximum space id in the existing |
|
366 |
tables, or assigned during the time
|
|
367 |
mysqld has been up; at an InnoDB
|
|
368 |
startup we scan the data dictionary
|
|
369 |
and set here the maximum of the
|
|
370 |
space id's of the tables there */
|
|
371 |
ib_longlong tablespace_version; |
|
372 |
/* a counter which is incremented for
|
|
373 |
every space object memory creation;
|
|
374 |
every space mem object gets a
|
|
375 |
'timestamp' from this; in DISCARD/
|
|
376 |
IMPORT this is used to check if we
|
|
377 |
should ignore an insert buffer merge
|
|
378 |
request */
|
|
379 |
UT_LIST_BASE_NODE_T(fil_space_t) space_list; |
|
380 |
/* list of all file spaces */
|
|
381 |
};
|
|
14
by kinoyasu
using rsync for incremental backup |
382 |
#else
|
383 |
//Plugin ?
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
384 |
/** File node of a tablespace or the log data space */
|
385 |
struct fil_node_struct { |
|
386 |
fil_space_t* space; /*!< backpointer to the space where this node |
|
387 |
belongs */
|
|
388 |
char* name; /*!< path to the file */ |
|
389 |
ibool open; /*!< TRUE if file open */ |
|
390 |
os_file_t handle; /*!< OS handle to the file, if file open */ |
|
391 |
ibool is_raw_disk;/*!< TRUE if the 'file' is actually a raw |
|
392 |
device or a raw disk partition */
|
|
393 |
ulint size; /*!< size of the file in database pages, 0 if |
|
394 |
not known yet; the possible last incomplete
|
|
395 |
megabyte may be ignored if space == 0 */
|
|
396 |
ulint n_pending; |
|
397 |
/*!< count of pending i/o's on this file;
|
|
398 |
closing of the file is not allowed if
|
|
399 |
this is > 0 */
|
|
400 |
ulint n_pending_flushes; |
|
401 |
/*!< count of pending flushes on this file;
|
|
402 |
closing of the file is not allowed if
|
|
403 |
this is > 0 */
|
|
404 |
ib_int64_t modification_counter;/*!< when we write to the file we |
|
405 |
increment this by one */
|
|
406 |
ib_int64_t flush_counter;/*!< up to what |
|
407 |
modification_counter value we have
|
|
408 |
flushed the modifications to disk */
|
|
409 |
UT_LIST_NODE_T(fil_node_t) chain; |
|
410 |
/*!< link field for the file chain */
|
|
411 |
UT_LIST_NODE_T(fil_node_t) LRU; |
|
412 |
/*!< link field for the LRU list */
|
|
413 |
ulint magic_n;/*!< FIL_NODE_MAGIC_N */ |
|
414 |
};
|
|
415 |
||
416 |
struct fil_space_struct { |
|
417 |
char* name; /*!< space name = the path to the first file in |
|
418 |
it */
|
|
419 |
ulint id; /*!< space id */ |
|
420 |
ib_int64_t tablespace_version; |
|
421 |
/*!< in DISCARD/IMPORT this timestamp
|
|
422 |
is used to check if we should ignore
|
|
423 |
an insert buffer merge request for a
|
|
424 |
page because it actually was for the
|
|
425 |
previous incarnation of the space */
|
|
426 |
ibool mark; /*!< this is set to TRUE at database startup if |
|
427 |
the space corresponds to a table in the InnoDB
|
|
428 |
data dictionary; so we can print a warning of
|
|
429 |
orphaned tablespaces */
|
|
430 |
ibool stop_ios;/*!< TRUE if we want to rename the |
|
431 |
.ibd file of tablespace and want to
|
|
432 |
stop temporarily posting of new i/o
|
|
433 |
requests on the file */
|
|
434 |
ibool stop_ibuf_merges; |
|
435 |
/*!< we set this TRUE when we start
|
|
436 |
deleting a single-table tablespace */
|
|
437 |
ibool is_being_deleted; |
|
438 |
/*!< this is set to TRUE when we start
|
|
439 |
deleting a single-table tablespace and its
|
|
440 |
file; when this flag is set no further i/o
|
|
441 |
or flush requests can be placed on this space,
|
|
442 |
though there may be such requests still being
|
|
443 |
processed on this space */
|
|
444 |
ulint purpose;/*!< FIL_TABLESPACE, FIL_LOG, or |
|
445 |
FIL_ARCH_LOG */
|
|
446 |
UT_LIST_BASE_NODE_T(fil_node_t) chain; |
|
447 |
/*!< base node for the file chain */
|
|
448 |
ulint size; /*!< space size in pages; 0 if a single-table |
|
449 |
tablespace whose size we do not know yet;
|
|
450 |
last incomplete megabytes in data files may be
|
|
451 |
ignored if space == 0 */
|
|
452 |
ulint flags; /*!< compressed page size and file format, or 0 */ |
|
453 |
ulint n_reserved_extents; |
|
454 |
/*!< number of reserved free extents for
|
|
455 |
ongoing operations like B-tree page split */
|
|
456 |
ulint n_pending_flushes; /*!< this is positive when flushing |
|
457 |
the tablespace to disk; dropping of the
|
|
458 |
tablespace is forbidden if this is positive */
|
|
459 |
ulint n_pending_ibuf_merges;/*!< this is positive |
|
460 |
when merging insert buffer entries to
|
|
461 |
a page so that we may need to access
|
|
462 |
the ibuf bitmap page in the
|
|
463 |
tablespade: dropping of the tablespace
|
|
464 |
is forbidden if this is positive */
|
|
465 |
hash_node_t hash; /*!< hash chain node */ |
|
466 |
hash_node_t name_hash;/*!< hash chain the name_hash table */ |
|
467 |
#ifndef UNIV_HOTBACKUP
|
|
468 |
rw_lock_t latch; /*!< latch protecting the file space storage |
|
469 |
allocation */
|
|
470 |
#endif /* !UNIV_HOTBACKUP */ |
|
471 |
UT_LIST_NODE_T(fil_space_t) unflushed_spaces; |
|
472 |
/*!< list of spaces with at least one unflushed
|
|
473 |
file we have written to */
|
|
474 |
ibool is_in_unflushed_spaces; /*!< TRUE if this space is |
|
475 |
currently in unflushed_spaces */
|
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
476 |
#ifdef XTRADB_BASED
|
477 |
ibool is_corrupt; |
|
478 |
#endif
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
479 |
UT_LIST_NODE_T(fil_space_t) space_list; |
480 |
/*!< list of all spaces */
|
|
481 |
ulint magic_n;/*!< FIL_SPACE_MAGIC_N */ |
|
482 |
};
|
|
483 |
||
484 |
typedef struct fil_system_struct fil_system_t; |
|
485 |
||
486 |
struct fil_system_struct { |
|
487 |
#ifndef UNIV_HOTBACKUP
|
|
488 |
mutex_t mutex; /*!< The mutex protecting the cache */ |
|
489 |
#endif /* !UNIV_HOTBACKUP */ |
|
490 |
hash_table_t* spaces; /*!< The hash table of spaces in the |
|
491 |
system; they are hashed on the space
|
|
492 |
id */
|
|
493 |
hash_table_t* name_hash; /*!< hash table based on the space |
|
494 |
name */
|
|
495 |
UT_LIST_BASE_NODE_T(fil_node_t) LRU; |
|
496 |
/*!< base node for the LRU list of the
|
|
497 |
most recently used open files with no
|
|
498 |
pending i/o's; if we start an i/o on
|
|
499 |
the file, we first remove it from this
|
|
500 |
list, and return it to the start of
|
|
501 |
the list when the i/o ends;
|
|
502 |
log files and the system tablespace are
|
|
503 |
not put to this list: they are opened
|
|
504 |
after the startup, and kept open until
|
|
505 |
shutdown */
|
|
506 |
UT_LIST_BASE_NODE_T(fil_space_t) unflushed_spaces; |
|
507 |
/*!< base node for the list of those
|
|
508 |
tablespaces whose files contain
|
|
509 |
unflushed writes; those spaces have
|
|
510 |
at least one file node where
|
|
511 |
modification_counter > flush_counter */
|
|
512 |
ulint n_open; /*!< number of files currently open */ |
|
513 |
ulint max_n_open; /*!< n_open is not allowed to exceed |
|
514 |
this */
|
|
515 |
ib_int64_t modification_counter;/*!< when we write to a file we |
|
516 |
increment this by one */
|
|
517 |
ulint max_assigned_id;/*!< maximum space id in the existing |
|
518 |
tables, or assigned during the time
|
|
519 |
mysqld has been up; at an InnoDB
|
|
520 |
startup we scan the data dictionary
|
|
521 |
and set here the maximum of the
|
|
522 |
space id's of the tables there */
|
|
523 |
ib_int64_t tablespace_version; |
|
524 |
/*!< a counter which is incremented for
|
|
525 |
every space object memory creation;
|
|
526 |
every space mem object gets a
|
|
527 |
'timestamp' from this; in DISCARD/
|
|
528 |
IMPORT this is used to check if we
|
|
529 |
should ignore an insert buffer merge
|
|
530 |
request */
|
|
531 |
UT_LIST_BASE_NODE_T(fil_space_t) space_list; |
|
532 |
/*!< list of all file spaces */
|
|
533 |
};
|
|
534 |
||
14
by kinoyasu
using rsync for incremental backup |
535 |
#endif /* INNODB_VERSION_SHORT */ |
536 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
537 |
typedef struct { |
538 |
ulint page_size; |
|
539 |
} xb_delta_info_t; |
|
540 |
||
1
by kinoyasu
initial registration |
541 |
extern fil_system_t* fil_system; |
542 |
||
543 |
/* ==end=== definition at fil0fil.c === */
|
|
544 |
||
545 |
||
18
by kinoyasu
supporting MySQL 5.1 |
546 |
my_bool innodb_inited= 0; |
1
by kinoyasu
initial registration |
547 |
|
548 |
/* === xtrabackup specific options === */
|
|
549 |
char xtrabackup_real_target_dir[FN_REFLEN] = "./xtrabackup_backupfiles/"; |
|
550 |
char *xtrabackup_target_dir= xtrabackup_real_target_dir; |
|
551 |
my_bool xtrabackup_backup = FALSE; |
|
85
by kinoyasu
new option --stats to gather index stats |
552 |
my_bool xtrabackup_stats = FALSE; |
1
by kinoyasu
initial registration |
553 |
my_bool xtrabackup_prepare = FALSE; |
5
by kinoyasu
add innobackup support patch, fix some bugs |
554 |
my_bool xtrabackup_print_param = FALSE; |
1
by kinoyasu
initial registration |
555 |
|
60
by kinoyasu
experimantal option --export is added |
556 |
my_bool xtrabackup_export = FALSE; |
179
by kinoyasu
add --apply-log-only option for test only for based on 5.5 version for now. It may be needed for incremental --prepare operation exactly. |
557 |
my_bool xtrabackup_apply_log_only = FALSE; |
60
by kinoyasu
experimantal option --export is added |
558 |
|
1
by kinoyasu
initial registration |
559 |
my_bool xtrabackup_suspend_at_end = FALSE; |
3
by kinoyasu
planned options are implemented |
560 |
longlong xtrabackup_use_memory = 100*1024*1024L; |
5
by kinoyasu
add innobackup support patch, fix some bugs |
561 |
my_bool xtrabackup_create_ib_logfile = FALSE; |
1
by kinoyasu
initial registration |
562 |
|
563 |
long xtrabackup_throttle = 0; /* 0:unlimited */ |
|
3
by kinoyasu
planned options are implemented |
564 |
lint io_ticket; |
565 |
os_event_t wait_throttle = NULL; |
|
566 |
||
1
by kinoyasu
initial registration |
567 |
my_bool xtrabackup_stream = FALSE; |
33
by kinoyasu
primitive implementation of incremental backup |
568 |
char *xtrabackup_incremental = NULL; |
100
by kinoyasu
initial implementation for InnoDB Plugin |
569 |
LSN64 incremental_lsn; |
570 |
LSN64 incremental_to_lsn; |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
571 |
LSN64 incremental_last_lsn; |
33
by kinoyasu
primitive implementation of incremental backup |
572 |
byte* incremental_buffer = NULL; |
573 |
byte* incremental_buffer_base = NULL; |
|
34
by kinoyasu
more user-friendly incremental backup |
574 |
|
575 |
char *xtrabackup_incremental_basedir = NULL; /* for --backup */ |
|
182.1.1
by Baron Schwartz
add --extra-lsndir to xtrabackup |
576 |
char *xtrabackup_extra_lsndir = NULL; /* for --backup with --extra-lsndir */ |
34
by kinoyasu
more user-friendly incremental backup |
577 |
char *xtrabackup_incremental_dir = NULL; /* for --prepare */ |
578 |
||
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
579 |
char *xtrabackup_tables = NULL; |
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
580 |
int tables_regex_num; |
581 |
regex_t *tables_regex; |
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
582 |
regmatch_t tables_regmatch[1]; |
1
by kinoyasu
initial registration |
583 |
|
158
by kinoyasu
new option --tables_file is added |
584 |
char *xtrabackup_tables_file = NULL; |
585 |
hash_table_t* tables_hash; |
|
586 |
||
587 |
struct xtrabackup_tables_struct{ |
|
588 |
char* name; |
|
589 |
hash_node_t name_hash; |
|
590 |
};
|
|
591 |
typedef struct xtrabackup_tables_struct xtrabackup_tables_t; |
|
592 |
||
136
by kinoyasu
port to Percona Server 5.1.47-11 |
593 |
#ifdef XTRADB_BASED
|
594 |
static ulint n[SRV_MAX_N_IO_THREADS + 6 + 64]; |
|
595 |
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6 + 64]; |
|
596 |
#else
|
|
597 |
static ulint n[SRV_MAX_N_IO_THREADS + 6]; |
|
598 |
static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6]; |
|
599 |
#endif
|
|
1
by kinoyasu
initial registration |
600 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
601 |
LSN64 checkpoint_lsn_start; |
602 |
LSN64 checkpoint_no_start; |
|
603 |
LSN64 log_copy_scanned_lsn; |
|
604 |
IB_INT64 log_copy_offset = 0; |
|
1
by kinoyasu
initial registration |
605 |
ibool log_copying = TRUE; |
606 |
ibool log_copying_running = FALSE; |
|
607 |
ibool log_copying_succeed = FALSE; |
|
608 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
609 |
ibool xtrabackup_logfile_is_renamed = FALSE; |
610 |
||
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
611 |
uint parallel; |
612 |
||
34
by kinoyasu
more user-friendly incremental backup |
613 |
/* === metadata of backup === */
|
614 |
#define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints"
|
|
615 |
char metadata_type[30] = ""; /*[full-backuped|full-prepared|incremental]*/ |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
616 |
#ifndef INNODB_VERSION_SHORT
|
34
by kinoyasu
more user-friendly incremental backup |
617 |
dulint metadata_from_lsn = {0, 0}; |
618 |
dulint metadata_to_lsn = {0, 0}; |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
619 |
dulint metadata_last_lsn = {0, 0}; |
100
by kinoyasu
initial implementation for InnoDB Plugin |
620 |
#else
|
621 |
ib_uint64_t metadata_from_lsn = 0; |
|
622 |
ib_uint64_t metadata_to_lsn = 0; |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
623 |
ib_uint64_t metadata_last_lsn = 0; |
100
by kinoyasu
initial implementation for InnoDB Plugin |
624 |
#endif
|
34
by kinoyasu
more user-friendly incremental backup |
625 |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
626 |
#define XB_DELTA_INFO_SUFFIX ".meta"
|
627 |
||
1
by kinoyasu
initial registration |
628 |
/* === sharing with thread === */
|
629 |
os_file_t dst_log = -1; |
|
630 |
char dst_log_path[FN_REFLEN]; |
|
631 |
||
632 |
/* === some variables from mysqld === */
|
|
633 |
char mysql_real_data_home[FN_REFLEN] = "./"; |
|
634 |
char *mysql_data_home= mysql_real_data_home; |
|
635 |
static char mysql_data_home_buff[2]; |
|
636 |
||
637 |
char *opt_mysql_tmpdir = NULL; |
|
638 |
MY_TMPDIR mysql_tmpdir_list; |
|
639 |
||
640 |
/* === static parameters in ha_innodb.cc */
|
|
641 |
||
642 |
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */ |
|
643 |
#define HA_INNOBASE_RANGE_COUNT 100
|
|
644 |
||
645 |
ulong innobase_large_page_size = 0; |
|
646 |
||
647 |
/* The default values for the following, type long or longlong, start-up
|
|
648 |
parameters are declared in mysqld.cc: */
|
|
649 |
||
650 |
long innobase_additional_mem_pool_size = 1*1024*1024L; |
|
651 |
long innobase_buffer_pool_awe_mem_mb = 0; |
|
652 |
long innobase_file_io_threads = 4; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
653 |
long innobase_read_io_threads = 4; |
654 |
long innobase_write_io_threads = 4; |
|
1
by kinoyasu
initial registration |
655 |
long innobase_force_recovery = 0; |
656 |
long innobase_lock_wait_timeout = 50; |
|
657 |
long innobase_log_buffer_size = 1024*1024L; |
|
658 |
long innobase_log_files_in_group = 2; |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
659 |
long innobase_log_files_in_group_backup; |
1
by kinoyasu
initial registration |
660 |
long innobase_mirrored_log_groups = 1; |
661 |
long innobase_open_files = 300L; |
|
662 |
||
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
663 |
long innobase_page_size = (1 << 14); /* 16KB */ |
664 |
my_bool innobase_fast_checksum = FALSE; |
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
665 |
my_bool innobase_extra_undoslots = FALSE; |
666 |
char* innobase_doublewrite_file = NULL; |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
667 |
|
1
by kinoyasu
initial registration |
668 |
longlong innobase_buffer_pool_size = 8*1024*1024L; |
669 |
longlong innobase_log_file_size = 5*1024*1024L; |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
670 |
longlong innobase_log_file_size_backup; |
1
by kinoyasu
initial registration |
671 |
|
672 |
/* The default values for the following char* start-up parameters
|
|
673 |
are determined in innobase_init below: */
|
|
674 |
||
675 |
char* innobase_data_home_dir = NULL; |
|
676 |
char* innobase_data_file_path = NULL; |
|
677 |
char* innobase_log_group_home_dir = NULL; |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
678 |
char* innobase_log_group_home_dir_backup = NULL; |
1
by kinoyasu
initial registration |
679 |
char* innobase_log_arch_dir = NULL;/* unused */ |
680 |
/* The following has a misleading name: starting from 4.0.5, this also
|
|
681 |
affects Windows: */
|
|
682 |
char* innobase_unix_file_flush_method = NULL; |
|
683 |
||
684 |
/* Below we have boolean-valued start-up parameters, and their default
|
|
685 |
values */
|
|
686 |
||
41
by kinoyasu
some performance tuning |
687 |
ulong innobase_fast_shutdown = 1; |
1
by kinoyasu
initial registration |
688 |
my_bool innobase_log_archive = FALSE;/* unused */ |
689 |
my_bool innobase_use_doublewrite = TRUE; |
|
690 |
my_bool innobase_use_checksums = TRUE; |
|
691 |
my_bool innobase_use_large_pages = FALSE; |
|
692 |
my_bool innobase_use_native_aio = FALSE; |
|
693 |
my_bool innobase_file_per_table = FALSE; |
|
694 |
my_bool innobase_locks_unsafe_for_binlog = FALSE; |
|
695 |
my_bool innobase_rollback_on_timeout = FALSE; |
|
696 |
my_bool innobase_create_status_file = FALSE; |
|
697 |
my_bool innobase_adaptive_hash_index = TRUE; |
|
698 |
||
699 |
static char *internal_innobase_data_file_path = NULL; |
|
700 |
||
701 |
/* The following counter is used to convey information to InnoDB
|
|
702 |
about server activity: in selects it is not sensible to call
|
|
703 |
srv_active_wake_master_thread after each fetch or search, we only do
|
|
704 |
it every INNOBASE_WAKE_INTERVAL'th step. */
|
|
705 |
||
706 |
#define INNOBASE_WAKE_INTERVAL 32
|
|
707 |
ulong innobase_active_counter = 0; |
|
708 |
||
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
709 |
/* ======== Datafiles iterator ======== */
|
710 |
typedef struct { |
|
711 |
fil_system_t *system; |
|
712 |
fil_space_t *space; |
|
713 |
fil_node_t *node; |
|
714 |
ibool started; |
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
715 |
os_mutex_t mutex; |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
716 |
} datafiles_iter_t; |
717 |
||
718 |
static
|
|
719 |
datafiles_iter_t * |
|
720 |
datafiles_iter_new(fil_system_t *system) |
|
721 |
{
|
|
722 |
datafiles_iter_t *it; |
|
723 |
||
724 |
it = ut_malloc(sizeof(datafiles_iter_t)); |
|
200
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
725 |
it->mutex = OS_MUTEX_CREATE(); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
726 |
|
727 |
it->system = system; |
|
728 |
it->space = NULL; |
|
729 |
it->node = NULL; |
|
730 |
it->started = FALSE; |
|
731 |
||
732 |
return it; |
|
733 |
}
|
|
734 |
||
735 |
static
|
|
736 |
fil_node_t * |
|
737 |
datafiles_iter_next(datafiles_iter_t *it, ibool *space_changed) |
|
738 |
{
|
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
739 |
os_mutex_enter(it->mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
740 |
|
741 |
*space_changed = FALSE; |
|
742 |
||
743 |
if (it->node == NULL) { |
|
744 |
if (it->started) |
|
745 |
goto end; |
|
746 |
it->started = TRUE; |
|
747 |
} else { |
|
748 |
it->node = UT_LIST_GET_NEXT(chain, it->node); |
|
749 |
if (it->node != NULL) |
|
750 |
goto end; |
|
751 |
}
|
|
752 |
||
753 |
it->space = (it->space == NULL) ? |
|
754 |
UT_LIST_GET_FIRST(it->system->space_list) : |
|
755 |
UT_LIST_GET_NEXT(space_list, it->space); |
|
756 |
||
757 |
while (it->space != NULL && |
|
758 |
(it->space->purpose != FIL_TABLESPACE || |
|
759 |
UT_LIST_GET_LEN(it->space->chain) == 0)) |
|
760 |
it->space = UT_LIST_GET_NEXT(space_list, it->space); |
|
761 |
if (it->space == NULL) |
|
762 |
goto end; |
|
763 |
*space_changed = TRUE; |
|
764 |
||
765 |
it->node = UT_LIST_GET_FIRST(it->space->chain); |
|
766 |
||
767 |
end: |
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
768 |
os_mutex_exit(it->mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
769 |
|
770 |
return it->node; |
|
771 |
}
|
|
772 |
||
773 |
static
|
|
774 |
void
|
|
775 |
datafiles_iter_free(datafiles_iter_t *it) |
|
776 |
{
|
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
777 |
os_mutex_free(it->mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
778 |
ut_free(it); |
779 |
}
|
|
780 |
||
781 |
/* ======== Date copying thread context ======== */
|
|
782 |
||
783 |
typedef struct { |
|
784 |
datafiles_iter_t *it; |
|
785 |
uint num; |
|
786 |
uint *count; |
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
787 |
os_mutex_t count_mutex; |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
788 |
os_thread_id_t id; |
789 |
} data_thread_ctxt_t; |
|
1
by kinoyasu
initial registration |
790 |
|
791 |
/* ======== for option and variables ======== */
|
|
792 |
||
793 |
enum options_xtrabackup |
|
794 |
{
|
|
795 |
OPT_XTRA_TARGET_DIR=256, |
|
796 |
OPT_XTRA_BACKUP, |
|
85
by kinoyasu
new option --stats to gather index stats |
797 |
OPT_XTRA_STATS, |
1
by kinoyasu
initial registration |
798 |
OPT_XTRA_PREPARE, |
60
by kinoyasu
experimantal option --export is added |
799 |
OPT_XTRA_EXPORT, |
179
by kinoyasu
add --apply-log-only option for test only for based on 5.5 version for now. It may be needed for incremental --prepare operation exactly. |
800 |
OPT_XTRA_APPLY_LOG_ONLY, |
5
by kinoyasu
add innobackup support patch, fix some bugs |
801 |
OPT_XTRA_PRINT_PARAM, |
1
by kinoyasu
initial registration |
802 |
OPT_XTRA_SUSPEND_AT_END, |
803 |
OPT_XTRA_USE_MEMORY, |
|
804 |
OPT_XTRA_THROTTLE, |
|
805 |
OPT_XTRA_STREAM, |
|
33
by kinoyasu
primitive implementation of incremental backup |
806 |
OPT_XTRA_INCREMENTAL, |
34
by kinoyasu
more user-friendly incremental backup |
807 |
OPT_XTRA_INCREMENTAL_BASEDIR, |
182.1.1
by Baron Schwartz
add --extra-lsndir to xtrabackup |
808 |
OPT_XTRA_EXTRA_LSNDIR, |
34
by kinoyasu
more user-friendly incremental backup |
809 |
OPT_XTRA_INCREMENTAL_DIR, |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
810 |
OPT_XTRA_TABLES, |
158
by kinoyasu
new option --tables_file is added |
811 |
OPT_XTRA_TABLES_FILE, |
5
by kinoyasu
add innobackup support patch, fix some bugs |
812 |
OPT_XTRA_CREATE_IB_LOGFILE, |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
813 |
OPT_XTRA_PARALLEL, |
1
by kinoyasu
initial registration |
814 |
OPT_INNODB_CHECKSUMS, |
815 |
OPT_INNODB_DATA_FILE_PATH, |
|
816 |
OPT_INNODB_DATA_HOME_DIR, |
|
817 |
OPT_INNODB_ADAPTIVE_HASH_INDEX, |
|
818 |
OPT_INNODB_DOUBLEWRITE, |
|
819 |
OPT_INNODB_FAST_SHUTDOWN, |
|
820 |
OPT_INNODB_FILE_PER_TABLE, |
|
821 |
OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, |
|
822 |
OPT_INNODB_FLUSH_METHOD, |
|
823 |
OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG, |
|
824 |
OPT_INNODB_LOG_ARCH_DIR, |
|
825 |
OPT_INNODB_LOG_ARCHIVE, |
|
826 |
OPT_INNODB_LOG_GROUP_HOME_DIR, |
|
827 |
OPT_INNODB_MAX_DIRTY_PAGES_PCT, |
|
828 |
OPT_INNODB_MAX_PURGE_LAG, |
|
829 |
OPT_INNODB_ROLLBACK_ON_TIMEOUT, |
|
830 |
OPT_INNODB_STATUS_FILE, |
|
831 |
OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE, |
|
832 |
OPT_INNODB_AUTOEXTEND_INCREMENT, |
|
833 |
OPT_INNODB_BUFFER_POOL_SIZE, |
|
834 |
OPT_INNODB_COMMIT_CONCURRENCY, |
|
835 |
OPT_INNODB_CONCURRENCY_TICKETS, |
|
836 |
OPT_INNODB_FILE_IO_THREADS, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
837 |
#ifdef INNODB_VERSION_SHORT
|
838 |
OPT_INNODB_IO_CAPACITY, |
|
839 |
OPT_INNODB_READ_IO_THREADS, |
|
840 |
OPT_INNODB_WRITE_IO_THREADS, |
|
841 |
#endif
|
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
842 |
#ifdef XTRADB_BASED
|
843 |
OPT_INNODB_PAGE_SIZE, |
|
844 |
OPT_INNODB_FAST_CHECKSUM, |
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
845 |
OPT_INNODB_EXTRA_UNDOSLOTS, |
846 |
OPT_INNODB_DOUBLEWRITE_FILE, |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
847 |
#endif
|
1
by kinoyasu
initial registration |
848 |
OPT_INNODB_FORCE_RECOVERY, |
849 |
OPT_INNODB_LOCK_WAIT_TIMEOUT, |
|
850 |
OPT_INNODB_LOG_BUFFER_SIZE, |
|
851 |
OPT_INNODB_LOG_FILE_SIZE, |
|
852 |
OPT_INNODB_LOG_FILES_IN_GROUP, |
|
853 |
OPT_INNODB_MIRRORED_LOG_GROUPS, |
|
854 |
OPT_INNODB_OPEN_FILES, |
|
855 |
OPT_INNODB_SYNC_SPIN_LOOPS, |
|
856 |
OPT_INNODB_THREAD_CONCURRENCY, |
|
80.1.1
by Aleksandr Kuzminsky
Fixed bug#408966 |
857 |
OPT_INNODB_THREAD_SLEEP_DELAY
|
1
by kinoyasu
initial registration |
858 |
};
|
859 |
||
860 |
static struct my_option my_long_options[] = |
|
861 |
{
|
|
94
by kinoyasu
Windows conscious experimental change |
862 |
{"target-dir", OPT_XTRA_TARGET_DIR, "destination directory", (G_PTR*) &xtrabackup_target_dir, |
863 |
(G_PTR*) &xtrabackup_target_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
1
by kinoyasu
initial registration |
864 |
{"backup", OPT_XTRA_BACKUP, "take backup to target-dir", |
94
by kinoyasu
Windows conscious experimental change |
865 |
(G_PTR*) &xtrabackup_backup, (G_PTR*) &xtrabackup_backup, |
1
by kinoyasu
initial registration |
866 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
85
by kinoyasu
new option --stats to gather index stats |
867 |
{"stats", OPT_XTRA_STATS, "calc statistic of datadir (offline mysqld is recommended)", |
94
by kinoyasu
Windows conscious experimental change |
868 |
(G_PTR*) &xtrabackup_stats, (G_PTR*) &xtrabackup_stats, |
85
by kinoyasu
new option --stats to gather index stats |
869 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
1
by kinoyasu
initial registration |
870 |
{"prepare", OPT_XTRA_PREPARE, "prepare a backup for starting mysql server on the backup.", |
94
by kinoyasu
Windows conscious experimental change |
871 |
(G_PTR*) &xtrabackup_prepare, (G_PTR*) &xtrabackup_prepare, |
1
by kinoyasu
initial registration |
872 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
60
by kinoyasu
experimantal option --export is added |
873 |
{"export", OPT_XTRA_EXPORT, "create files to import to another database when prepare.", |
94
by kinoyasu
Windows conscious experimental change |
874 |
(G_PTR*) &xtrabackup_export, (G_PTR*) &xtrabackup_export, |
60
by kinoyasu
experimantal option --export is added |
875 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
179
by kinoyasu
add --apply-log-only option for test only for based on 5.5 version for now. It may be needed for incremental --prepare operation exactly. |
876 |
{"apply-log-only", OPT_XTRA_APPLY_LOG_ONLY, |
877 |
"stop recovery process not to progress LSN after applying log when prepare.", |
|
878 |
(G_PTR*) &xtrabackup_apply_log_only, (G_PTR*) &xtrabackup_apply_log_only, |
|
879 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
880 |
{"print-param", OPT_XTRA_PRINT_PARAM, "print parameter of mysqld needed for copyback.", |
94
by kinoyasu
Windows conscious experimental change |
881 |
(G_PTR*) &xtrabackup_print_param, (G_PTR*) &xtrabackup_print_param, |
5
by kinoyasu
add innobackup support patch, fix some bugs |
882 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
3
by kinoyasu
planned options are implemented |
883 |
{"use-memory", OPT_XTRA_USE_MEMORY, "The value is used instead of buffer_pool_size", |
94
by kinoyasu
Windows conscious experimental change |
884 |
(G_PTR*) &xtrabackup_use_memory, (G_PTR*) &xtrabackup_use_memory, |
3
by kinoyasu
planned options are implemented |
885 |
0, GET_LL, REQUIRED_ARG, 100*1024*1024L, 1024*1024L, LONGLONG_MAX, 0, |
1
by kinoyasu
initial registration |
886 |
1024*1024L, 0}, |
887 |
{"suspend-at-end", OPT_XTRA_SUSPEND_AT_END, "creates a file 'xtrabackup_suspended' and waits until the user deletes that file at the end of '--backup'", |
|
94
by kinoyasu
Windows conscious experimental change |
888 |
(G_PTR*) &xtrabackup_suspend_at_end, (G_PTR*) &xtrabackup_suspend_at_end, |
1
by kinoyasu
initial registration |
889 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
3
by kinoyasu
planned options are implemented |
890 |
{"throttle", OPT_XTRA_THROTTLE, "limit count of IO operations (pairs of read&write) per second to IOS values (for '--backup')", |
94
by kinoyasu
Windows conscious experimental change |
891 |
(G_PTR*) &xtrabackup_throttle, (G_PTR*) &xtrabackup_throttle, |
1
by kinoyasu
initial registration |
892 |
0, GET_LONG, REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1, 0}, |
14
by kinoyasu
using rsync for incremental backup |
893 |
{"log-stream", OPT_XTRA_STREAM, "outputs the contents of 'xtrabackup_logfile' to stdout only until the file 'xtrabackup_suspended' deleted (for '--backup').", |
94
by kinoyasu
Windows conscious experimental change |
894 |
(G_PTR*) &xtrabackup_stream, (G_PTR*) &xtrabackup_stream, |
1
by kinoyasu
initial registration |
895 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
182.1.1
by Baron Schwartz
add --extra-lsndir to xtrabackup |
896 |
{"extra-lsndir", OPT_XTRA_EXTRA_LSNDIR, "(for --backup): save an extra copy of the xtrabackup_checkpoints file in this directory.", |
897 |
(G_PTR*) &xtrabackup_extra_lsndir, (G_PTR*) &xtrabackup_extra_lsndir, |
|
898 |
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
34
by kinoyasu
more user-friendly incremental backup |
899 |
{"incremental-lsn", OPT_XTRA_INCREMENTAL, "(for --backup): copy only .ibd pages newer than specified LSN 'high:low'. ##ATTENTION##: checkpoint lsn must be used. anyone can detect your mistake. be carefully!", |
94
by kinoyasu
Windows conscious experimental change |
900 |
(G_PTR*) &xtrabackup_incremental, (G_PTR*) &xtrabackup_incremental, |
33
by kinoyasu
primitive implementation of incremental backup |
901 |
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
34
by kinoyasu
more user-friendly incremental backup |
902 |
{"incremental-basedir", OPT_XTRA_INCREMENTAL_BASEDIR, "(for --backup): copy only .ibd pages newer than backup at specified directory.", |
94
by kinoyasu
Windows conscious experimental change |
903 |
(G_PTR*) &xtrabackup_incremental_basedir, (G_PTR*) &xtrabackup_incremental_basedir, |
34
by kinoyasu
more user-friendly incremental backup |
904 |
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
905 |
{"incremental-dir", OPT_XTRA_INCREMENTAL_DIR, "(for --prepare): apply .delta files and logfile in the specified directory.", |
|
94
by kinoyasu
Windows conscious experimental change |
906 |
(G_PTR*) &xtrabackup_incremental_dir, (G_PTR*) &xtrabackup_incremental_dir, |
34
by kinoyasu
more user-friendly incremental backup |
907 |
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
33
by kinoyasu
primitive implementation of incremental backup |
908 |
{"tables", OPT_XTRA_TABLES, "filtering by regexp for table names.", |
94
by kinoyasu
Windows conscious experimental change |
909 |
(G_PTR*) &xtrabackup_tables, (G_PTR*) &xtrabackup_tables, |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
910 |
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
158
by kinoyasu
new option --tables_file is added |
911 |
{"tables_file", OPT_XTRA_TABLES_FILE, "filtering by list of the exact database.table name in the file.", |
912 |
(G_PTR*) &xtrabackup_tables_file, (G_PTR*) &xtrabackup_tables_file, |
|
913 |
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
914 |
{"create-ib-logfile", OPT_XTRA_CREATE_IB_LOGFILE, "** not work for now** creates ib_logfile* also after '--prepare'. ### If you want create ib_logfile*, only re-execute this command in same options. ###", |
94
by kinoyasu
Windows conscious experimental change |
915 |
(G_PTR*) &xtrabackup_create_ib_logfile, (G_PTR*) &xtrabackup_create_ib_logfile, |
5
by kinoyasu
add innobackup support patch, fix some bugs |
916 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
1
by kinoyasu
initial registration |
917 |
|
94
by kinoyasu
Windows conscious experimental change |
918 |
{"datadir", 'h', "Path to the database root.", (G_PTR*) &mysql_data_home, |
919 |
(G_PTR*) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
1
by kinoyasu
initial registration |
920 |
{"tmpdir", 't', |
921 |
"Path for temporary files. Several paths may be specified, separated by a "
|
|
922 |
#if defined(__WIN__) || defined(OS2) || defined(__NETWARE__)
|
|
923 |
"semicolon (;)"
|
|
924 |
#else
|
|
925 |
"colon (:)"
|
|
926 |
#endif
|
|
927 |
", in this case they are used in a round-robin fashion.", |
|
94
by kinoyasu
Windows conscious experimental change |
928 |
(G_PTR*) &opt_mysql_tmpdir, |
929 |
(G_PTR*) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
930 |
{"parallel", OPT_XTRA_PARALLEL, |
931 |
"Number of threads to use for parallel datafiles transfer. Does not have "
|
|
932 |
"any effect in the stream mode. The default value is 1.", |
|
933 |
(G_PTR*) ¶llel, (G_PTR*) ¶llel, 0, GET_UINT, REQUIRED_ARG, |
|
934 |
1, 1, UINT_MAX, 0, 0, 0}, |
|
1
by kinoyasu
initial registration |
935 |
|
936 |
{"innodb_adaptive_hash_index", OPT_INNODB_ADAPTIVE_HASH_INDEX, |
|
937 |
"Enable InnoDB adaptive hash index (enabled by default). "
|
|
938 |
"Disable with --skip-innodb-adaptive-hash-index.", |
|
94
by kinoyasu
Windows conscious experimental change |
939 |
(G_PTR*) &innobase_adaptive_hash_index, |
940 |
(G_PTR*) &innobase_adaptive_hash_index, |
|
1
by kinoyasu
initial registration |
941 |
0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, |
942 |
{"innodb_additional_mem_pool_size", OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE, |
|
943 |
"Size of a memory pool InnoDB uses to store data dictionary information and other internal data structures.", |
|
94
by kinoyasu
Windows conscious experimental change |
944 |
(G_PTR*) &innobase_additional_mem_pool_size, |
945 |
(G_PTR*) &innobase_additional_mem_pool_size, 0, GET_LONG, REQUIRED_ARG, |
|
1
by kinoyasu
initial registration |
946 |
1*1024*1024L, 512*1024L, LONG_MAX, 0, 1024, 0}, |
947 |
{"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT, |
|
948 |
"Data file autoextend increment in megabytes", |
|
94
by kinoyasu
Windows conscious experimental change |
949 |
(G_PTR*) &srv_auto_extend_increment, |
950 |
(G_PTR*) &srv_auto_extend_increment, |
|
1
by kinoyasu
initial registration |
951 |
0, GET_ULONG, REQUIRED_ARG, 8L, 1L, 1000L, 0, 1L, 0}, |
952 |
{"innodb_buffer_pool_size", OPT_INNODB_BUFFER_POOL_SIZE, |
|
953 |
"The size of the memory buffer InnoDB uses to cache data and indexes of its tables.", |
|
94
by kinoyasu
Windows conscious experimental change |
954 |
(G_PTR*) &innobase_buffer_pool_size, (G_PTR*) &innobase_buffer_pool_size, 0, |
1
by kinoyasu
initial registration |
955 |
GET_LL, REQUIRED_ARG, 8*1024*1024L, 1024*1024L, LONGLONG_MAX, 0, |
956 |
1024*1024L, 0}, |
|
957 |
{"innodb_checksums", OPT_INNODB_CHECKSUMS, "Enable InnoDB checksums validation (enabled by default). \ |
|
94
by kinoyasu
Windows conscious experimental change |
958 |
Disable with --skip-innodb-checksums.", (G_PTR*) &innobase_use_checksums, |
959 |
(G_PTR*) &innobase_use_checksums, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, |
|
1
by kinoyasu
initial registration |
960 |
/*
|
961 |
{"innodb_commit_concurrency", OPT_INNODB_COMMIT_CONCURRENCY,
|
|
962 |
"Helps in performance tuning in heavily concurrent environments.",
|
|
94
by kinoyasu
Windows conscious experimental change |
963 |
(G_PTR*) &srv_commit_concurrency, (G_PTR*) &srv_commit_concurrency,
|
1
by kinoyasu
initial registration |
964 |
0, GET_ULONG, REQUIRED_ARG, 0, 0, 1000, 0, 1, 0},
|
965 |
*/
|
|
966 |
/*
|
|
967 |
{"innodb_concurrency_tickets", OPT_INNODB_CONCURRENCY_TICKETS,
|
|
968 |
"Number of times a thread is allowed to enter InnoDB within the same \
|
|
969 |
SQL query after it has once got the ticket",
|
|
94
by kinoyasu
Windows conscious experimental change |
970 |
(G_PTR*) &srv_n_free_tickets_to_enter,
|
971 |
(G_PTR*) &srv_n_free_tickets_to_enter,
|
|
1
by kinoyasu
initial registration |
972 |
0, GET_ULONG, REQUIRED_ARG, 500L, 1L, ULONG_MAX, 0, 1L, 0},
|
973 |
*/
|
|
974 |
{"innodb_data_file_path", OPT_INNODB_DATA_FILE_PATH, |
|
94
by kinoyasu
Windows conscious experimental change |
975 |
"Path to individual files and their sizes.", (G_PTR*) &innobase_data_file_path, |
976 |
(G_PTR*) &innobase_data_file_path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
1
by kinoyasu
initial registration |
977 |
{"innodb_data_home_dir", OPT_INNODB_DATA_HOME_DIR, |
94
by kinoyasu
Windows conscious experimental change |
978 |
"The common part for InnoDB table spaces.", (G_PTR*) &innobase_data_home_dir, |
979 |
(G_PTR*) &innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, |
|
1
by kinoyasu
initial registration |
980 |
0}, |
981 |
{"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer (enabled by default). \ |
|
94
by kinoyasu
Windows conscious experimental change |
982 |
Disable with --skip-innodb-doublewrite.", (G_PTR*) &innobase_use_doublewrite, |
983 |
(G_PTR*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
984 |
#ifdef INNODB_VERSION_SHORT
|
985 |
{"innodb_io_capacity", OPT_INNODB_IO_CAPACITY, |
|
986 |
"Number of IOPs the server can do. Tunes the background IO rate", |
|
987 |
(G_PTR*) &srv_io_capacity, (G_PTR*) &srv_io_capacity, |
|
988 |
0, GET_ULONG, OPT_ARG, 200, 100, ~0L, 0, 0, 0}, |
|
989 |
#endif
|
|
1
by kinoyasu
initial registration |
990 |
/*
|
991 |
{"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN,
|
|
992 |
"Speeds up the shutdown process of the InnoDB storage engine. Possible "
|
|
993 |
"values are 0, 1 (faster)"
|
|
994 |
" or 2 (fastest - crash-like)"
|
|
995 |
".",
|
|
94
by kinoyasu
Windows conscious experimental change |
996 |
(G_PTR*) &innobase_fast_shutdown,
|
997 |
(G_PTR*) &innobase_fast_shutdown, 0, GET_ULONG, OPT_ARG, 1, 0,
|
|
1
by kinoyasu
initial registration |
998 |
2, 0, 0, 0},
|
999 |
*/
|
|
1000 |
{"innodb_file_io_threads", OPT_INNODB_FILE_IO_THREADS, |
|
94
by kinoyasu
Windows conscious experimental change |
1001 |
"Number of file I/O threads in InnoDB.", (G_PTR*) &innobase_file_io_threads, |
1002 |
(G_PTR*) &innobase_file_io_threads, 0, GET_LONG, REQUIRED_ARG, 4, 4, 64, 0, |
|
1
by kinoyasu
initial registration |
1003 |
1, 0}, |
100
by kinoyasu
initial implementation for InnoDB Plugin |
1004 |
#ifdef INNODB_VERSION_SHORT
|
1005 |
{"innodb_read_io_threads", OPT_INNODB_READ_IO_THREADS, |
|
1006 |
"Number of background read I/O threads in InnoDB.", (G_PTR*) &innobase_read_io_threads, |
|
1007 |
(G_PTR*) &innobase_read_io_threads, 0, GET_LONG, REQUIRED_ARG, 4, 1, 64, 0, |
|
1008 |
1, 0}, |
|
1009 |
{"innodb_write_io_threads", OPT_INNODB_WRITE_IO_THREADS, |
|
1010 |
"Number of background write I/O threads in InnoDB.", (G_PTR*) &innobase_write_io_threads, |
|
1011 |
(G_PTR*) &innobase_write_io_threads, 0, GET_LONG, REQUIRED_ARG, 4, 1, 64, 0, |
|
1012 |
1, 0}, |
|
1013 |
#endif
|
|
1
by kinoyasu
initial registration |
1014 |
{"innodb_file_per_table", OPT_INNODB_FILE_PER_TABLE, |
1015 |
"Stores each InnoDB table to an .ibd file in the database dir.", |
|
94
by kinoyasu
Windows conscious experimental change |
1016 |
(G_PTR*) &innobase_file_per_table, |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
1017 |
(G_PTR*) &innobase_file_per_table, 0, GET_BOOL, NO_ARG, |
1018 |
#if (MYSQL_VERSION_ID < 50500)
|
|
1019 |
0, |
|
1020 |
#else
|
|
1021 |
1, |
|
1022 |
#endif
|
|
1023 |
0, 0, 0, 0, 0}, |
|
1
by kinoyasu
initial registration |
1024 |
{"innodb_flush_log_at_trx_commit", OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT, |
1025 |
"Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2 (write at commit, flush once per second).", |
|
94
by kinoyasu
Windows conscious experimental change |
1026 |
(G_PTR*) &srv_flush_log_at_trx_commit, |
1027 |
(G_PTR*) &srv_flush_log_at_trx_commit, |
|
1
by kinoyasu
initial registration |
1028 |
0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0}, |
1029 |
{"innodb_flush_method", OPT_INNODB_FLUSH_METHOD, |
|
94
by kinoyasu
Windows conscious experimental change |
1030 |
"With which method to flush data.", (G_PTR*) &innobase_unix_file_flush_method, |
1031 |
(G_PTR*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, |
|
1
by kinoyasu
initial registration |
1032 |
0, 0, 0}, |
1033 |
||
1034 |
/* ####### Should we use this option? ####### */
|
|
1035 |
{"innodb_force_recovery", OPT_INNODB_FORCE_RECOVERY, |
|
1036 |
"Helps to save your data in case the disk image of the database becomes corrupt.", |
|
94
by kinoyasu
Windows conscious experimental change |
1037 |
(G_PTR*) &innobase_force_recovery, (G_PTR*) &innobase_force_recovery, 0, |
1
by kinoyasu
initial registration |
1038 |
GET_LONG, REQUIRED_ARG, 0, 0, 6, 0, 1, 0}, |
1039 |
||
1040 |
{"innodb_lock_wait_timeout", OPT_INNODB_LOCK_WAIT_TIMEOUT, |
|
1041 |
"Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back.", |
|
94
by kinoyasu
Windows conscious experimental change |
1042 |
(G_PTR*) &innobase_lock_wait_timeout, (G_PTR*) &innobase_lock_wait_timeout, |
1
by kinoyasu
initial registration |
1043 |
0, GET_LONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0}, |
1044 |
/*
|
|
1045 |
{"innodb_locks_unsafe_for_binlog", OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG,
|
|
1046 |
"Force InnoDB not to use next-key locking. Instead use only row-level locking",
|
|
94
by kinoyasu
Windows conscious experimental change |
1047 |
(G_PTR*) &innobase_locks_unsafe_for_binlog,
|
1048 |
(G_PTR*) &innobase_locks_unsafe_for_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
|
1
by kinoyasu
initial registration |
1049 |
*/
|
1050 |
/*
|
|
1051 |
{"innodb_log_arch_dir", OPT_INNODB_LOG_ARCH_DIR,
|
|
94
by kinoyasu
Windows conscious experimental change |
1052 |
"Where full logs should be archived.", (G_PTR*) &innobase_log_arch_dir,
|
1053 |
(G_PTR*) &innobase_log_arch_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
|
1
by kinoyasu
initial registration |
1054 |
*/
|
1055 |
{"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE, |
|
1056 |
"The size of the buffer which InnoDB uses to write log to the log files on disk.", |
|
94
by kinoyasu
Windows conscious experimental change |
1057 |
(G_PTR*) &innobase_log_buffer_size, (G_PTR*) &innobase_log_buffer_size, 0, |
1
by kinoyasu
initial registration |
1058 |
GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, LONG_MAX, 0, 1024, 0}, |
1059 |
{"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE, |
|
1060 |
"Size of each log file in a log group.", |
|
94
by kinoyasu
Windows conscious experimental change |
1061 |
(G_PTR*) &innobase_log_file_size, (G_PTR*) &innobase_log_file_size, 0, |
1
by kinoyasu
initial registration |
1062 |
GET_LL, REQUIRED_ARG, 5*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 0, |
1063 |
1024*1024L, 0}, |
|
1064 |
{"innodb_log_files_in_group", OPT_INNODB_LOG_FILES_IN_GROUP, |
|
1065 |
"Number of log files in the log group. InnoDB writes to the files in a circular fashion. Value 3 is recommended here.", |
|
94
by kinoyasu
Windows conscious experimental change |
1066 |
(G_PTR*) &innobase_log_files_in_group, (G_PTR*) &innobase_log_files_in_group, |
1
by kinoyasu
initial registration |
1067 |
0, GET_LONG, REQUIRED_ARG, 2, 2, 100, 0, 1, 0}, |
1068 |
{"innodb_log_group_home_dir", OPT_INNODB_LOG_GROUP_HOME_DIR, |
|
94
by kinoyasu
Windows conscious experimental change |
1069 |
"Path to InnoDB log files.", (G_PTR*) &innobase_log_group_home_dir, |
1070 |
(G_PTR*) &innobase_log_group_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, |
|
1
by kinoyasu
initial registration |
1071 |
0, 0}, |
1072 |
{"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT, |
|
94
by kinoyasu
Windows conscious experimental change |
1073 |
"Percentage of dirty pages allowed in bufferpool.", (G_PTR*) &srv_max_buf_pool_modified_pct, |
1074 |
(G_PTR*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0}, |
|
1
by kinoyasu
initial registration |
1075 |
/*
|
1076 |
{"innodb_max_purge_lag", OPT_INNODB_MAX_PURGE_LAG,
|
|
1077 |
"Desired maximum length of the purge queue (0 = no limit)",
|
|
94
by kinoyasu
Windows conscious experimental change |
1078 |
(G_PTR*) &srv_max_purge_lag,
|
1079 |
(G_PTR*) &srv_max_purge_lag, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX,
|
|
1
by kinoyasu
initial registration |
1080 |
0, 1L, 0},
|
1081 |
*/
|
|
1082 |
/*
|
|
1083 |
{"innodb_mirrored_log_groups", OPT_INNODB_MIRRORED_LOG_GROUPS,
|
|
1084 |
"Number of identical copies of log groups we keep for the database. Currently this should be set to 1.",
|
|
94
by kinoyasu
Windows conscious experimental change |
1085 |
(G_PTR*) &innobase_mirrored_log_groups,
|
1086 |
(G_PTR*) &innobase_mirrored_log_groups, 0, GET_LONG, REQUIRED_ARG, 1, 1, 10,
|
|
1
by kinoyasu
initial registration |
1087 |
0, 1, 0},
|
1088 |
*/
|
|
1089 |
{"innodb_open_files", OPT_INNODB_OPEN_FILES, |
|
1090 |
"How many files at the maximum InnoDB keeps open at the same time.", |
|
94
by kinoyasu
Windows conscious experimental change |
1091 |
(G_PTR*) &innobase_open_files, (G_PTR*) &innobase_open_files, 0, |
1
by kinoyasu
initial registration |
1092 |
GET_LONG, REQUIRED_ARG, 300L, 10L, LONG_MAX, 0, 1L, 0}, |
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
1093 |
#ifdef XTRADB_BASED
|
1094 |
{"innodb_page_size", OPT_INNODB_PAGE_SIZE, |
|
1095 |
"The universal page size of the database.", |
|
1096 |
(G_PTR*) &innobase_page_size, (G_PTR*) &innobase_page_size, 0, |
|
1097 |
GET_LONG, REQUIRED_ARG, (1 << 14), (1 << 12), (1 << UNIV_PAGE_SIZE_SHIFT_MAX), 0, 1L, 0}, |
|
1098 |
{"innodb_fast_checksum", OPT_INNODB_FAST_CHECKSUM, |
|
1099 |
"Change the algorithm of checksum for the whole of datapage to 4-bytes word based.", |
|
1100 |
(G_PTR*) &innobase_fast_checksum, |
|
1101 |
(G_PTR*) &innobase_fast_checksum, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
1102 |
{"innodb_extra_undoslots", OPT_INNODB_EXTRA_UNDOSLOTS, |
1103 |
"Enable to use about 4000 undo slots instead of default 1024. Not recommended to use, "
|
|
1104 |
"Because it is not change back to disable, once it is used.", |
|
1105 |
(G_PTR*) &innobase_extra_undoslots, (G_PTR*) &innobase_extra_undoslots, |
|
1106 |
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
|
1107 |
{"innodb_doublewrite_file", OPT_INNODB_DOUBLEWRITE_FILE, |
|
1108 |
"Path to special datafile for doublewrite buffer. (default is "": not used)", |
|
1109 |
(G_PTR*) &innobase_doublewrite_file, (G_PTR*) &innobase_doublewrite_file, |
|
1110 |
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
1111 |
#endif
|
1
by kinoyasu
initial registration |
1112 |
/*
|
1113 |
{"innodb_rollback_on_timeout", OPT_INNODB_ROLLBACK_ON_TIMEOUT,
|
|
1114 |
"Roll back the complete transaction on lock wait timeout, for 4.x compatibility (disabled by default)",
|
|
94
by kinoyasu
Windows conscious experimental change |
1115 |
(G_PTR*) &innobase_rollback_on_timeout, (G_PTR*) &innobase_rollback_on_timeout,
|
1
by kinoyasu
initial registration |
1116 |
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
1117 |
*/
|
|
1118 |
/*
|
|
1119 |
{"innodb_status_file", OPT_INNODB_STATUS_FILE,
|
|
1120 |
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
|
|
94
by kinoyasu
Windows conscious experimental change |
1121 |
(G_PTR*) &innobase_create_status_file, (G_PTR*) &innobase_create_status_file,
|
1
by kinoyasu
initial registration |
1122 |
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
|
1123 |
*/
|
|
1124 |
/*
|
|
1125 |
{"innodb_sync_spin_loops", OPT_INNODB_SYNC_SPIN_LOOPS,
|
|
1126 |
"Count of spin-loop rounds in InnoDB mutexes",
|
|
94
by kinoyasu
Windows conscious experimental change |
1127 |
(G_PTR*) &srv_n_spin_wait_rounds,
|
1128 |
(G_PTR*) &srv_n_spin_wait_rounds,
|
|
1
by kinoyasu
initial registration |
1129 |
0, GET_ULONG, REQUIRED_ARG, 20L, 0L, ULONG_MAX, 0, 1L, 0},
|
1130 |
*/
|
|
1131 |
/*
|
|
1132 |
{"innodb_thread_concurrency", OPT_INNODB_THREAD_CONCURRENCY,
|
|
1133 |
"Helps in performance tuning in heavily concurrent environments. "
|
|
1134 |
"Sets the maximum number of threads allowed inside InnoDB. Value 0"
|
|
1135 |
" will disable the thread throttling.",
|
|
94
by kinoyasu
Windows conscious experimental change |
1136 |
(G_PTR*) &srv_thread_concurrency, (G_PTR*) &srv_thread_concurrency,
|
1
by kinoyasu
initial registration |
1137 |
0, GET_ULONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0},
|
1138 |
*/
|
|
1139 |
/*
|
|
1140 |
{"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY,
|
|
1141 |
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0"
|
|
1142 |
" disable a sleep",
|
|
94
by kinoyasu
Windows conscious experimental change |
1143 |
(G_PTR*) &srv_thread_sleep_delay,
|
1144 |
(G_PTR*) &srv_thread_sleep_delay,
|
|
1
by kinoyasu
initial registration |
1145 |
0, GET_ULONG, REQUIRED_ARG, 10000L, 0L, ULONG_MAX, 0, 1L, 0},
|
1146 |
*/
|
|
1147 |
||
1148 |
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} |
|
1149 |
};
|
|
1150 |
||
1151 |
static const char *load_default_groups[]= { "mysqld","xtrabackup",0 }; |
|
1152 |
||
1153 |
static void print_version(void) |
|
1154 |
{
|
|
77.1.1
by Aleksandr Kuzminsky
1) xtrabackup prints source code revision number set via XTRABACKUP_REVISION |
1155 |
printf("%s Ver %s Rev %s for %s %s (%s)\n" ,my_progname, |
1156 |
XTRABACKUP_VERSION, XTRABACKUP_REVISION, MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); |
|
1
by kinoyasu
initial registration |
1157 |
}
|
1158 |
||
1159 |
static void usage(void) |
|
1160 |
{
|
|
80.1.2
by Aleksandr Kuzminsky
fixed syntax error |
1161 |
puts("Open source backup tool for InnoDB and XtraDB\n\ |
1162 |
\n\ |
|
1163 |
Copyright (C) 2009 Percona Inc.\n\ |
|
1164 |
\n\ |
|
1165 |
This program is free software; you can redistribute it and/or\n\ |
|
1166 |
modify it under the terms of the GNU General Public License\n\ |
|
1167 |
as published by the Free Software Foundation version 2\n\ |
|
1168 |
of the License.\n\ |
|
1169 |
\n\ |
|
1170 |
This program is distributed in the hope that it will be useful,\n\ |
|
1171 |
but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ |
|
1172 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ |
|
1173 |
GNU General Public License for more details.\n\ |
|
1174 |
\n\ |
|
1175 |
You can download full text of the license on http://www.gnu.org/licenses/gpl-2.0.txt\n"); |
|
1
by kinoyasu
initial registration |
1176 |
|
43
by kinoyasu
fix bug 358266, bug 359341 |
1177 |
printf("Usage: [%s [--defaults-file=#] --backup | %s [--defaults-file=#] --prepare] [OPTIONS]\n",my_progname,my_progname); |
1
by kinoyasu
initial registration |
1178 |
print_defaults("my",load_default_groups); |
1179 |
my_print_help(my_long_options); |
|
1180 |
my_print_variables(my_long_options); |
|
1181 |
}
|
|
1182 |
||
1183 |
static my_bool |
|
1184 |
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), |
|
1185 |
char *argument) |
|
1186 |
{
|
|
1187 |
switch(optid) { |
|
1188 |
case 'h': |
|
1189 |
strmake(mysql_real_data_home,argument, sizeof(mysql_real_data_home)-1); |
|
1190 |
mysql_data_home= mysql_real_data_home; |
|
1191 |
break; |
|
1192 |
case OPT_XTRA_TARGET_DIR: |
|
1193 |
strmake(xtrabackup_real_target_dir,argument, sizeof(xtrabackup_real_target_dir)-1); |
|
1194 |
xtrabackup_target_dir= xtrabackup_real_target_dir; |
|
1195 |
break; |
|
1196 |
case '?': |
|
1197 |
usage(); |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
1198 |
exit(EXIT_SUCCESS); |
1
by kinoyasu
initial registration |
1199 |
break; |
1200 |
default: |
|
1201 |
break; |
|
1202 |
}
|
|
1203 |
return 0; |
|
1204 |
}
|
|
1205 |
||
1206 |
/* ================ Dummys =================== */
|
|
1207 |
||
18
by kinoyasu
supporting MySQL 5.1 |
1208 |
ibool
|
1209 |
thd_is_replication_slave_thread( |
|
1210 |
void* thd) |
|
1211 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1212 |
fprintf(stderr, "xtrabackup: thd_is_replication_slave_thread() is called\n"); |
85
by kinoyasu
new option --stats to gather index stats |
1213 |
return(FALSE); |
18
by kinoyasu
supporting MySQL 5.1 |
1214 |
}
|
1215 |
||
1216 |
ibool
|
|
1217 |
thd_has_edited_nontrans_tables( |
|
1218 |
void* thd) |
|
1219 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1220 |
fprintf(stderr, "xtrabackup: thd_has_edited_nontrans_tables() is called\n"); |
85
by kinoyasu
new option --stats to gather index stats |
1221 |
return(FALSE); |
18
by kinoyasu
supporting MySQL 5.1 |
1222 |
}
|
1223 |
||
1224 |
ibool
|
|
1225 |
thd_is_select( |
|
1226 |
const void* thd) |
|
1227 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1228 |
fprintf(stderr, "xtrabackup: thd_is_select() is called\n"); |
85
by kinoyasu
new option --stats to gather index stats |
1229 |
return(FALSE); |
18
by kinoyasu
supporting MySQL 5.1 |
1230 |
}
|
1231 |
||
1
by kinoyasu
initial registration |
1232 |
void
|
1233 |
innobase_mysql_prepare_print_arbitrary_thd(void) |
|
1234 |
{
|
|
11
by kinoyasu
fix tribials |
1235 |
/* do nothing */
|
1
by kinoyasu
initial registration |
1236 |
}
|
1237 |
||
1238 |
void
|
|
1239 |
innobase_mysql_end_print_arbitrary_thd(void) |
|
1240 |
{
|
|
11
by kinoyasu
fix tribials |
1241 |
/* do nothing */
|
1
by kinoyasu
initial registration |
1242 |
}
|
1243 |
||
1244 |
void
|
|
1245 |
innobase_mysql_print_thd( |
|
1246 |
FILE* f, |
|
1247 |
void* input_thd, |
|
1248 |
uint max_query_len) |
|
1249 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1250 |
fprintf(stderr, "xtrabackup: innobase_mysql_print_thd() is called\n"); |
1
by kinoyasu
initial registration |
1251 |
}
|
1252 |
||
1253 |
void
|
|
1254 |
innobase_get_cset_width( |
|
1255 |
ulint cset, |
|
1256 |
ulint* mbminlen, |
|
1257 |
ulint* mbmaxlen) |
|
1258 |
{
|
|
1259 |
CHARSET_INFO* cs; |
|
1260 |
ut_ad(cset < 256); |
|
1261 |
ut_ad(mbminlen); |
|
1262 |
ut_ad(mbmaxlen); |
|
1263 |
||
1264 |
cs = all_charsets[cset]; |
|
1265 |
if (cs) { |
|
1266 |
*mbminlen = cs->mbminlen; |
|
1267 |
*mbmaxlen = cs->mbmaxlen; |
|
1268 |
} else { |
|
1269 |
ut_a(cset == 0); |
|
1270 |
*mbminlen = *mbmaxlen = 0; |
|
1271 |
}
|
|
1272 |
}
|
|
1273 |
||
18
by kinoyasu
supporting MySQL 5.1 |
1274 |
void
|
1275 |
innobase_convert_from_table_id( |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1276 |
#ifdef INNODB_VERSION_SHORT
|
1277 |
struct charset_info_st* cs, |
|
1278 |
#endif
|
|
18
by kinoyasu
supporting MySQL 5.1 |
1279 |
char* to, |
1280 |
const char* from, |
|
1281 |
ulint len) |
|
1282 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1283 |
fprintf(stderr, "xtrabackup: innobase_convert_from_table_id() is called\n"); |
18
by kinoyasu
supporting MySQL 5.1 |
1284 |
}
|
1285 |
||
1286 |
void
|
|
1287 |
innobase_convert_from_id( |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1288 |
#ifdef INNODB_VERSION_SHORT
|
1289 |
struct charset_info_st* cs, |
|
1290 |
#endif
|
|
18
by kinoyasu
supporting MySQL 5.1 |
1291 |
char* to, |
1292 |
const char* from, |
|
1293 |
ulint len) |
|
1294 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1295 |
fprintf(stderr, "xtrabackup: innobase_convert_from_id() is called\n"); |
18
by kinoyasu
supporting MySQL 5.1 |
1296 |
}
|
1297 |
||
1
by kinoyasu
initial registration |
1298 |
int
|
1299 |
innobase_strcasecmp( |
|
1300 |
const char* a, |
|
1301 |
const char* b) |
|
1302 |
{
|
|
1303 |
return(my_strcasecmp(&my_charset_utf8_general_ci, a, b)); |
|
1304 |
}
|
|
1305 |
||
1306 |
void
|
|
1307 |
innobase_casedn_str( |
|
1308 |
char* a) |
|
1309 |
{
|
|
11
by kinoyasu
fix tribials |
1310 |
my_casedn_str(&my_charset_utf8_general_ci, a); |
1
by kinoyasu
initial registration |
1311 |
}
|
1312 |
||
18
by kinoyasu
supporting MySQL 5.1 |
1313 |
struct charset_info_st* |
1314 |
innobase_get_charset( |
|
1315 |
void* mysql_thd) |
|
1316 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1317 |
fprintf(stderr, "xtrabackup: innobase_get_charset() is called\n"); |
85
by kinoyasu
new option --stats to gather index stats |
1318 |
return(NULL); |
18
by kinoyasu
supporting MySQL 5.1 |
1319 |
}
|
1320 |
||
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
1321 |
const char* |
1322 |
innobase_get_stmt( |
|
1323 |
void* mysql_thd, |
|
1324 |
size_t* length) |
|
1325 |
{
|
|
1326 |
fprintf(stderr, "xtrabackup: innobase_get_stmt() is called\n"); |
|
1327 |
return("nothing"); |
|
1328 |
}
|
|
1329 |
||
1
by kinoyasu
initial registration |
1330 |
int
|
1331 |
innobase_mysql_tmpfile(void) |
|
1332 |
{
|
|
1333 |
char filename[FN_REFLEN]; |
|
1334 |
int fd2 = -1; |
|
1335 |
File fd = create_temp_file(filename, my_tmpdir(&mysql_tmpdir_list), "ib", |
|
1336 |
#ifdef __WIN__
|
|
1337 |
O_BINARY | O_TRUNC | O_SEQUENTIAL | |
|
1338 |
O_TEMPORARY | O_SHORT_LIVED | |
|
1339 |
#endif /* __WIN__ */ |
|
1340 |
O_CREAT | O_EXCL | O_RDWR, |
|
1341 |
MYF(MY_WME)); |
|
1342 |
if (fd >= 0) { |
|
1343 |
#ifndef __WIN__
|
|
1344 |
/* On Windows, open files cannot be removed, but files can be
|
|
1345 |
created with the O_TEMPORARY flag to the same effect
|
|
1346 |
("delete on close"). */
|
|
1347 |
unlink(filename); |
|
1348 |
#endif /* !__WIN__ */ |
|
1349 |
/* Copy the file descriptor, so that the additional resources
|
|
1350 |
allocated by create_temp_file() can be freed by invoking
|
|
1351 |
my_close().
|
|
1352 |
||
1353 |
Because the file descriptor returned by this function
|
|
1354 |
will be passed to fdopen(), it will be closed by invoking
|
|
1355 |
fclose(), which in turn will invoke close() instead of
|
|
1356 |
my_close(). */
|
|
1357 |
fd2 = dup(fd); |
|
1358 |
if (fd2 < 0) { |
|
45
by kinoyasu
messages are fixed a little |
1359 |
fprintf(stderr, "xtrabackup: Got error %d on dup\n",fd2); |
1
by kinoyasu
initial registration |
1360 |
}
|
1361 |
my_close(fd, MYF(MY_WME)); |
|
1362 |
}
|
|
1363 |
return(fd2); |
|
1364 |
}
|
|
1365 |
||
1366 |
void
|
|
1367 |
innobase_invalidate_query_cache( |
|
1368 |
trx_t* trx, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1369 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
1370 |
char* full_name, |
100
by kinoyasu
initial implementation for InnoDB Plugin |
1371 |
#else
|
1372 |
const char* full_name, |
|
1373 |
#endif
|
|
1
by kinoyasu
initial registration |
1374 |
ulint full_name_len) |
1375 |
{
|
|
11
by kinoyasu
fix tribials |
1376 |
/* do nothing */
|
1
by kinoyasu
initial registration |
1377 |
}
|
1378 |
||
1379 |
int
|
|
1380 |
mysql_get_identifier_quote_char( |
|
1381 |
trx_t* trx, |
|
1382 |
const char* name, |
|
1383 |
ulint namelen) |
|
1384 |
{
|
|
11
by kinoyasu
fix tribials |
1385 |
return '"'; |
1
by kinoyasu
initial registration |
1386 |
}
|
1387 |
||
18
by kinoyasu
supporting MySQL 5.1 |
1388 |
void
|
1389 |
innobase_print_identifier( |
|
1390 |
FILE* f, |
|
1391 |
trx_t* trx, |
|
1392 |
ibool table_id, |
|
1393 |
const char* name, |
|
1394 |
ulint namelen) |
|
1395 |
{
|
|
1396 |
const char* s = name; |
|
94
by kinoyasu
Windows conscious experimental change |
1397 |
const char* e = s + namelen; |
18
by kinoyasu
supporting MySQL 5.1 |
1398 |
int q; |
1399 |
||
1400 |
q = '"'; |
|
1401 |
||
1402 |
putc(q, f); |
|
1403 |
while (s < e) { |
|
1404 |
int c = *s++; |
|
1405 |
if (c == q) { |
|
1406 |
putc(c, f); |
|
1407 |
}
|
|
1408 |
putc(c, f); |
|
1409 |
}
|
|
1410 |
putc(q, f); |
|
1411 |
}
|
|
1412 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
1413 |
/*****************************************************************//**
|
1414 |
Convert an SQL identifier to the MySQL system_charset_info (UTF-8)
|
|
1415 |
and quote it if needed.
|
|
1416 |
@return pointer to the end of buf */
|
|
1417 |
static
|
|
1418 |
char* |
|
1419 |
innobase_convert_identifier( |
|
1420 |
/*========================*/
|
|
1421 |
char* buf, /*!< out: buffer for converted identifier */ |
|
1422 |
ulint buflen, /*!< in: length of buf, in bytes */ |
|
1423 |
const char* id, /*!< in: identifier to convert */ |
|
1424 |
ulint idlen, /*!< in: length of id, in bytes */ |
|
1425 |
void* thd, /*!< in: MySQL connection thread, or NULL */ |
|
1426 |
ibool file_id)/*!< in: TRUE=id is a table or database name; |
|
1427 |
FALSE=id is an UTF-8 string */
|
|
1428 |
{
|
|
1429 |
const char* s = id; |
|
1430 |
int q; |
|
1431 |
||
1432 |
/* See if the identifier needs to be quoted. */
|
|
1433 |
q = '"'; |
|
1434 |
||
1435 |
if (q == EOF) { |
|
1436 |
if (UNIV_UNLIKELY(idlen > buflen)) { |
|
1437 |
idlen = buflen; |
|
1438 |
}
|
|
1439 |
memcpy(buf, s, idlen); |
|
1440 |
return(buf + idlen); |
|
1441 |
}
|
|
1442 |
||
1443 |
/* Quote the identifier. */
|
|
1444 |
if (buflen < 2) { |
|
1445 |
return(buf); |
|
1446 |
}
|
|
1447 |
||
1448 |
*buf++ = q; |
|
1449 |
buflen--; |
|
1450 |
||
1451 |
for (; idlen; idlen--) { |
|
1452 |
int c = *s++; |
|
1453 |
if (UNIV_UNLIKELY(c == q)) { |
|
1454 |
if (UNIV_UNLIKELY(buflen < 3)) { |
|
1455 |
break; |
|
1456 |
}
|
|
1457 |
||
1458 |
*buf++ = c; |
|
1459 |
*buf++ = c; |
|
1460 |
buflen -= 2; |
|
1461 |
} else { |
|
1462 |
if (UNIV_UNLIKELY(buflen < 2)) { |
|
1463 |
break; |
|
1464 |
}
|
|
1465 |
||
1466 |
*buf++ = c; |
|
1467 |
buflen--; |
|
1468 |
}
|
|
1469 |
}
|
|
1470 |
||
1471 |
*buf++ = q; |
|
1472 |
return(buf); |
|
1473 |
}
|
|
1474 |
||
1475 |
/*****************************************************************//**
|
|
1476 |
Convert a table or index name to the MySQL system_charset_info (UTF-8)
|
|
1477 |
and quote it if needed.
|
|
1478 |
@return pointer to the end of buf */
|
|
1479 |
char* |
|
1480 |
innobase_convert_name( |
|
1481 |
/*==================*/
|
|
1482 |
char* buf, /*!< out: buffer for converted identifier */ |
|
1483 |
ulint buflen, /*!< in: length of buf, in bytes */ |
|
1484 |
const char* id, /*!< in: identifier to convert */ |
|
1485 |
ulint idlen, /*!< in: length of id, in bytes */ |
|
1486 |
void* thd, /*!< in: MySQL connection thread, or NULL */ |
|
1487 |
ibool table_id)/*!< in: TRUE=id is a table or database name; |
|
1488 |
FALSE=id is an index name */
|
|
1489 |
{
|
|
1490 |
char* s = buf; |
|
1491 |
const char* bufend = buf + buflen; |
|
1492 |
||
1493 |
if (table_id) { |
|
1494 |
const char* slash = (const char*) memchr(id, '/', idlen); |
|
1495 |
if (!slash) { |
|
1496 |
||
1497 |
goto no_db_name; |
|
1498 |
}
|
|
1499 |
||
1500 |
/* Print the database name and table name separately. */
|
|
1501 |
s = innobase_convert_identifier(s, bufend - s, id, slash - id, |
|
1502 |
thd, TRUE); |
|
1503 |
if (UNIV_LIKELY(s < bufend)) { |
|
1504 |
*s++ = '.'; |
|
1505 |
s = innobase_convert_identifier(s, bufend - s, |
|
1506 |
slash + 1, idlen |
|
1507 |
- (slash - id) - 1, |
|
1508 |
thd, TRUE); |
|
1509 |
}
|
|
159
by kinoyasu
recover 5.1 builtin base version support, and remove unused or obsolete patches |
1510 |
#ifdef INNODB_VERSION_SHORT
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1511 |
} else if (UNIV_UNLIKELY(*id == TEMP_INDEX_PREFIX)) { |
1512 |
/* Temporary index name (smart ALTER TABLE) */
|
|
1513 |
const char temp_index_suffix[]= "--temporary--"; |
|
1514 |
||
1515 |
s = innobase_convert_identifier(buf, buflen, id + 1, idlen - 1, |
|
1516 |
thd, FALSE); |
|
1517 |
if (s - buf + (sizeof temp_index_suffix - 1) < buflen) { |
|
1518 |
memcpy(s, temp_index_suffix, |
|
1519 |
sizeof temp_index_suffix - 1); |
|
1520 |
s += sizeof temp_index_suffix - 1; |
|
1521 |
}
|
|
159
by kinoyasu
recover 5.1 builtin base version support, and remove unused or obsolete patches |
1522 |
#endif
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1523 |
} else { |
1524 |
no_db_name: |
|
1525 |
s = innobase_convert_identifier(buf, buflen, id, idlen, |
|
1526 |
thd, table_id); |
|
1527 |
}
|
|
1528 |
||
1529 |
return(s); |
|
1530 |
||
1531 |
}
|
|
1532 |
||
1
by kinoyasu
initial registration |
1533 |
ibool
|
1534 |
trx_is_interrupted( |
|
1535 |
trx_t* trx) |
|
1536 |
{
|
|
11
by kinoyasu
fix tribials |
1537 |
/* There are no mysql_thd */
|
1538 |
return(FALSE); |
|
1
by kinoyasu
initial registration |
1539 |
}
|
1540 |
||
1541 |
int
|
|
1542 |
innobase_mysql_cmp( |
|
1543 |
int mysql_type, |
|
1544 |
uint charset_number, |
|
1545 |
unsigned char* a, |
|
1546 |
unsigned int a_length, |
|
1547 |
unsigned char* b, |
|
1548 |
unsigned int b_length) |
|
1549 |
{
|
|
11
by kinoyasu
fix tribials |
1550 |
CHARSET_INFO* charset; |
1551 |
enum enum_field_types mysql_tp; |
|
1552 |
int ret; |
|
1553 |
||
1554 |
DBUG_ASSERT(a_length != UNIV_SQL_NULL); |
|
1555 |
DBUG_ASSERT(b_length != UNIV_SQL_NULL); |
|
1556 |
||
1557 |
mysql_tp = (enum enum_field_types) mysql_type; |
|
1558 |
||
1559 |
switch (mysql_tp) { |
|
1560 |
||
1561 |
case MYSQL_TYPE_BIT: |
|
1562 |
case MYSQL_TYPE_STRING: |
|
1563 |
case MYSQL_TYPE_VAR_STRING: |
|
1564 |
case FIELD_TYPE_TINY_BLOB: |
|
1565 |
case FIELD_TYPE_MEDIUM_BLOB: |
|
1566 |
case FIELD_TYPE_BLOB: |
|
1567 |
case FIELD_TYPE_LONG_BLOB: |
|
1568 |
case MYSQL_TYPE_VARCHAR: |
|
1569 |
/* Use the charset number to pick the right charset struct for
|
|
1570 |
the comparison. Since the MySQL function get_charset may be
|
|
1571 |
slow before Bar removes the mutex operation there, we first
|
|
1572 |
look at 2 common charsets directly. */
|
|
1573 |
||
1574 |
if (charset_number == default_charset_info->number) { |
|
1575 |
charset = default_charset_info; |
|
1576 |
} else if (charset_number == my_charset_latin1.number) { |
|
1577 |
charset = &my_charset_latin1; |
|
1578 |
} else { |
|
1579 |
charset = get_charset(charset_number, MYF(MY_WME)); |
|
1580 |
||
1581 |
if (charset == NULL) { |
|
45
by kinoyasu
messages are fixed a little |
1582 |
fprintf(stderr, "xtrabackup: InnoDB needs charset %lu for doing " |
11
by kinoyasu
fix tribials |
1583 |
"a comparison, but MySQL cannot "
|
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
1584 |
"find that charset.\n", |
11
by kinoyasu
fix tribials |
1585 |
(ulong) charset_number); |
1586 |
ut_a(0); |
|
1587 |
}
|
|
1588 |
}
|
|
1589 |
||
1590 |
/* Starting from 4.1.3, we use strnncollsp() in comparisons of
|
|
1591 |
non-latin1_swedish_ci strings. NOTE that the collation order
|
|
1592 |
changes then: 'b\0\0...' is ordered BEFORE 'b ...'. Users
|
|
1593 |
having indexes on such data need to rebuild their tables! */
|
|
1594 |
||
1595 |
ret = charset->coll->strnncollsp(charset, |
|
1596 |
a, a_length, |
|
1597 |
b, b_length, 0); |
|
1598 |
if (ret < 0) { |
|
1599 |
return(-1); |
|
1600 |
} else if (ret > 0) { |
|
1601 |
return(1); |
|
1602 |
} else { |
|
1603 |
return(0); |
|
1604 |
}
|
|
1605 |
default: |
|
1606 |
assert(0); |
|
1607 |
}
|
|
1608 |
||
1609 |
return(0); |
|
1
by kinoyasu
initial registration |
1610 |
}
|
1611 |
||
1612 |
ulint
|
|
1613 |
innobase_get_at_most_n_mbchars( |
|
1614 |
ulint charset_id, |
|
1615 |
ulint prefix_len, |
|
1616 |
ulint data_len, |
|
1617 |
const char* str) |
|
1618 |
{
|
|
11
by kinoyasu
fix tribials |
1619 |
ulint char_length; /* character length in bytes */ |
1620 |
ulint n_chars; /* number of characters in prefix */ |
|
1621 |
CHARSET_INFO* charset; /* charset used in the field */ |
|
1622 |
||
1623 |
charset = get_charset((uint) charset_id, MYF(MY_WME)); |
|
1624 |
||
1625 |
ut_ad(charset); |
|
1626 |
ut_ad(charset->mbmaxlen); |
|
1627 |
||
1628 |
/* Calculate how many characters at most the prefix index contains */
|
|
1629 |
||
1630 |
n_chars = prefix_len / charset->mbmaxlen; |
|
1631 |
||
1632 |
/* If the charset is multi-byte, then we must find the length of the
|
|
1633 |
first at most n chars in the string. If the string contains less
|
|
1634 |
characters than n, then we return the length to the end of the last
|
|
1635 |
character. */
|
|
1636 |
||
1637 |
if (charset->mbmaxlen > 1) { |
|
1638 |
/* my_charpos() returns the byte length of the first n_chars
|
|
1639 |
characters, or a value bigger than the length of str, if
|
|
1640 |
there were not enough full characters in str.
|
|
1641 |
||
1642 |
Why does the code below work:
|
|
1643 |
Suppose that we are looking for n UTF-8 characters.
|
|
1644 |
||
1645 |
1) If the string is long enough, then the prefix contains at
|
|
1646 |
least n complete UTF-8 characters + maybe some extra
|
|
1647 |
characters + an incomplete UTF-8 character. No problem in
|
|
1648 |
this case. The function returns the pointer to the
|
|
1649 |
end of the nth character.
|
|
1650 |
||
1651 |
2) If the string is not long enough, then the string contains
|
|
1652 |
the complete value of a column, that is, only complete UTF-8
|
|
1653 |
characters, and we can store in the column prefix index the
|
|
1654 |
whole string. */
|
|
1655 |
||
1656 |
char_length = my_charpos(charset, str, |
|
1657 |
str + data_len, (int) n_chars); |
|
1658 |
if (char_length > data_len) { |
|
1659 |
char_length = data_len; |
|
1660 |
}
|
|
1661 |
} else { |
|
1662 |
if (data_len < prefix_len) { |
|
1663 |
char_length = data_len; |
|
1664 |
} else { |
|
1665 |
char_length = prefix_len; |
|
1666 |
}
|
|
1667 |
}
|
|
1668 |
||
1669 |
return(char_length); |
|
1
by kinoyasu
initial registration |
1670 |
}
|
1671 |
||
1672 |
ibool
|
|
1673 |
innobase_query_is_update(void) |
|
1674 |
{
|
|
45
by kinoyasu
messages are fixed a little |
1675 |
fprintf(stderr, "xtrabackup: innobase_query_is_update() is called\n"); |
11
by kinoyasu
fix tribials |
1676 |
return(0); |
1
by kinoyasu
initial registration |
1677 |
}
|
1678 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
1679 |
#ifdef INNODB_VERSION_SHORT
|
1680 |
ulint
|
|
1681 |
innobase_raw_format( |
|
1682 |
/*================*/
|
|
1683 |
const char* data, /*!< in: raw data */ |
|
1684 |
ulint data_len, /*!< in: raw data length |
|
1685 |
in bytes */
|
|
1686 |
ulint charset_coll, /*!< in: charset collation */ |
|
1687 |
char* buf, /*!< out: output buffer */ |
|
1688 |
ulint buf_size) /*!< in: output buffer size |
|
1689 |
in bytes */
|
|
1690 |
{
|
|
1691 |
fprintf(stderr, "xtrabackup: innobase_raw_format() is called\n"); |
|
1692 |
return(0); |
|
1693 |
}
|
|
1694 |
||
1695 |
ulong
|
|
1696 |
thd_lock_wait_timeout( |
|
1697 |
/*==================*/
|
|
1698 |
void* thd) /*!< in: thread handle (THD*), or NULL to query |
|
1699 |
the global innodb_lock_wait_timeout */
|
|
1700 |
{
|
|
1701 |
return(innobase_lock_wait_timeout); |
|
1702 |
}
|
|
1703 |
||
1704 |
ibool
|
|
1705 |
thd_supports_xa( |
|
1706 |
/*============*/
|
|
1707 |
void* thd) /*!< in: thread handle (THD*), or NULL to query |
|
1708 |
the global innodb_supports_xa */
|
|
1709 |
{
|
|
1710 |
return(FALSE); |
|
1711 |
}
|
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
1712 |
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
1713 |
ibool
|
1714 |
trx_is_strict( |
|
1715 |
/*==========*/
|
|
1716 |
trx_t* trx) /*!< in: transaction */ |
|
1717 |
{
|
|
1718 |
return(FALSE); |
|
1719 |
}
|
|
1720 |
||
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
1721 |
#ifdef XTRADB_BASED
|
1722 |
trx_t* |
|
1723 |
innobase_get_trx() |
|
1724 |
{
|
|
1725 |
return(NULL); |
|
1726 |
}
|
|
1727 |
||
1728 |
ibool
|
|
1729 |
innobase_get_slow_log() |
|
1730 |
{
|
|
1731 |
return(FALSE); |
|
1732 |
}
|
|
1733 |
#endif
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1734 |
#endif
|
1
by kinoyasu
initial registration |
1735 |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
1736 |
/***********************************************************************
|
1737 |
Computes page shift for a given page size. If the argument is not a power
|
|
1738 |
of 2, returns 0.*/
|
|
1739 |
UNIV_INLINE
|
|
1740 |
ulint
|
|
1741 |
get_page_size_shift(ulint page_size) |
|
1742 |
{
|
|
1743 |
ulint shift; |
|
1744 |
||
1745 |
if (page_size == 0) |
|
1746 |
return 0; |
|
1747 |
||
1748 |
for (shift = 0; !(page_size & 1UL); shift++) { |
|
1749 |
page_size >>= 1; |
|
1750 |
}
|
|
1751 |
return (page_size >> 1) ? 0 : shift; |
|
1752 |
}
|
|
1753 |
||
18
by kinoyasu
supporting MySQL 5.1 |
1754 |
my_bool
|
1
by kinoyasu
initial registration |
1755 |
innodb_init_param(void) |
1756 |
{
|
|
97.1.1
by Aleksandr Kuzminsky
fixes bug435634 |
1757 |
/* innobase_init */
|
1758 |
static char current_dir[3]; /* Set if using current lib */ |
|
1759 |
my_bool ret; |
|
99
by kinoyasu
refix bug 435634 |
1760 |
char *default_path; |
97.1.1
by Aleksandr Kuzminsky
fixes bug435634 |
1761 |
|
1
by kinoyasu
initial registration |
1762 |
/* === some variables from mysqld === */
|
94
by kinoyasu
Windows conscious experimental change |
1763 |
bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); |
1
by kinoyasu
initial registration |
1764 |
|
1765 |
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir)) |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
1766 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
1767 |
|
1768 |
/* dummy for initialize all_charsets[] */
|
|
1769 |
get_charset_name(0); |
|
1770 |
||
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
1771 |
#ifdef XTRADB_BASED
|
1772 |
srv_page_size = 0; |
|
1773 |
srv_page_size_shift = 0; |
|
1774 |
||
1775 |
if (innobase_page_size != (1 << 14)) { |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
1776 |
int n_shift = get_page_size_shift(innobase_page_size); |
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
1777 |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
1778 |
if (n_shift >= 12 && n_shift <= UNIV_PAGE_SIZE_SHIFT_MAX) { |
1779 |
fprintf(stderr, |
|
1780 |
"InnoDB: Warning: innodb_page_size has been "
|
|
1781 |
"changed from default value 16384.\n", |
|
1782 |
innobase_page_size); |
|
1783 |
srv_page_size_shift = n_shift; |
|
1784 |
srv_page_size = 1 << n_shift; |
|
1785 |
fprintf(stderr, |
|
1786 |
"InnoDB: The universal page size of the "
|
|
1787 |
"database is set to %lu.\n", srv_page_size); |
|
1788 |
} else { |
|
1789 |
fprintf(stderr, "InnoDB: Error: invalid value of " |
|
1790 |
"innobase_page_size: %lu", innobase_page_size); |
|
1791 |
exit(EXIT_FAILURE); |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
1792 |
}
|
1793 |
} else { |
|
1794 |
srv_page_size_shift = 14; |
|
1795 |
srv_page_size = (1 << srv_page_size_shift); |
|
1796 |
}
|
|
1797 |
||
1798 |
srv_fast_checksum = (ibool) innobase_fast_checksum; |
|
1799 |
#endif
|
|
1800 |
||
1
by kinoyasu
initial registration |
1801 |
/* Check that values don't overflow on 32-bit systems. */
|
1802 |
if (sizeof(ulint) == 4) { |
|
3
by kinoyasu
planned options are implemented |
1803 |
if (xtrabackup_use_memory > UINT_MAX32) { |
1804 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
1805 |
"xtrabackup: use-memory can't be over 4GB"
|
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
1806 |
" on 32-bit systems\n"); |
3
by kinoyasu
planned options are implemented |
1807 |
}
|
1808 |
||
1
by kinoyasu
initial registration |
1809 |
if (innobase_buffer_pool_size > UINT_MAX32) { |
1810 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
1811 |
"xtrabackup: innobase_buffer_pool_size can't be over 4GB"
|
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
1812 |
" on 32-bit systems\n"); |
1
by kinoyasu
initial registration |
1813 |
|
1814 |
goto error; |
|
1815 |
}
|
|
1816 |
||
1817 |
if (innobase_log_file_size > UINT_MAX32) { |
|
1818 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
1819 |
"xtrabackup: innobase_log_file_size can't be over 4GB"
|
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
1820 |
" on 32-bit systemsi\n"); |
1
by kinoyasu
initial registration |
1821 |
|
1822 |
goto error; |
|
1823 |
}
|
|
1824 |
}
|
|
1825 |
||
1826 |
os_innodb_umask = (ulint)0664; |
|
1827 |
||
1828 |
/* First calculate the default path for innodb_data_home_dir etc.,
|
|
1829 |
in case the user has not given any value.
|
|
1830 |
||
1831 |
Note that when using the embedded server, the datadirectory is not
|
|
1832 |
necessarily the current directory of this program. */
|
|
1833 |
||
1834 |
/* It's better to use current lib, to keep paths short */
|
|
1835 |
current_dir[0] = FN_CURLIB; |
|
1836 |
current_dir[1] = FN_LIBCHAR; |
|
1837 |
current_dir[2] = 0; |
|
1838 |
default_path = current_dir; |
|
1839 |
||
1840 |
ut_a(default_path); |
|
1841 |
||
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
1842 |
#if (MYSQL_VERSION_ID < 50500)
|
1
by kinoyasu
initial registration |
1843 |
// if (specialflag & SPECIAL_NO_PRIOR) {
|
1844 |
srv_set_thread_priorities = FALSE; |
|
1845 |
// } else {
|
|
1846 |
// srv_set_thread_priorities = TRUE;
|
|
1847 |
// srv_query_thread_priority = QUERY_PRIOR;
|
|
1848 |
// }
|
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
1849 |
#endif
|
1
by kinoyasu
initial registration |
1850 |
|
1851 |
/* Set InnoDB initialization parameters according to the values
|
|
1852 |
read from MySQL .cnf file */
|
|
1853 |
||
85
by kinoyasu
new option --stats to gather index stats |
1854 |
if (xtrabackup_backup || xtrabackup_stats) { |
45
by kinoyasu
messages are fixed a little |
1855 |
fprintf(stderr, "xtrabackup: Target instance is assumed as followings.\n"); |
1856 |
} else { |
|
1857 |
fprintf(stderr, "xtrabackup: Temporary instance for recovery is set as followings.\n"); |
|
1858 |
}
|
|
1859 |
||
1
by kinoyasu
initial registration |
1860 |
/*--------------- Data files -------------------------*/
|
1861 |
||
1862 |
/* The default dir for data files is the datadir of MySQL */
|
|
1863 |
||
85
by kinoyasu
new option --stats to gather index stats |
1864 |
srv_data_home = ((xtrabackup_backup || xtrabackup_stats) && innobase_data_home_dir |
34
by kinoyasu
more user-friendly incremental backup |
1865 |
? innobase_data_home_dir : default_path); |
45
by kinoyasu
messages are fixed a little |
1866 |
fprintf(stderr, "xtrabackup: innodb_data_home_dir = %s\n", srv_data_home); |
1
by kinoyasu
initial registration |
1867 |
|
1868 |
/* Set default InnoDB data file size to 10 MB and let it be
|
|
1869 |
auto-extending. Thus users can use InnoDB in >= 4.0 without having
|
|
1870 |
to specify any startup options. */
|
|
1871 |
||
1872 |
if (!innobase_data_file_path) { |
|
1873 |
innobase_data_file_path = (char*) "ibdata1:10M:autoextend"; |
|
1874 |
}
|
|
45
by kinoyasu
messages are fixed a little |
1875 |
fprintf(stderr, "xtrabackup: innodb_data_file_path = %s\n", |
1876 |
innobase_data_file_path); |
|
1
by kinoyasu
initial registration |
1877 |
|
1878 |
/* Since InnoDB edits the argument in the next call, we make another
|
|
1879 |
copy of it: */
|
|
1880 |
||
1881 |
internal_innobase_data_file_path = strdup(innobase_data_file_path); |
|
1882 |
||
18
by kinoyasu
supporting MySQL 5.1 |
1883 |
ret = (my_bool) srv_parse_data_file_paths_and_sizes( |
100
by kinoyasu
initial implementation for InnoDB Plugin |
1884 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
1885 |
internal_innobase_data_file_path, |
1886 |
&srv_data_file_names, |
|
1887 |
&srv_data_file_sizes, |
|
1888 |
&srv_data_file_is_raw_partition, |
|
1889 |
&srv_n_data_files, |
|
1890 |
&srv_auto_extend_last_data_file, |
|
1891 |
&srv_last_file_size_max); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1892 |
#else
|
1893 |
internal_innobase_data_file_path); |
|
1894 |
#endif
|
|
1
by kinoyasu
initial registration |
1895 |
if (ret == FALSE) { |
1896 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
1897 |
"xtrabackup: syntax error in innodb_data_file_path\n"); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
1898 |
mem_free_and_error: |
1
by kinoyasu
initial registration |
1899 |
free(internal_innobase_data_file_path); |
1900 |
goto error; |
|
1901 |
}
|
|
1902 |
||
35
by kinoyasu
fix somebugs: bug 339013, bug 352742 |
1903 |
if (xtrabackup_prepare) { |
1904 |
/* "--prepare" needs filenames only */
|
|
1905 |
ulint i; |
|
1906 |
||
1907 |
for (i=0; i < srv_n_data_files; i++) { |
|
1908 |
char *p; |
|
1909 |
||
1910 |
p = srv_data_file_names[i]; |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
1911 |
while ((p = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL) |
96
by kinoyasu
Windows conscious change more |
1912 |
{
|
35
by kinoyasu
fix somebugs: bug 339013, bug 352742 |
1913 |
p++; |
1914 |
srv_data_file_names[i] = p; |
|
1915 |
}
|
|
1916 |
}
|
|
1917 |
}
|
|
1918 |
||
136
by kinoyasu
port to Percona Server 5.1.47-11 |
1919 |
#ifdef XTRADB_BASED
|
1920 |
srv_doublewrite_file = innobase_doublewrite_file; |
|
1921 |
||
1922 |
srv_extra_undoslots = (ibool) innobase_extra_undoslots; |
|
1923 |
#endif
|
|
1924 |
||
1
by kinoyasu
initial registration |
1925 |
/* -------------- Log files ---------------------------*/
|
1926 |
||
1927 |
/* The default dir for log files is the datadir of MySQL */
|
|
1928 |
||
85
by kinoyasu
new option --stats to gather index stats |
1929 |
if (!((xtrabackup_backup || xtrabackup_stats) && innobase_log_group_home_dir)) { |
1
by kinoyasu
initial registration |
1930 |
innobase_log_group_home_dir = default_path; |
1931 |
}
|
|
34
by kinoyasu
more user-friendly incremental backup |
1932 |
if (xtrabackup_prepare && xtrabackup_incremental_dir) { |
1933 |
innobase_log_group_home_dir = xtrabackup_incremental_dir; |
|
1934 |
}
|
|
45
by kinoyasu
messages are fixed a little |
1935 |
fprintf(stderr, "xtrabackup: innodb_log_group_home_dir = %s\n", |
1936 |
innobase_log_group_home_dir); |
|
1
by kinoyasu
initial registration |
1937 |
|
1938 |
#ifdef UNIV_LOG_ARCHIVE
|
|
1939 |
/* Since innodb_log_arch_dir has no relevance under MySQL,
|
|
1940 |
starting from 4.0.6 we always set it the same as
|
|
1941 |
innodb_log_group_home_dir: */
|
|
1942 |
||
1943 |
innobase_log_arch_dir = innobase_log_group_home_dir; |
|
1944 |
||
1945 |
srv_arch_dir = innobase_log_arch_dir; |
|
1946 |
#endif /* UNIG_LOG_ARCHIVE */ |
|
1947 |
||
18
by kinoyasu
supporting MySQL 5.1 |
1948 |
ret = (my_bool) |
100
by kinoyasu
initial implementation for InnoDB Plugin |
1949 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
1950 |
srv_parse_log_group_home_dirs(innobase_log_group_home_dir, |
1951 |
&srv_log_group_home_dirs); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1952 |
#else
|
1953 |
srv_parse_log_group_home_dirs(innobase_log_group_home_dir); |
|
1954 |
#endif
|
|
1
by kinoyasu
initial registration |
1955 |
|
1956 |
if (ret == FALSE || innobase_mirrored_log_groups != 1) { |
|
45
by kinoyasu
messages are fixed a little |
1957 |
fprintf(stderr, "xtrabackup: syntax error in innodb_log_group_home_dir, or a " |
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
1958 |
"wrong number of mirrored log groups\n"); |
1
by kinoyasu
initial registration |
1959 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1960 |
goto mem_free_and_error; |
1
by kinoyasu
initial registration |
1961 |
}
|
1962 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
1963 |
#ifdef INNODB_VERSION_SHORT
|
1964 |
srv_adaptive_flushing = FALSE; |
|
1965 |
srv_use_sys_malloc = TRUE; |
|
1966 |
srv_file_format = 1; /* Barracuda */ |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
1967 |
#if (MYSQL_VERSION_ID < 50500)
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1968 |
srv_check_file_format_at_startup = DICT_TF_FORMAT_51; /* on */ |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
1969 |
#else
|
1970 |
srv_max_file_format_at_startup = DICT_TF_FORMAT_51; /* on */ |
|
1971 |
#endif
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
1972 |
#endif
|
1
by kinoyasu
initial registration |
1973 |
/* --------------------------------------------------*/
|
1974 |
||
1975 |
srv_file_flush_method_str = innobase_unix_file_flush_method; |
|
1976 |
||
1977 |
srv_n_log_groups = (ulint) innobase_mirrored_log_groups; |
|
1978 |
srv_n_log_files = (ulint) innobase_log_files_in_group; |
|
1979 |
srv_log_file_size = (ulint) innobase_log_file_size; |
|
45
by kinoyasu
messages are fixed a little |
1980 |
fprintf(stderr, "xtrabackup: innodb_log_files_in_group = %ld\n", |
1981 |
srv_n_log_files); |
|
1982 |
fprintf(stderr, "xtrabackup: innodb_log_file_size = %ld\n", |
|
1983 |
srv_log_file_size); |
|
1
by kinoyasu
initial registration |
1984 |
|
1985 |
#ifdef UNIV_LOG_ARCHIVE
|
|
1986 |
srv_log_archive_on = (ulint) innobase_log_archive; |
|
1987 |
#endif /* UNIV_LOG_ARCHIVE */ |
|
1988 |
srv_log_buffer_size = (ulint) innobase_log_buffer_size; |
|
1989 |
||
1990 |
/* We set srv_pool_size here in units of 1 kB. InnoDB internally
|
|
1991 |
changes the value so that it becomes the number of database pages. */
|
|
1992 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
1993 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
1994 |
if (innobase_buffer_pool_awe_mem_mb == 0) { |
1995 |
/* Careful here: we first convert the signed long int to ulint
|
|
1996 |
and only after that divide */
|
|
1997 |
||
3
by kinoyasu
planned options are implemented |
1998 |
//srv_pool_size = ((ulint) innobase_buffer_pool_size) / 1024;
|
1999 |
srv_pool_size = ((ulint) xtrabackup_use_memory) / 1024; |
|
1
by kinoyasu
initial registration |
2000 |
} else { |
2001 |
srv_use_awe = TRUE; |
|
2002 |
srv_pool_size = (ulint) |
|
2003 |
(1024 * innobase_buffer_pool_awe_mem_mb); |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
2004 |
//srv_awe_window_size = (ulint) innobase_buffer_pool_size;
|
2005 |
srv_awe_window_size = (ulint) xtrabackup_use_memory; |
|
1
by kinoyasu
initial registration |
2006 |
|
2007 |
/* Note that what the user specified as
|
|
2008 |
innodb_buffer_pool_size is actually the AWE memory window
|
|
2009 |
size in this case, and the real buffer pool size is
|
|
2010 |
determined by .._awe_mem_mb. */
|
|
2011 |
}
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2012 |
#else
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
2013 |
//srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
|
2014 |
srv_buf_pool_size = (ulint) xtrabackup_use_memory; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2015 |
#endif
|
1
by kinoyasu
initial registration |
2016 |
|
2017 |
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size; |
|
2018 |
||
2019 |
srv_n_file_io_threads = (ulint) innobase_file_io_threads; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2020 |
#ifdef INNODB_VERSION_SHORT
|
2021 |
srv_n_read_io_threads = (ulint) innobase_read_io_threads; |
|
2022 |
srv_n_write_io_threads = (ulint) innobase_write_io_threads; |
|
2023 |
#endif
|
|
1
by kinoyasu
initial registration |
2024 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2025 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
2026 |
srv_lock_wait_timeout = (ulint) innobase_lock_wait_timeout; |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2027 |
#endif
|
1
by kinoyasu
initial registration |
2028 |
srv_force_recovery = (ulint) innobase_force_recovery; |
2029 |
||
2030 |
srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite; |
|
2031 |
srv_use_checksums = (ibool) innobase_use_checksums; |
|
2032 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
2033 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
2034 |
srv_use_adaptive_hash_indexes = (ibool) innobase_adaptive_hash_index; |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2035 |
#else
|
2036 |
btr_search_enabled = (ibool) innobase_adaptive_hash_index; |
|
2037 |
#endif
|
|
1
by kinoyasu
initial registration |
2038 |
|
2039 |
os_use_large_pages = (ibool) innobase_use_large_pages; |
|
2040 |
os_large_page_size = (ulint) innobase_large_page_size; |
|
2041 |
||
2042 |
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; |
|
2043 |
||
2044 |
srv_file_per_table = (ibool) innobase_file_per_table; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2045 |
|
1
by kinoyasu
initial registration |
2046 |
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; |
2047 |
||
2048 |
srv_max_n_open_files = (ulint) innobase_open_files; |
|
2049 |
srv_innodb_status = (ibool) innobase_create_status_file; |
|
2050 |
||
2051 |
srv_print_verbose_log = 1; |
|
2052 |
||
2053 |
/* Store the default charset-collation number of this MySQL
|
|
2054 |
installation */
|
|
2055 |
||
2056 |
/* We cannot treat characterset here for now!! */
|
|
2057 |
data_mysql_default_charset_coll = (ulint)default_charset_info->number; |
|
2058 |
||
2059 |
ut_a(DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL == |
|
2060 |
my_charset_latin1.number); |
|
2061 |
ut_a(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number); |
|
2062 |
||
2063 |
/* Store the latin1_swedish_ci character ordering table to InnoDB. For
|
|
2064 |
non-latin1_swedish_ci charsets we use the MySQL comparison functions,
|
|
2065 |
and consequently we do not need to know the ordering internally in
|
|
2066 |
InnoDB. */
|
|
2067 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
2068 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
2069 |
ut_a(0 == strcmp((char*)my_charset_latin1.name, |
2070 |
(char*)"latin1_swedish_ci")); |
|
2071 |
memcpy(srv_latin1_ordering, my_charset_latin1.sort_order, 256); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2072 |
#else
|
2073 |
ut_a(0 == strcmp(my_charset_latin1.name, "latin1_swedish_ci")); |
|
2074 |
srv_latin1_ordering = my_charset_latin1.sort_order; |
|
2075 |
||
2076 |
//innobase_commit_concurrency_init_default();
|
|
2077 |
#endif
|
|
1
by kinoyasu
initial registration |
2078 |
|
2079 |
/* Since we in this module access directly the fields of a trx
|
|
2080 |
struct, and due to different headers and flags it might happen that
|
|
2081 |
mutex_t has a different size in this module and in InnoDB
|
|
2082 |
modules, we check at run time that the size is the same in
|
|
2083 |
these compilation modules. */
|
|
2084 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
2085 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
2086 |
srv_sizeof_trx_t_in_ha_innodb_cc = sizeof(trx_t); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2087 |
#endif
|
1
by kinoyasu
initial registration |
2088 |
|
2089 |
return(FALSE); |
|
2090 |
||
2091 |
error: |
|
45
by kinoyasu
messages are fixed a little |
2092 |
fprintf(stderr, "xtrabackup: innodb_init_param(): Error occured.\n"); |
1
by kinoyasu
initial registration |
2093 |
return(TRUE); |
2094 |
}
|
|
2095 |
||
18
by kinoyasu
supporting MySQL 5.1 |
2096 |
my_bool
|
1
by kinoyasu
initial registration |
2097 |
innodb_init(void) |
2098 |
{
|
|
2099 |
int err; |
|
2100 |
||
2101 |
err = innobase_start_or_create_for_mysql(); |
|
2102 |
||
2103 |
if (err != DB_SUCCESS) { |
|
2104 |
free(internal_innobase_data_file_path); |
|
2105 |
goto error; |
|
2106 |
}
|
|
2107 |
||
2108 |
/* They may not be needed for now */
|
|
2109 |
// (void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0,
|
|
2110 |
// (hash_get_key) innobase_get_key, 0, 0);
|
|
2111 |
// pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
|
|
2112 |
// pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
|
|
2113 |
// pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
|
|
2114 |
// pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
|
|
2115 |
// pthread_cond_init(&commit_cond, NULL);
|
|
2116 |
||
2117 |
innodb_inited= 1; |
|
2118 |
||
2119 |
return(FALSE); |
|
2120 |
||
2121 |
error: |
|
45
by kinoyasu
messages are fixed a little |
2122 |
fprintf(stderr, "xtrabackup: innodb_init(): Error occured.\n"); |
1
by kinoyasu
initial registration |
2123 |
return(TRUE); |
2124 |
}
|
|
2125 |
||
18
by kinoyasu
supporting MySQL 5.1 |
2126 |
my_bool
|
1
by kinoyasu
initial registration |
2127 |
innodb_end(void) |
2128 |
{
|
|
2129 |
srv_fast_shutdown = (ulint) innobase_fast_shutdown; |
|
2130 |
innodb_inited = 0; |
|
47
by kinoyasu
show innodb_fast_shutdown at shutdown for checking |
2131 |
|
2132 |
fprintf(stderr, "xtrabackup: starting shutdown with innodb_fast_shutdown = %lu\n", |
|
2133 |
srv_fast_shutdown); |
|
2134 |
||
1
by kinoyasu
initial registration |
2135 |
if (innobase_shutdown_for_mysql() != DB_SUCCESS) { |
2136 |
goto error; |
|
2137 |
}
|
|
2138 |
free(internal_innobase_data_file_path); |
|
2139 |
||
2140 |
/* They may not be needed for now */
|
|
2141 |
// hash_free(&innobase_open_tables);
|
|
2142 |
// pthread_mutex_destroy(&innobase_share_mutex);
|
|
2143 |
// pthread_mutex_destroy(&prepare_commit_mutex);
|
|
2144 |
// pthread_mutex_destroy(&commit_threads_m);
|
|
2145 |
// pthread_mutex_destroy(&commit_cond_m);
|
|
2146 |
// pthread_cond_destroy(&commit_cond);
|
|
2147 |
||
2148 |
return(FALSE); |
|
2149 |
||
2150 |
error: |
|
45
by kinoyasu
messages are fixed a little |
2151 |
fprintf(stderr, "xtrabackup: innodb_end(): Error occured.\n"); |
1
by kinoyasu
initial registration |
2152 |
return(TRUE); |
2153 |
}
|
|
2154 |
||
34
by kinoyasu
more user-friendly incremental backup |
2155 |
/* ================= common ================= */
|
2156 |
my_bool
|
|
2157 |
xtrabackup_read_metadata(char *filename) |
|
2158 |
{
|
|
2159 |
FILE *fp; |
|
2160 |
||
2161 |
fp = fopen(filename,"r"); |
|
2162 |
if(!fp) { |
|
46
by kinoyasu
make restricted not to overwrite backup |
2163 |
fprintf(stderr, "xtrabackup: Error: cannot open %s\n", filename); |
34
by kinoyasu
more user-friendly incremental backup |
2164 |
return(TRUE); |
2165 |
}
|
|
2166 |
||
2167 |
if (fscanf(fp, "backup_type = %29s\n", metadata_type) |
|
2168 |
!= 1) |
|
2169 |
return(TRUE); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2170 |
#ifndef INNODB_VERSION_SHORT
|
34
by kinoyasu
more user-friendly incremental backup |
2171 |
if (fscanf(fp, "from_lsn = %lu:%lu\n", &metadata_from_lsn.high, &metadata_from_lsn.low) |
2172 |
!= 2) |
|
2173 |
return(TRUE); |
|
2174 |
if (fscanf(fp, "to_lsn = %lu:%lu\n", &metadata_to_lsn.high, &metadata_to_lsn.low) |
|
2175 |
!= 2) |
|
2176 |
return(TRUE); |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
2177 |
if (fscanf(fp, "last_lsn = %lu:%lu\n", &metadata_last_lsn.high, &metadata_last_lsn.low) |
192
by kinoyasu
adjust rev.191 for backward compatibility |
2178 |
!= 2) { |
2179 |
metadata_last_lsn.high = metadata_last_lsn.low = 0; |
|
2180 |
}
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2181 |
#else
|
2182 |
if (fscanf(fp, "from_lsn = %llu\n", &metadata_from_lsn) |
|
2183 |
!= 1) |
|
2184 |
return(TRUE); |
|
2185 |
if (fscanf(fp, "to_lsn = %llu\n", &metadata_to_lsn) |
|
2186 |
!= 1) |
|
2187 |
return(TRUE); |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
2188 |
if (fscanf(fp, "last_lsn = %llu\n", &metadata_last_lsn) |
192
by kinoyasu
adjust rev.191 for backward compatibility |
2189 |
!= 1) { |
2190 |
metadata_last_lsn = 0; |
|
2191 |
}
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2192 |
#endif
|
34
by kinoyasu
more user-friendly incremental backup |
2193 |
|
2194 |
fclose(fp); |
|
2195 |
||
2196 |
return(FALSE); |
|
2197 |
}
|
|
2198 |
||
2199 |
my_bool
|
|
2200 |
xtrabackup_write_metadata(char *filename) |
|
2201 |
{
|
|
2202 |
FILE *fp; |
|
2203 |
||
2204 |
fp = fopen(filename,"w"); |
|
2205 |
if(!fp) { |
|
46
by kinoyasu
make restricted not to overwrite backup |
2206 |
fprintf(stderr, "xtrabackup: Error: cannot open %s\n", filename); |
34
by kinoyasu
more user-friendly incremental backup |
2207 |
return(TRUE); |
2208 |
}
|
|
2209 |
||
2210 |
if (fprintf(fp, "backup_type = %s\n", metadata_type) |
|
2211 |
< 0) |
|
2212 |
return(TRUE); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2213 |
#ifndef INNODB_VERSION_SHORT
|
34
by kinoyasu
more user-friendly incremental backup |
2214 |
if (fprintf(fp, "from_lsn = %lu:%lu\n", metadata_from_lsn.high, metadata_from_lsn.low) |
2215 |
< 0) |
|
2216 |
return(TRUE); |
|
2217 |
if (fprintf(fp, "to_lsn = %lu:%lu\n", metadata_to_lsn.high, metadata_to_lsn.low) |
|
2218 |
< 0) |
|
2219 |
return(TRUE); |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
2220 |
if (fprintf(fp, "last_lsn = %lu:%lu\n", metadata_last_lsn.high, metadata_last_lsn.low) |
2221 |
< 0) |
|
2222 |
return(TRUE); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2223 |
#else
|
2224 |
if (fprintf(fp, "from_lsn = %llu\n", metadata_from_lsn) |
|
2225 |
< 0) |
|
2226 |
return(TRUE); |
|
2227 |
if (fprintf(fp, "to_lsn = %llu\n", metadata_to_lsn) |
|
2228 |
< 0) |
|
2229 |
return(TRUE); |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
2230 |
if (fprintf(fp, "last_lsn = %llu\n", metadata_last_lsn) |
2231 |
< 0) |
|
2232 |
return(TRUE); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2233 |
#endif
|
34
by kinoyasu
more user-friendly incremental backup |
2234 |
|
2235 |
fclose(fp); |
|
2236 |
||
2237 |
return(FALSE); |
|
2238 |
}
|
|
1
by kinoyasu
initial registration |
2239 |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
2240 |
/***********************************************************************
|
2241 |
Read meta info for an incremental delta.
|
|
2242 |
@return TRUE on success, FALSE on failure. */
|
|
2243 |
my_bool
|
|
2244 |
xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info) |
|
2245 |
{
|
|
2246 |
FILE *fp; |
|
2247 |
||
2248 |
memset(info, 0, sizeof(xb_delta_info_t)); |
|
2249 |
||
2250 |
fp = fopen(filepath, "r"); |
|
2251 |
if (!fp) { |
|
2252 |
/* Meta files for incremental deltas are optional */
|
|
2253 |
return(TRUE); |
|
2254 |
}
|
|
2255 |
||
2256 |
if (fscanf(fp, "page_size = %lu\n", &info->page_size) != 1) |
|
2257 |
return(FALSE); |
|
2258 |
||
2259 |
fclose(fp); |
|
2260 |
||
2261 |
return(TRUE); |
|
2262 |
}
|
|
2263 |
||
2264 |
/***********************************************************************
|
|
2265 |
Write meta info for an incremental delta.
|
|
2266 |
@return TRUE on success, FALSE on failure. */
|
|
2267 |
my_bool
|
|
2268 |
xb_write_delta_metadata(const char *filepath, const xb_delta_info_t *info) |
|
2269 |
{
|
|
2270 |
FILE *fp; |
|
2271 |
||
2272 |
fp = fopen(filepath, "w"); |
|
2273 |
if (!fp) { |
|
2274 |
fprintf(stderr, "xtrabackup: Error: cannot open %s\n", filepath); |
|
2275 |
return(FALSE); |
|
2276 |
}
|
|
2277 |
||
2278 |
if (fprintf(fp, "page_size = %lu\n", info->page_size) < 0) |
|
2279 |
return(FALSE); |
|
2280 |
||
2281 |
fclose(fp); |
|
2282 |
||
2283 |
return(TRUE); |
|
2284 |
}
|
|
2285 |
||
1
by kinoyasu
initial registration |
2286 |
/* ================= backup ================= */
|
3
by kinoyasu
planned options are implemented |
2287 |
void
|
2288 |
xtrabackup_io_throttling(void) |
|
2289 |
{
|
|
2290 |
if (xtrabackup_throttle && (io_ticket--) < 0) { |
|
2291 |
os_event_reset(wait_throttle); |
|
2292 |
os_event_wait(wait_throttle); |
|
2293 |
}
|
|
2294 |
}
|
|
2295 |
||
1
by kinoyasu
initial registration |
2296 |
|
2297 |
/* TODO: We may tune the behavior (e.g. by fil_aio)*/
|
|
2298 |
#define COPY_CHUNK 64
|
|
2299 |
||
18
by kinoyasu
supporting MySQL 5.1 |
2300 |
my_bool
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2301 |
xtrabackup_copy_datafile(fil_node_t* node, uint thread_n) |
1
by kinoyasu
initial registration |
2302 |
{
|
2303 |
os_file_t src_file = -1; |
|
2304 |
os_file_t dst_file = -1; |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
2305 |
char dst_path[FN_REFLEN]; |
2306 |
char meta_path[FN_REFLEN]; |
|
1
by kinoyasu
initial registration |
2307 |
ibool success; |
2308 |
byte* page; |
|
2309 |
byte* buf2 = NULL; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2310 |
LSN64 flush_lsn; |
2311 |
IB_INT64 file_size; |
|
2312 |
IB_INT64 offset; |
|
33
by kinoyasu
primitive implementation of incremental backup |
2313 |
ulint page_in_buffer; |
2314 |
ulint incremental_buffers = 0; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2315 |
ulint page_size; |
2316 |
ulint page_size_shift; |
|
2317 |
#ifdef INNODB_VERSION_SHORT
|
|
2318 |
ulint zip_size; |
|
2319 |
#endif
|
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
2320 |
xb_delta_info_t info; |
1
by kinoyasu
initial registration |
2321 |
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
2322 |
#ifdef XTRADB_BASED
|
2323 |
if (xtrabackup_tables && (!trx_sys_sys_space(node->space->id))) |
|
2324 |
#else
|
|
2325 |
if (xtrabackup_tables && (node->space->id != 0)) |
|
2326 |
#endif
|
|
2327 |
{ /* must backup id==0 */ |
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2328 |
char *p; |
2329 |
int p_len, regres; |
|
23
by kinoyasu
fix REGEXP behavior (including database name) |
2330 |
char *next, *prev; |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2331 |
char tmp; |
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
2332 |
int i; |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2333 |
|
2334 |
p = node->name; |
|
23
by kinoyasu
fix REGEXP behavior (including database name) |
2335 |
prev = NULL; |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
2336 |
while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL) |
96
by kinoyasu
Windows conscious change more |
2337 |
{
|
23
by kinoyasu
fix REGEXP behavior (including database name) |
2338 |
prev = p; |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2339 |
p = next + 1; |
2340 |
}
|
|
2341 |
p_len = strlen(p) - strlen(".ibd"); |
|
2342 |
||
2343 |
if (p_len < 1) { |
|
2344 |
/* unknown situation: skip filtering */
|
|
2345 |
goto skip_filter; |
|
2346 |
}
|
|
2347 |
||
23
by kinoyasu
fix REGEXP behavior (including database name) |
2348 |
/* TODO: Fix this lazy implementation... */
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2349 |
tmp = p[p_len]; |
2350 |
p[p_len] = 0; |
|
23
by kinoyasu
fix REGEXP behavior (including database name) |
2351 |
*(p - 1) = '.'; |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2352 |
|
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
2353 |
for (i = 0; i < tables_regex_num; i++) { |
2354 |
regres = regexec(&tables_regex[i], prev, 1, tables_regmatch, 0); |
|
2355 |
if (regres != REG_NOMATCH) |
|
2356 |
break; |
|
2357 |
}
|
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2358 |
|
2359 |
p[p_len] = tmp; |
|
96
by kinoyasu
Windows conscious change more |
2360 |
*(p - 1) = SRV_PATH_SEPARATOR; |
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2361 |
|
2362 |
if ( regres == REG_NOMATCH ) { |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2363 |
printf("[%02u] Copying %s is skipped.\n", |
2364 |
thread_n, node->name); |
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2365 |
return(FALSE); |
2366 |
}
|
|
2367 |
}
|
|
158
by kinoyasu
new option --tables_file is added |
2368 |
|
2369 |
#ifdef XTRADB_BASED
|
|
2370 |
if (xtrabackup_tables_file && (!trx_sys_sys_space(node->space->id))) |
|
2371 |
#else
|
|
2372 |
if (xtrabackup_tables_file && (node->space->id != 0)) |
|
2373 |
#endif
|
|
2374 |
{ /* must backup id==0 */ |
|
2375 |
xtrabackup_tables_t* table; |
|
2376 |
char *p; |
|
2377 |
int p_len, regres; |
|
2378 |
char *next, *prev; |
|
2379 |
char tmp; |
|
2380 |
int i; |
|
2381 |
||
2382 |
p = node->name; |
|
2383 |
prev = NULL; |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
2384 |
while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL) |
158
by kinoyasu
new option --tables_file is added |
2385 |
{
|
2386 |
prev = p; |
|
2387 |
p = next + 1; |
|
2388 |
}
|
|
2389 |
p_len = strlen(p) - strlen(".ibd"); |
|
2390 |
||
2391 |
if (p_len < 1) { |
|
2392 |
/* unknown situation: skip filtering */
|
|
2393 |
goto skip_filter; |
|
2394 |
}
|
|
2395 |
||
2396 |
/* TODO: Fix this lazy implementation... */
|
|
2397 |
tmp = p[p_len]; |
|
2398 |
p[p_len] = 0; |
|
2399 |
||
2400 |
HASH_SEARCH(name_hash, tables_hash, ut_fold_string(prev), |
|
159
by kinoyasu
recover 5.1 builtin base version support, and remove unused or obsolete patches |
2401 |
#ifdef INNODB_VERSION_SHORT
|
2402 |
xtrabackup_tables_t*, |
|
2403 |
#endif
|
|
2404 |
table, |
|
2405 |
#ifdef INNODB_VERSION_SHORT
|
|
2406 |
ut_ad(table->name), |
|
2407 |
#endif
|
|
158
by kinoyasu
new option --tables_file is added |
2408 |
!strcmp(table->name, prev)); |
2409 |
||
2410 |
p[p_len] = tmp; |
|
2411 |
||
2412 |
if (!table) { |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2413 |
printf("[%02u] Copying %s is skipped.\n", |
2414 |
thread_n, node->name); |
|
158
by kinoyasu
new option --tables_file is added |
2415 |
return(FALSE); |
2416 |
}
|
|
2417 |
}
|
|
2418 |
||
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2419 |
skip_filter: |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2420 |
#ifndef INNODB_VERSION_SHORT
|
2421 |
page_size = UNIV_PAGE_SIZE; |
|
2422 |
page_size_shift = UNIV_PAGE_SIZE_SHIFT; |
|
2423 |
#else
|
|
2424 |
zip_size = fil_space_get_zip_size(node->space->id); |
|
215
by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already |
2425 |
if (zip_size == ULINT_UNDEFINED) { |
2426 |
fprintf(stderr, "[%02u] xtrabackup: Warning: " |
|
2427 |
"Failed to determine page size for %s.\n" |
|
2428 |
"[%02u] xtrabackup: Warning: We assume the table was "
|
|
2429 |
"dropped during xtrabackup execution and ignore the "
|
|
2430 |
"file.\n", thread_n, node->name, thread_n); |
|
2431 |
goto skip; |
|
2432 |
} else if (zip_size) { |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2433 |
page_size = zip_size; |
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
2434 |
page_size_shift = get_page_size_shift(page_size); |
2435 |
fprintf(stderr, "[%02u] %s is compressed with page size = " |
|
2436 |
"%lu bytes\n", thread_n, node->name, page_size); |
|
2437 |
if (page_size_shift < 10 || page_size_shift > 14) { |
|
2438 |
fprintf(stderr, "[%02u] xtrabackup: Error: Invalid " |
|
215
by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already |
2439 |
"page size.\n", thread_n); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2440 |
ut_error; |
2441 |
}
|
|
2442 |
} else { |
|
2443 |
page_size = UNIV_PAGE_SIZE; |
|
2444 |
page_size_shift = UNIV_PAGE_SIZE_SHIFT; |
|
2445 |
}
|
|
2446 |
#endif
|
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
2447 |
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
2448 |
#ifdef XTRADB_BASED
|
2449 |
if (trx_sys_sys_space(node->space->id)) |
|
2450 |
#else
|
|
2451 |
if (node->space->id == 0) |
|
2452 |
#endif
|
|
2453 |
{
|
|
26
by kinoyasu
fix bug 346197 |
2454 |
char *next, *p; |
2455 |
/* system datafile "/fullpath/datafilename.ibd" or "./datafilename.ibd" */
|
|
2456 |
p = node->name; |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
2457 |
while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL) |
96
by kinoyasu
Windows conscious change more |
2458 |
{
|
26
by kinoyasu
fix bug 346197 |
2459 |
p = next + 1; |
2460 |
}
|
|
2461 |
sprintf(dst_path, "%s/%s", xtrabackup_target_dir, p); |
|
2462 |
} else { |
|
2463 |
/* file per table style "./database/table.ibd" */
|
|
96
by kinoyasu
Windows conscious change more |
2464 |
sprintf(dst_path, "%s%s", xtrabackup_target_dir, strstr(node->name, SRV_PATH_SEPARATOR_STR)); |
26
by kinoyasu
fix bug 346197 |
2465 |
}
|
1
by kinoyasu
initial registration |
2466 |
|
33
by kinoyasu
primitive implementation of incremental backup |
2467 |
if (xtrabackup_incremental) { |
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
2468 |
snprintf(meta_path, sizeof(meta_path), |
2469 |
"%s%s", dst_path, XB_DELTA_INFO_SUFFIX); |
|
33
by kinoyasu
primitive implementation of incremental backup |
2470 |
strcat(dst_path, ".delta"); |
2471 |
||
2472 |
/* clear buffer */
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2473 |
bzero(incremental_buffer, (page_size/4) * page_size); |
33
by kinoyasu
primitive implementation of incremental backup |
2474 |
page_in_buffer = 0; |
2475 |
mach_write_to_4(incremental_buffer, 0x78747261UL);/*"xtra"*/ |
|
2476 |
page_in_buffer++; |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
2477 |
|
2478 |
info.page_size = page_size; |
|
33
by kinoyasu
primitive implementation of incremental backup |
2479 |
}
|
2480 |
||
1
by kinoyasu
initial registration |
2481 |
/* open src_file*/
|
2482 |
if (!node->open) { |
|
2483 |
src_file = os_file_create_simple_no_error_handling( |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
2484 |
#if (MYSQL_VERSION_ID > 50500)
|
2485 |
0 /* dummy of innodb_file_data_key */, |
|
2486 |
#endif
|
|
1
by kinoyasu
initial registration |
2487 |
node->name, OS_FILE_OPEN, |
2488 |
OS_FILE_READ_ONLY, &success); |
|
2489 |
if (!success) { |
|
2490 |
/* The following call prints an error message */
|
|
2491 |
os_file_get_last_error(TRUE); |
|
2492 |
||
2493 |
fprintf(stderr, |
|
215
by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already |
2494 |
"[%02u] xtrabackup: Warning: cannot open %s\n" |
2495 |
"[%02u] xtrabackup: Warning: We assume the "
|
|
2496 |
"table was dropped during xtrabackup execution "
|
|
2497 |
"and ignore the file.\n", |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2498 |
thread_n, node->name, thread_n); |
215
by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already |
2499 |
goto skip; |
1
by kinoyasu
initial registration |
2500 |
}
|
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
2501 |
|
2502 |
if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { |
|
2503 |
os_file_set_nocache(src_file, node->name, "OPEN"); |
|
2504 |
}
|
|
1
by kinoyasu
initial registration |
2505 |
} else { |
2506 |
src_file = node->handle; |
|
2507 |
}
|
|
2508 |
||
52
by kinoyasu
add to use posix_fadvise() if possible |
2509 |
#ifdef USE_POSIX_FADVISE
|
2510 |
posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL); |
|
2511 |
posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED); |
|
2512 |
#endif
|
|
2513 |
||
1
by kinoyasu
initial registration |
2514 |
/* open dst_file */
|
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
2515 |
/* os_file_create reads srv_unix_file_flush_method */
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
2516 |
dst_file = os_file_create( |
2517 |
#if (MYSQL_VERSION_ID > 50500)
|
|
2518 |
0 /* dummy of innodb_file_data_key */, |
|
2519 |
#endif
|
|
2520 |
dst_path, OS_FILE_CREATE, |
|
2521 |
OS_FILE_NORMAL, OS_DATA_FILE, &success); |
|
1
by kinoyasu
initial registration |
2522 |
if (!success) { |
2523 |
/* The following call prints an error message */
|
|
2524 |
os_file_get_last_error(TRUE); |
|
2525 |
||
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2526 |
fprintf(stderr,"[%02u] xtrabackup: error: " |
2527 |
"cannot open %s\n", thread_n, dst_path); |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
2528 |
goto error; |
1
by kinoyasu
initial registration |
2529 |
}
|
2530 |
||
52
by kinoyasu
add to use posix_fadvise() if possible |
2531 |
#ifdef USE_POSIX_FADVISE
|
2532 |
posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED); |
|
2533 |
#endif
|
|
2534 |
||
1
by kinoyasu
initial registration |
2535 |
/* copy : TODO: tune later */
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2536 |
printf("[%02u] Copying %s \n to %s\n", thread_n, |
2537 |
node->name, dst_path); |
|
1
by kinoyasu
initial registration |
2538 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2539 |
buf2 = ut_malloc(COPY_CHUNK * page_size + UNIV_PAGE_SIZE); |
1
by kinoyasu
initial registration |
2540 |
page = ut_align(buf2, UNIV_PAGE_SIZE); |
2541 |
||
2542 |
success = os_file_read(src_file, page, 0, 0, UNIV_PAGE_SIZE); |
|
2543 |
if (!success) { |
|
2544 |
goto error; |
|
2545 |
}
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2546 |
flush_lsn = MACH_READ_64(page + FIL_PAGE_FILE_FLUSH_LSN); |
1
by kinoyasu
initial registration |
2547 |
/* check current flush lsn newer than checkpoint@start */
|
2548 |
// if (ut_dulint_cmp(backup_start_checkpoint, flush_lsn) >= 0) {
|
|
2549 |
// goto error;
|
|
2550 |
// }
|
|
2551 |
||
2552 |
file_size = os_file_get_size_as_iblonglong(src_file); |
|
2553 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
2554 |
for (offset = 0; offset < file_size; offset += COPY_CHUNK * page_size) { |
1
by kinoyasu
initial registration |
2555 |
ulint chunk; |
63
by kinoyasu
data page corruption check is added to local backup mode |
2556 |
ulint chunk_offset; |
2557 |
ulint retry_count = 10; |
|
1
by kinoyasu
initial registration |
2558 |
copy_loop: |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2559 |
if (file_size - offset > COPY_CHUNK * page_size) { |
2560 |
chunk = COPY_CHUNK * page_size; |
|
1
by kinoyasu
initial registration |
2561 |
} else { |
2562 |
chunk = (ulint)(file_size - offset); |
|
2563 |
}
|
|
2564 |
||
63
by kinoyasu
data page corruption check is added to local backup mode |
2565 |
read_retry: |
3
by kinoyasu
planned options are implemented |
2566 |
xtrabackup_io_throttling(); |
2567 |
||
1
by kinoyasu
initial registration |
2568 |
success = os_file_read(src_file, page, |
2569 |
(ulint)(offset & 0xFFFFFFFFUL), |
|
2570 |
(ulint)(offset >> 32), chunk); |
|
2571 |
if (!success) { |
|
2572 |
goto error; |
|
2573 |
}
|
|
2574 |
||
63
by kinoyasu
data page corruption check is added to local backup mode |
2575 |
/* check corruption and retry */
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2576 |
for (chunk_offset = 0; chunk_offset < chunk; chunk_offset += page_size) { |
2577 |
#ifndef INNODB_VERSION_SHORT
|
|
2578 |
if (buf_page_is_corrupted(page + chunk_offset)) |
|
2579 |
#else
|
|
2580 |
if (buf_page_is_corrupted(page + chunk_offset, zip_size)) |
|
2581 |
#endif
|
|
2582 |
{
|
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
2583 |
if ( |
2584 |
#ifdef XTRADB_BASED
|
|
2585 |
trx_sys_sys_space(node->space->id) |
|
2586 |
#else
|
|
2587 |
node->space->id == 0 |
|
2588 |
#endif
|
|
121
by kinoyasu
fix bug498660 |
2589 |
&& ((offset + (IB_INT64)chunk_offset) >> page_size_shift) |
2590 |
>= FSP_EXTENT_SIZE |
|
2591 |
&& ((offset + (IB_INT64)chunk_offset) >> page_size_shift) |
|
2592 |
< FSP_EXTENT_SIZE * 3) { |
|
2593 |
/* double write buffer may have old data in the end
|
|
2594 |
or it may contain the other format page like COMPRESSED.
|
|
2595 |
So, we can pass the check of double write buffer.*/
|
|
2596 |
ut_a(page_size == UNIV_PAGE_SIZE); |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2597 |
fprintf(stderr, "[%02u] xtrabackup: " |
2598 |
"Page %lu seems double write "
|
|
2599 |
"buffer. passing the check.\n", |
|
2600 |
thread_n, |
|
2601 |
(ulint)((offset + |
|
2602 |
(IB_INT64)chunk_offset) >> |
|
2603 |
page_size_shift)); |
|
121
by kinoyasu
fix bug498660 |
2604 |
} else { |
2605 |
retry_count--; |
|
2606 |
if (retry_count == 0) { |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2607 |
fprintf(stderr, |
2608 |
"[%02u] xtrabackup: "
|
|
2609 |
"Error: 10 retries "
|
|
2610 |
"resulted in fail. This"
|
|
2611 |
"file seems to be "
|
|
2612 |
"corrupted.\n", |
|
2613 |
thread_n); |
|
121
by kinoyasu
fix bug498660 |
2614 |
goto error; |
2615 |
}
|
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2616 |
fprintf(stderr, "[%02u] xtrabackup: " |
2617 |
"Database page corruption "
|
|
2618 |
"detected at page %lu. "
|
|
2619 |
"retrying...\n", |
|
2620 |
thread_n, |
|
2621 |
(ulint)((offset + |
|
2622 |
(IB_INT64)chunk_offset) |
|
2623 |
>> page_size_shift)); |
|
121
by kinoyasu
fix bug498660 |
2624 |
goto read_retry; |
63
by kinoyasu
data page corruption check is added to local backup mode |
2625 |
}
|
2626 |
}
|
|
2627 |
}
|
|
2628 |
||
33
by kinoyasu
primitive implementation of incremental backup |
2629 |
if (xtrabackup_incremental) { |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2630 |
for (chunk_offset = 0; chunk_offset < chunk; chunk_offset += page_size) { |
33
by kinoyasu
primitive implementation of incremental backup |
2631 |
/* newer page */
|
2632 |
/* This condition may be OK for header, ibuf and fsp */
|
|
187
by kinoyasu
revert to treat the pages of FIL_PAGE_LSN is 0 as .delta file. It is not needed for consistent InnoDB datafile. And it seems to increase size of .delta |
2633 |
if (ut_dulint_cmp(incremental_lsn, |
2634 |
MACH_READ_64(page + chunk_offset + FIL_PAGE_LSN)) < 0) { |
|
33
by kinoyasu
primitive implementation of incremental backup |
2635 |
/* ========================================= */
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2636 |
IB_INT64 page_offset; |
33
by kinoyasu
primitive implementation of incremental backup |
2637 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2638 |
if (page_in_buffer == page_size/4) { |
33
by kinoyasu
primitive implementation of incremental backup |
2639 |
/* flush buffer */
|
2640 |
success = os_file_write(dst_path, dst_file, incremental_buffer, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2641 |
((incremental_buffers * (page_size/4)) |
2642 |
<< page_size_shift) & 0xFFFFFFFFUL, |
|
2643 |
(incremental_buffers * (page_size/4)) |
|
2644 |
>> (32 - page_size_shift), |
|
2645 |
page_in_buffer * page_size); |
|
33
by kinoyasu
primitive implementation of incremental backup |
2646 |
if (!success) { |
2647 |
goto error; |
|
2648 |
}
|
|
2649 |
||
2650 |
incremental_buffers++; |
|
2651 |
||
2652 |
/* clear buffer */
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2653 |
bzero(incremental_buffer, (page_size/4) * page_size); |
33
by kinoyasu
primitive implementation of incremental backup |
2654 |
page_in_buffer = 0; |
2655 |
mach_write_to_4(incremental_buffer, 0x78747261UL);/*"xtra"*/ |
|
2656 |
page_in_buffer++; |
|
2657 |
}
|
|
2658 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
2659 |
page_offset = ((offset + (IB_INT64)chunk_offset) >> page_size_shift); |
33
by kinoyasu
primitive implementation of incremental backup |
2660 |
ut_a(page_offset >> 32 == 0); |
2661 |
||
84
by kinoyasu
some fixes for 32bit |
2662 |
mach_write_to_4(incremental_buffer + page_in_buffer * 4, (ulint)page_offset); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2663 |
memcpy(incremental_buffer + page_in_buffer * page_size, |
2664 |
page + chunk_offset, page_size); |
|
33
by kinoyasu
primitive implementation of incremental backup |
2665 |
|
2666 |
page_in_buffer++; |
|
2667 |
/* ========================================= */
|
|
2668 |
}
|
|
2669 |
}
|
|
2670 |
} else { |
|
2671 |
success = os_file_write(dst_path, dst_file, page, |
|
2672 |
(ulint)(offset & 0xFFFFFFFFUL), |
|
2673 |
(ulint)(offset >> 32), chunk); |
|
2674 |
if (!success) { |
|
2675 |
goto error; |
|
2676 |
}
|
|
2677 |
}
|
|
2678 |
||
2679 |
}
|
|
2680 |
||
2681 |
if (xtrabackup_incremental) { |
|
2682 |
/* termination */
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2683 |
if (page_in_buffer != page_size/4) { |
33
by kinoyasu
primitive implementation of incremental backup |
2684 |
mach_write_to_4(incremental_buffer + page_in_buffer * 4, 0xFFFFFFFFUL); |
2685 |
}
|
|
2686 |
||
2687 |
mach_write_to_4(incremental_buffer, 0x58545241UL);/*"XTRA"*/ |
|
2688 |
||
2689 |
/* flush buffer */
|
|
2690 |
success = os_file_write(dst_path, dst_file, incremental_buffer, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2691 |
((incremental_buffers * (page_size/4)) |
2692 |
<< page_size_shift) & 0xFFFFFFFFUL, |
|
2693 |
(incremental_buffers * (page_size/4)) |
|
2694 |
>> (32 - page_size_shift), |
|
2695 |
page_in_buffer * page_size); |
|
33
by kinoyasu
primitive implementation of incremental backup |
2696 |
if (!success) { |
2697 |
goto error; |
|
2698 |
}
|
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
2699 |
if (!xb_write_delta_metadata(meta_path, &info)) { |
2700 |
fprintf(stderr, "[%02u] xtrabackup: Error: " |
|
2701 |
"failed to write meta info for %s\n", dst_path); |
|
2702 |
goto error; |
|
2703 |
}
|
|
1
by kinoyasu
initial registration |
2704 |
}
|
2705 |
||
2706 |
success = os_file_flush(dst_file); |
|
2707 |
if (!success) { |
|
2708 |
goto error; |
|
2709 |
}
|
|
2710 |
||
2711 |
||
2712 |
/* check size again */
|
|
2713 |
/* TODO: but is it needed ?? */
|
|
189
by kinoyasu
remove needless retry at xtrabackup_copy_datafile() |
2714 |
// if (file_size < os_file_get_size_as_iblonglong(src_file)) {
|
2715 |
// offset -= COPY_CHUNK * page_size;
|
|
2716 |
// file_size = os_file_get_size_as_iblonglong(src_file);
|
|
2717 |
// goto copy_loop;
|
|
2718 |
// }
|
|
1
by kinoyasu
initial registration |
2719 |
|
2720 |
/* TODO: How should we treat double_write_buffer here? */
|
|
2
by kinoyasu
The first usable version. |
2721 |
/* (currently, don't care about. Because,
|
2722 |
the blocks is newer than the last checkpoint anyway.) */
|
|
1
by kinoyasu
initial registration |
2723 |
|
2724 |
/* close */
|
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2725 |
printf("[%02u] ...done\n", thread_n); |
133
by kinoyasu
fix duplicate close() problem at xtrabackup_copy_datafile() |
2726 |
if (!node->open) { |
2727 |
os_file_close(src_file); |
|
2728 |
}
|
|
1
by kinoyasu
initial registration |
2729 |
os_file_close(dst_file); |
2730 |
ut_free(buf2); |
|
2731 |
return(FALSE); |
|
2732 |
error: |
|
133
by kinoyasu
fix duplicate close() problem at xtrabackup_copy_datafile() |
2733 |
if (src_file != -1 && !node->open) |
1
by kinoyasu
initial registration |
2734 |
os_file_close(src_file); |
62
by kinoyasu
fix simple mistakes |
2735 |
if (dst_file != -1) |
1
by kinoyasu
initial registration |
2736 |
os_file_close(dst_file); |
2737 |
if (buf2) |
|
2738 |
ut_free(buf2); |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
2739 |
fprintf(stderr, "[%02u] xtrabackup: Error: " |
2740 |
"xtrabackup_copy_datafile() failed.\n", thread_n); |
|
1
by kinoyasu
initial registration |
2741 |
return(TRUE); /*ERROR*/ |
215
by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already |
2742 |
|
2743 |
skip: |
|
2744 |
if (src_file != -1 && !node->open) |
|
2745 |
os_file_close(src_file); |
|
2746 |
if (dst_file != -1) |
|
2747 |
os_file_close(dst_file); |
|
2748 |
if (buf2) |
|
2749 |
ut_free(buf2); |
|
2750 |
fprintf(stderr, "[%02u] xtrabackup: Warning: skipping file %s.\n", |
|
2751 |
thread_n, node->name); |
|
2752 |
return(FALSE); |
|
1
by kinoyasu
initial registration |
2753 |
}
|
2754 |
||
18
by kinoyasu
supporting MySQL 5.1 |
2755 |
my_bool
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2756 |
xtrabackup_copy_logfile(LSN64 from_lsn, my_bool is_last) |
1
by kinoyasu
initial registration |
2757 |
{
|
2758 |
/* definition from recv_recovery_from_checkpoint_start() */
|
|
2759 |
log_group_t* group; |
|
2760 |
log_group_t* up_to_date_group; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2761 |
LSN64 old_scanned_lsn; |
2762 |
LSN64 group_scanned_lsn; |
|
2763 |
LSN64 contiguous_lsn; |
|
1
by kinoyasu
initial registration |
2764 |
|
2765 |
ibool success; |
|
2766 |
||
14
by kinoyasu
using rsync for incremental backup |
2767 |
if (!xtrabackup_stream) |
2768 |
ut_a(dst_log != -1); |
|
1
by kinoyasu
initial registration |
2769 |
|
2770 |
/* read from checkpoint_lsn_start to current */
|
|
2771 |
contiguous_lsn = ut_dulint_align_down(from_lsn, |
|
2772 |
OS_FILE_LOG_BLOCK_SIZE); |
|
2773 |
||
2774 |
/* TODO: We must check the contiguous_lsn still exists in log file.. */
|
|
2775 |
||
2776 |
group = UT_LIST_GET_FIRST(log_sys->log_groups); |
|
2777 |
||
2778 |
while (group) { |
|
2779 |
ibool finished; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2780 |
LSN64 start_lsn; |
2781 |
LSN64 end_lsn; |
|
1
by kinoyasu
initial registration |
2782 |
|
2783 |
||
2784 |
old_scanned_lsn = from_lsn; |
|
2785 |
||
2
by kinoyasu
The first usable version. |
2786 |
/* reference recv_group_scan_log_recs() */
|
1
by kinoyasu
initial registration |
2787 |
finished = FALSE; |
2788 |
||
2789 |
start_lsn = contiguous_lsn; |
|
2790 |
||
2791 |
while (!finished) { |
|
2792 |
end_lsn = ut_dulint_add(start_lsn, RECV_SCAN_SIZE); |
|
2793 |
||
3
by kinoyasu
planned options are implemented |
2794 |
xtrabackup_io_throttling(); |
2795 |
||
1
by kinoyasu
initial registration |
2796 |
log_group_read_log_seg(LOG_RECOVER, log_sys->buf, |
2797 |
group, start_lsn, end_lsn); |
|
2798 |
||
2
by kinoyasu
The first usable version. |
2799 |
//printf("log read from (%lu %lu) to (%lu %lu)\n",
|
2800 |
// start_lsn.high, start_lsn.low, end_lsn.high, end_lsn.low);
|
|
1
by kinoyasu
initial registration |
2801 |
|
2
by kinoyasu
The first usable version. |
2802 |
/* reference recv_scan_log_recs() */
|
1
by kinoyasu
initial registration |
2803 |
{
|
2804 |
byte* log_block; |
|
2805 |
ulint no; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2806 |
LSN64 scanned_lsn; |
1
by kinoyasu
initial registration |
2807 |
ulint data_len; |
2808 |
ibool more_data; |
|
2809 |
||
2810 |
ulint scanned_checkpoint_no = 0; |
|
2811 |
||
2812 |
finished = FALSE; |
|
2813 |
||
2814 |
log_block = log_sys->buf; |
|
2815 |
scanned_lsn = start_lsn; |
|
2816 |
more_data = FALSE; |
|
2817 |
||
2818 |
while (log_block < log_sys->buf + RECV_SCAN_SIZE && !finished) { |
|
2819 |
||
2820 |
no = log_block_get_hdr_no(log_block); |
|
2821 |
||
2822 |
if (no != log_block_convert_lsn_to_no(scanned_lsn) |
|
2823 |
|| !log_block_checksum_is_ok_or_old_format(log_block)) { |
|
2824 |
||
194.1.1
by kinoyasu
change overtaken-check to the more exact method. |
2825 |
if (no > log_block_convert_lsn_to_no(scanned_lsn) |
2826 |
&& log_block_checksum_is_ok_or_old_format(log_block)) { |
|
2827 |
fprintf(stderr, |
|
2828 |
">> ###Warning###: The copying transaction log migh be overtaken already by the target.\n" |
|
2829 |
">> : Waiting log block no %lu, but the bumber is already %lu.\n" |
|
2830 |
">> : If the number equals %lu + n * %lu, it should be overtaken already.\n", |
|
2831 |
(ulong) log_block_convert_lsn_to_no(scanned_lsn), |
|
2832 |
(ulong) no, |
|
2833 |
(ulong) log_block_convert_lsn_to_no(scanned_lsn), |
|
2834 |
(ulong) (log_block_convert_lsn_to_no( |
|
194.1.5
by Alexey Kopytov
LP bug#681507: Compile error, XtraBackup 1.5(trunk), CentOS 5 |
2835 |
#ifndef INNODB_VERSION_SHORT
|
2836 |
ut_dulint_create(0, log_group_get_capacity(group)) |
|
2837 |
#else
|
|
2838 |
log_group_get_capacity(group) |
|
2839 |
#endif
|
|
2840 |
) - 1)); |
|
194.1.1
by kinoyasu
change overtaken-check to the more exact method. |
2841 |
|
2842 |
} else if (no == log_block_convert_lsn_to_no(scanned_lsn) |
|
1
by kinoyasu
initial registration |
2843 |
&& !log_block_checksum_is_ok_or_old_format( |
2844 |
log_block)) { |
|
2845 |
fprintf(stderr, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2846 |
#ifndef INNODB_VERSION_SHORT
|
45
by kinoyasu
messages are fixed a little |
2847 |
"xtrabackup: Log block no %lu at lsn %lu %lu has\n" |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2848 |
#else
|
2849 |
"xtrabackup: Log block no %lu at lsn %llu has\n" |
|
2850 |
#endif
|
|
45
by kinoyasu
messages are fixed a little |
2851 |
"xtrabackup: ok header, but checksum field contains %lu, should be %lu\n", |
1
by kinoyasu
initial registration |
2852 |
(ulong) no, |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2853 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
2854 |
(ulong) ut_dulint_get_high(scanned_lsn), |
2855 |
(ulong) ut_dulint_get_low(scanned_lsn), |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
2856 |
#else
|
2857 |
scanned_lsn, |
|
2858 |
#endif
|
|
1
by kinoyasu
initial registration |
2859 |
(ulong) log_block_get_checksum(log_block), |
2860 |
(ulong) log_block_calc_checksum(log_block)); |
|
2861 |
}
|
|
2862 |
||
2863 |
/* Garbage or an incompletely written log block */
|
|
2864 |
||
2865 |
finished = TRUE; |
|
2866 |
||
2867 |
break; |
|
2868 |
}
|
|
2869 |
||
2870 |
if (log_block_get_flush_bit(log_block)) { |
|
2871 |
/* This block was a start of a log flush operation:
|
|
2872 |
we know that the previous flush operation must have
|
|
2873 |
been completed for all log groups before this block
|
|
2874 |
can have been flushed to any of the groups. Therefore,
|
|
2875 |
we know that log data is contiguous up to scanned_lsn
|
|
2876 |
in all non-corrupt log groups. */
|
|
2877 |
||
2878 |
if (ut_dulint_cmp(scanned_lsn, contiguous_lsn) > 0) { |
|
2879 |
contiguous_lsn = scanned_lsn; |
|
2880 |
}
|
|
2881 |
}
|
|
2882 |
||
2883 |
data_len = log_block_get_data_len(log_block); |
|
2884 |
||
2885 |
if ( |
|
2886 |
(scanned_checkpoint_no > 0) |
|
2887 |
&& (log_block_get_checkpoint_no(log_block) |
|
2888 |
< scanned_checkpoint_no) |
|
2889 |
&& (scanned_checkpoint_no |
|
2890 |
- log_block_get_checkpoint_no(log_block) |
|
2891 |
> 0x80000000UL)) { |
|
2892 |
||
2893 |
/* Garbage from a log buffer flush which was made
|
|
2894 |
before the most recent database recovery */
|
|
2895 |
||
2896 |
finished = TRUE; |
|
2897 |
break; |
|
2898 |
}
|
|
2899 |
||
2900 |
scanned_lsn = ut_dulint_add(scanned_lsn, data_len); |
|
2901 |
scanned_checkpoint_no = log_block_get_checkpoint_no(log_block); |
|
2902 |
||
2903 |
if (data_len < OS_FILE_LOG_BLOCK_SIZE) { |
|
2904 |
/* Log data for this group ends here */
|
|
2905 |
||
2906 |
finished = TRUE; |
|
2907 |
} else { |
|
2908 |
log_block += OS_FILE_LOG_BLOCK_SIZE; |
|
2909 |
}
|
|
2910 |
} /* while (log_block < log_sys->buf + RECV_SCAN_SIZE && !finished) */ |
|
2911 |
||
2912 |
group_scanned_lsn = scanned_lsn; |
|
2913 |
||
2914 |
||
2915 |
||
2916 |
}
|
|
2917 |
||
2918 |
/* ===== write log to 'xtrabackup_logfile' ====== */
|
|
2919 |
{
|
|
2920 |
ulint write_size; |
|
2921 |
||
2922 |
if (!finished) { |
|
2923 |
write_size = RECV_SCAN_SIZE; |
|
2924 |
} else { |
|
2925 |
write_size = ut_dulint_minus( |
|
2926 |
ut_dulint_align_up(group_scanned_lsn, OS_FILE_LOG_BLOCK_SIZE), |
|
2927 |
start_lsn); |
|
2928 |
}
|
|
2929 |
||
2
by kinoyasu
The first usable version. |
2930 |
//printf("Wrinting offset= %lld, size= %lu\n", log_copy_offset, write_size);
|
1
by kinoyasu
initial registration |
2931 |
|
14
by kinoyasu
using rsync for incremental backup |
2932 |
if (!xtrabackup_stream) { |
2933 |
success = os_file_write(dst_log_path, dst_log, log_sys->buf, |
|
2934 |
(ulint)(log_copy_offset & 0xFFFFFFFFUL), |
|
2935 |
(ulint)(log_copy_offset >> 32), write_size); |
|
2936 |
} else { |
|
2937 |
ulint ret; |
|
2938 |
ulint stdout_write_size = write_size; |
|
31
by kinoyasu
fix bug 352742 |
2939 |
if (finished && !is_last |
100
by kinoyasu
initial implementation for InnoDB Plugin |
2940 |
#ifndef INNODB_VERSION_SHORT
|
2941 |
&& group_scanned_lsn.low % OS_FILE_LOG_BLOCK_SIZE |
|
2942 |
#else
|
|
2943 |
&& group_scanned_lsn % OS_FILE_LOG_BLOCK_SIZE |
|
2944 |
#endif
|
|
2945 |
)
|
|
14
by kinoyasu
using rsync for incremental backup |
2946 |
stdout_write_size -= OS_FILE_LOG_BLOCK_SIZE; |
2947 |
if (stdout_write_size) { |
|
2948 |
ret = write(fileno(stdout), log_sys->buf, stdout_write_size); |
|
2949 |
if (ret == stdout_write_size) { |
|
2950 |
success = TRUE; |
|
2951 |
} else { |
|
2952 |
fprintf(stderr, "write: %lu > %lu\n", stdout_write_size, ret); |
|
2953 |
success = FALSE; |
|
2954 |
}
|
|
2955 |
} else { |
|
2956 |
success = TRUE; /* do nothing */ |
|
2957 |
}
|
|
2958 |
}
|
|
2959 |
||
1
by kinoyasu
initial registration |
2960 |
log_copy_offset += write_size; |
2961 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
2962 |
#ifndef INNODB_VERSION_SHORT
|
2963 |
if (finished && group_scanned_lsn.low % OS_FILE_LOG_BLOCK_SIZE) |
|
2964 |
#else
|
|
2965 |
if (finished && group_scanned_lsn % OS_FILE_LOG_BLOCK_SIZE) |
|
2966 |
#endif
|
|
2967 |
{
|
|
1
by kinoyasu
initial registration |
2968 |
/* if continue, it will start from align_down(group_scanned_lsn) */
|
2969 |
log_copy_offset -= OS_FILE_LOG_BLOCK_SIZE; |
|
2970 |
}
|
|
2971 |
||
2972 |
if(!success) { |
|
14
by kinoyasu
using rsync for incremental backup |
2973 |
if (!xtrabackup_stream) { |
45
by kinoyasu
messages are fixed a little |
2974 |
fprintf(stderr, "xtrabackup: Error: os_file_write to %s\n", dst_log_path); |
14
by kinoyasu
using rsync for incremental backup |
2975 |
} else { |
45
by kinoyasu
messages are fixed a little |
2976 |
fprintf(stderr, "xtrabackup: Error: write to stdout\n"); |
14
by kinoyasu
using rsync for incremental backup |
2977 |
}
|
1
by kinoyasu
initial registration |
2978 |
goto error; |
2979 |
}
|
|
2980 |
||
2981 |
||
2982 |
}
|
|
2983 |
||
2984 |
||
2985 |
||
2986 |
||
2987 |
||
2988 |
start_lsn = end_lsn; |
|
2989 |
}
|
|
2990 |
||
2991 |
||
2992 |
||
2993 |
group->scanned_lsn = group_scanned_lsn; |
|
2994 |
||
2995 |
if (ut_dulint_cmp(old_scanned_lsn, group_scanned_lsn) < 0) { |
|
2996 |
/* We found a more up-to-date group */
|
|
2997 |
||
2998 |
up_to_date_group = group; |
|
2999 |
}
|
|
3000 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3001 |
#ifndef INNODB_VERSION_SHORT
|
11
by kinoyasu
fix tribials |
3002 |
fprintf(stderr, ">> log scanned up to (%lu %lu)\n",group->scanned_lsn.high,group->scanned_lsn.low); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3003 |
#else
|
3004 |
fprintf(stderr, ">> log scanned up to (%llu)\n",group->scanned_lsn); |
|
3005 |
#endif
|
|
1
by kinoyasu
initial registration |
3006 |
|
3007 |
group = UT_LIST_GET_NEXT(log_groups, group); |
|
3008 |
||
3009 |
/* update global variable*/
|
|
3010 |
log_copy_scanned_lsn = group_scanned_lsn; |
|
3011 |
||
3012 |
/* innodb_mirrored_log_groups must be 1, no other groups */
|
|
3013 |
ut_a(group == NULL); |
|
3014 |
}
|
|
3015 |
||
3016 |
||
14
by kinoyasu
using rsync for incremental backup |
3017 |
if (!xtrabackup_stream) { |
3018 |
success = os_file_flush(dst_log); |
|
3019 |
} else { |
|
3020 |
fflush(stdout); |
|
3021 |
success = TRUE; |
|
3022 |
}
|
|
3023 |
||
1
by kinoyasu
initial registration |
3024 |
if(!success) { |
3025 |
goto error; |
|
3026 |
}
|
|
3027 |
||
3028 |
return(FALSE); |
|
3029 |
||
3030 |
error: |
|
14
by kinoyasu
using rsync for incremental backup |
3031 |
if (!xtrabackup_stream) |
3032 |
os_file_close(dst_log); |
|
45
by kinoyasu
messages are fixed a little |
3033 |
fprintf(stderr, "xtrabackup: Error: xtrabackup_copy_logfile() failed.\n"); |
1
by kinoyasu
initial registration |
3034 |
return(TRUE); |
3035 |
}
|
|
3036 |
||
3037 |
/* copying logfile in background */
|
|
3038 |
#define SLEEPING_PERIOD 5
|
|
3039 |
||
3040 |
static
|
|
3041 |
#ifndef __WIN__
|
|
3042 |
void* |
|
3043 |
#else
|
|
3044 |
ulint
|
|
3045 |
#endif
|
|
3046 |
log_copying_thread( |
|
3047 |
void* arg) |
|
3048 |
{
|
|
3
by kinoyasu
planned options are implemented |
3049 |
ulint counter = 0; |
3050 |
||
14
by kinoyasu
using rsync for incremental backup |
3051 |
if (!xtrabackup_stream) |
3052 |
ut_a(dst_log != -1); |
|
2
by kinoyasu
The first usable version. |
3053 |
|
1
by kinoyasu
initial registration |
3054 |
log_copying_running = TRUE; |
3055 |
||
3056 |
while(log_copying) { |
|
94
by kinoyasu
Windows conscious experimental change |
3057 |
os_thread_sleep(200000); /*0.2 sec*/ |
1
by kinoyasu
initial registration |
3058 |
|
3
by kinoyasu
planned options are implemented |
3059 |
counter++; |
11
by kinoyasu
fix tribials |
3060 |
if(counter >= SLEEPING_PERIOD * 5) { |
14
by kinoyasu
using rsync for incremental backup |
3061 |
if(xtrabackup_copy_logfile(log_copy_scanned_lsn, FALSE)) |
3
by kinoyasu
planned options are implemented |
3062 |
goto end; |
3063 |
counter = 0; |
|
3064 |
}
|
|
1
by kinoyasu
initial registration |
3065 |
}
|
3066 |
||
3
by kinoyasu
planned options are implemented |
3067 |
/* last copying */
|
14
by kinoyasu
using rsync for incremental backup |
3068 |
if(xtrabackup_copy_logfile(log_copy_scanned_lsn, TRUE)) |
3
by kinoyasu
planned options are implemented |
3069 |
goto end; |
3070 |
||
1
by kinoyasu
initial registration |
3071 |
log_copying_succeed = TRUE; |
3072 |
end: |
|
3073 |
log_copying_running = FALSE; |
|
3074 |
os_thread_exit(NULL); |
|
85
by kinoyasu
new option --stats to gather index stats |
3075 |
|
3076 |
return(0); |
|
1
by kinoyasu
initial registration |
3077 |
}
|
3078 |
||
3
by kinoyasu
planned options are implemented |
3079 |
/* io throttle watching (rough) */
|
3080 |
static
|
|
3081 |
#ifndef __WIN__
|
|
3082 |
void* |
|
3083 |
#else
|
|
3084 |
ulint
|
|
3085 |
#endif
|
|
3086 |
io_watching_thread( |
|
3087 |
void* arg) |
|
3088 |
{
|
|
3089 |
/* currently, for --backup only */
|
|
3090 |
ut_a(xtrabackup_backup); |
|
3091 |
||
3092 |
while (log_copying) { |
|
94
by kinoyasu
Windows conscious experimental change |
3093 |
os_thread_sleep(1000000); /*1 sec*/ |
3
by kinoyasu
planned options are implemented |
3094 |
|
3095 |
//for DEBUG
|
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
3096 |
//if (io_ticket == xtrabackup_throttle) {
|
3097 |
// fprintf(stderr, "There seem to be no IO...?\n");
|
|
3098 |
//}
|
|
3
by kinoyasu
planned options are implemented |
3099 |
|
3100 |
io_ticket = xtrabackup_throttle; |
|
3101 |
os_event_set(wait_throttle); |
|
3102 |
}
|
|
3103 |
||
3104 |
/* stop io throttle */
|
|
3105 |
xtrabackup_throttle = 0; |
|
3106 |
os_event_set(wait_throttle); |
|
3107 |
||
3108 |
os_thread_exit(NULL); |
|
85
by kinoyasu
new option --stats to gather index stats |
3109 |
|
3110 |
return(0); |
|
3
by kinoyasu
planned options are implemented |
3111 |
}
|
1
by kinoyasu
initial registration |
3112 |
|
3113 |
/************************************************************************
|
|
3114 |
I/o-handler thread function. */
|
|
3115 |
static
|
|
3116 |
||
3117 |
#ifndef __WIN__
|
|
3118 |
void* |
|
3119 |
#else
|
|
3120 |
ulint
|
|
3121 |
#endif
|
|
3122 |
io_handler_thread( |
|
3123 |
/*==============*/
|
|
3124 |
void* arg) |
|
3125 |
{
|
|
3126 |
ulint segment; |
|
3127 |
ulint i; |
|
3128 |
||
3129 |
segment = *((ulint*)arg); |
|
3130 |
||
3131 |
for (i = 0;; i++) { |
|
3132 |
fil_aio_wait(segment); |
|
3133 |
}
|
|
3134 |
||
3135 |
/* We count the number of threads in os_thread_exit(). A created
|
|
3136 |
thread should always use that to exit and not use return() to exit.
|
|
3137 |
The thread actually never comes here because it is exited in an
|
|
3138 |
os_event_wait(). */
|
|
3139 |
||
3140 |
os_thread_exit(NULL); |
|
3141 |
||
3142 |
#ifndef __WIN__
|
|
3143 |
return(NULL); /* Not reached */ |
|
3144 |
#else
|
|
3145 |
return(0); |
|
3146 |
#endif
|
|
3147 |
}
|
|
3148 |
||
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3149 |
/***************************************************************************
|
3150 |
Creates an output directory for a given tablespace, if it does not exist */
|
|
3151 |
static
|
|
3152 |
int
|
|
3153 |
xtrabackup_create_output_dir( |
|
3154 |
/*==========================*/
|
|
3155 |
/* out: 0 if succes, -1 if failure */
|
|
3156 |
fil_space_t *space) /* in: tablespace */ |
|
3157 |
{
|
|
3158 |
char path[FN_REFLEN]; |
|
3159 |
char *ptr1, *ptr2; |
|
3160 |
MY_STAT stat_info; |
|
3161 |
||
3162 |
/* mkdir if not exist */
|
|
3163 |
ptr1 = strstr(space->name, SRV_PATH_SEPARATOR_STR); |
|
3164 |
if (ptr1) { |
|
3165 |
ptr2 = strstr(ptr1 + 1, SRV_PATH_SEPARATOR_STR); |
|
3166 |
} else { |
|
3167 |
ptr2 = NULL; |
|
3168 |
}
|
|
3169 |
#ifdef XTRADB_BASED
|
|
3170 |
if(!trx_sys_sys_space(space->id) && ptr2) |
|
3171 |
#else
|
|
3172 |
if(space->id && ptr2) |
|
3173 |
#endif
|
|
3174 |
{
|
|
3175 |
/* single table space */
|
|
3176 |
*ptr2 = 0; /* temporary (it's my lazy..)*/ |
|
3177 |
snprintf(path, sizeof(path), "%s%s", xtrabackup_target_dir, |
|
3178 |
ptr1); |
|
3179 |
*ptr2 = SRV_PATH_SEPARATOR; |
|
3180 |
||
221
by Alexey Kopytov
LP bug #717784: Race condition in directory creation with parallel |
3181 |
if (my_mkdir(path, 0777, MYF(0)) < 0 && my_errno != EEXIST) { |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3182 |
fprintf(stderr, |
3183 |
"xtrabackup: Error: cannot mkdir %d: %s\n", |
|
3184 |
my_errno, path); |
|
3185 |
return -1; |
|
3186 |
}
|
|
3187 |
}
|
|
3188 |
return 0; |
|
3189 |
}
|
|
3190 |
||
3191 |
/**************************************************************************
|
|
3192 |
Datafiles copying thread.*/
|
|
3193 |
static
|
|
3194 |
os_thread_ret_t
|
|
3195 |
data_copy_thread_func( |
|
3196 |
/*==================*/
|
|
3197 |
void *arg) /* thread context */ |
|
3198 |
{
|
|
3199 |
data_thread_ctxt_t *ctxt = (data_thread_ctxt_t *) arg; |
|
3200 |
uint num = ctxt->num; |
|
3201 |
fil_space_t* space; |
|
3202 |
ibool space_changed; |
|
3203 |
fil_node_t* node; |
|
3204 |
||
3205 |
/*
|
|
3206 |
We have to initialize mysys thread-specific memory because
|
|
3207 |
of the my_stat() call in xtrabackup_create_output_dir().
|
|
3208 |
*/
|
|
3209 |
my_thread_init(); |
|
3210 |
||
3211 |
while ((node = datafiles_iter_next(ctxt->it, &space_changed)) != NULL) { |
|
3212 |
space = node->space; |
|
3213 |
||
3214 |
if (space_changed && xtrabackup_create_output_dir(space)) |
|
208
by Alexey Kopytov
Manual merge from lp:~percona-dev/percona-xtrabackup/exit_codes |
3215 |
exit(EXIT_FAILURE); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3216 |
|
3217 |
/* copy the datafile */
|
|
3218 |
if(xtrabackup_copy_datafile(node, num)) { |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
3219 |
fprintf(stderr, "[%02u] xtrabackup: Error: " |
3220 |
"failed to copy datafile.\n", |
|
3221 |
num); |
|
206.2.2
by Alexey Kopytov
Manual merge from trunk. |
3222 |
exit(EXIT_FAILURE); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3223 |
}
|
3224 |
}
|
|
3225 |
||
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3226 |
os_mutex_enter(ctxt->count_mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3227 |
(*ctxt->count)--; |
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3228 |
os_mutex_exit(ctxt->count_mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3229 |
|
3230 |
my_thread_end(); |
|
3231 |
os_thread_exit(NULL); |
|
3232 |
OS_THREAD_DUMMY_RETURN; |
|
3233 |
}
|
|
3234 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
3235 |
/* CAUTION(?): Don't rename file_per_table during backup */
|
1
by kinoyasu
initial registration |
3236 |
void
|
3237 |
xtrabackup_backup_func(void) |
|
3238 |
{
|
|
3239 |
MY_STAT stat_info; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3240 |
LSN64 latest_cp; |
1
by kinoyasu
initial registration |
3241 |
|
52
by kinoyasu
add to use posix_fadvise() if possible |
3242 |
#ifdef USE_POSIX_FADVISE
|
3243 |
fprintf(stderr, "xtrabackup: uses posix_fadvise().\n"); |
|
3244 |
#endif
|
|
3245 |
||
1
by kinoyasu
initial registration |
3246 |
/* cd to datadir */
|
3247 |
||
3248 |
if (my_setwd(mysql_real_data_home,MYF(MY_WME))) |
|
3249 |
{
|
|
45
by kinoyasu
messages are fixed a little |
3250 |
fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3251 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3252 |
}
|
45
by kinoyasu
messages are fixed a little |
3253 |
fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home); |
3254 |
||
1
by kinoyasu
initial registration |
3255 |
mysql_data_home= mysql_data_home_buff; |
3256 |
mysql_data_home[0]=FN_CURLIB; // all paths are relative from here |
|
3257 |
mysql_data_home[1]=0; |
|
3258 |
||
73
by kinoyasu
fix bug 394781, bug 394374 |
3259 |
/* set read only */
|
3260 |
srv_read_only = TRUE; |
|
99
by kinoyasu
refix bug 435634 |
3261 |
|
1
by kinoyasu
initial registration |
3262 |
/* initialize components */
|
3263 |
if(innodb_init_param()) |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3264 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3265 |
|
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3266 |
if (srv_file_flush_method_str == NULL) { |
3267 |
/* These are the default options */
|
|
53
by kinoyasu
fix compiling error at 5.1 |
3268 |
#if (MYSQL_VERSION_ID < 50100)
|
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3269 |
srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; |
53
by kinoyasu
fix compiling error at 5.1 |
3270 |
#else /* MYSQL_VERSION_ID < 51000 */ |
3271 |
srv_unix_file_flush_method = SRV_UNIX_FSYNC; |
|
3272 |
#endif
|
|
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3273 |
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; |
3274 |
#ifndef __WIN__
|
|
53
by kinoyasu
fix compiling error at 5.1 |
3275 |
#if (MYSQL_VERSION_ID < 50100)
|
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3276 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "fdatasync")) { |
3277 |
srv_unix_file_flush_method = SRV_UNIX_FDATASYNC; |
|
53
by kinoyasu
fix compiling error at 5.1 |
3278 |
#else /* MYSQL_VERSION_ID < 51000 */ |
3279 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "fsync")) { |
|
3280 |
srv_unix_file_flush_method = SRV_UNIX_FSYNC; |
|
3281 |
#endif
|
|
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3282 |
|
3283 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) { |
|
3284 |
srv_unix_file_flush_method = SRV_UNIX_O_DSYNC; |
|
3285 |
||
3286 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) { |
|
3287 |
srv_unix_file_flush_method = SRV_UNIX_O_DIRECT; |
|
3288 |
fprintf(stderr,"xtrabackup: use O_DIRECT\n"); |
|
3289 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "littlesync")) { |
|
3290 |
srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC; |
|
3291 |
||
3292 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "nosync")) { |
|
3293 |
srv_unix_file_flush_method = SRV_UNIX_NOSYNC; |
|
3294 |
#else
|
|
3295 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) { |
|
3296 |
srv_win_file_flush_method = SRV_WIN_IO_NORMAL; |
|
3297 |
os_aio_use_native_aio = FALSE; |
|
3298 |
||
3299 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) { |
|
3300 |
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; |
|
3301 |
os_aio_use_native_aio = FALSE; |
|
3302 |
||
3303 |
} else if (0 == ut_strcmp(srv_file_flush_method_str, |
|
3304 |
"async_unbuffered")) { |
|
3305 |
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED; |
|
3306 |
#endif
|
|
3307 |
} else { |
|
3308 |
fprintf(stderr, |
|
3309 |
"xtrabackup: Unrecognized value %s for innodb_flush_method\n", |
|
3310 |
srv_file_flush_method_str); |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3311 |
exit(EXIT_FAILURE); |
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3312 |
}
|
3313 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3314 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
3315 |
if (srv_pool_size >= 1000 * 1024) { |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3316 |
#else
|
3317 |
if (srv_buf_pool_size >= 1000 * 1024 * 1024) { |
|
3318 |
#endif
|
|
1
by kinoyasu
initial registration |
3319 |
/* Here we still have srv_pool_size counted
|
3320 |
in kilobytes (in 4.0 this was in bytes)
|
|
3321 |
srv_boot() converts the value to
|
|
3322 |
pages; if buffer pool is less than 1000 MB,
|
|
3323 |
assume fewer threads. */
|
|
3324 |
srv_max_n_threads = 50000; |
|
3325 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3326 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
3327 |
} else if (srv_pool_size >= 8 * 1024) { |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3328 |
#else
|
3329 |
} else if (srv_buf_pool_size >= 8 * 1024 * 1024) { |
|
3330 |
#endif
|
|
1
by kinoyasu
initial registration |
3331 |
|
3332 |
srv_max_n_threads = 10000; |
|
3333 |
} else { |
|
3334 |
srv_max_n_threads = 1000; /* saves several MB of memory, |
|
3335 |
especially in 64-bit
|
|
3336 |
computers */
|
|
3337 |
}
|
|
3338 |
||
3339 |
{
|
|
3340 |
ulint n; |
|
3341 |
ulint i; |
|
3342 |
||
3343 |
n = srv_n_data_files; |
|
3344 |
||
3345 |
for (i = 0; i < n; i++) { |
|
3346 |
srv_data_file_sizes[i] = srv_data_file_sizes[i] |
|
3347 |
* ((1024 * 1024) / UNIV_PAGE_SIZE); |
|
3348 |
}
|
|
3349 |
||
3350 |
srv_last_file_size_max = srv_last_file_size_max |
|
3351 |
* ((1024 * 1024) / UNIV_PAGE_SIZE); |
|
3352 |
||
3353 |
srv_log_file_size = srv_log_file_size / UNIV_PAGE_SIZE; |
|
3354 |
||
3355 |
srv_log_buffer_size = srv_log_buffer_size / UNIV_PAGE_SIZE; |
|
3356 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3357 |
#ifndef INNODB_VERSION_SHORT
|
1
by kinoyasu
initial registration |
3358 |
srv_pool_size = srv_pool_size / (UNIV_PAGE_SIZE / 1024); |
3359 |
||
3360 |
srv_awe_window_size = srv_awe_window_size / UNIV_PAGE_SIZE; |
|
3361 |
||
3362 |
if (srv_use_awe) { |
|
3363 |
/* If we are using AWE we must save memory in the 32-bit
|
|
3364 |
address space of the process, and cannot bind the lock
|
|
3365 |
table size to the real buffer pool size. */
|
|
3366 |
||
3367 |
srv_lock_table_size = 20 * srv_awe_window_size; |
|
3368 |
} else { |
|
3369 |
srv_lock_table_size = 5 * srv_pool_size; |
|
3370 |
}
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3371 |
#else
|
3372 |
srv_lock_table_size = 5 * (srv_buf_pool_size / UNIV_PAGE_SIZE); |
|
3373 |
#endif
|
|
1
by kinoyasu
initial registration |
3374 |
}
|
3375 |
||
2
by kinoyasu
The first usable version. |
3376 |
os_sync_mutex = NULL; |
1
by kinoyasu
initial registration |
3377 |
srv_general_init(); |
3378 |
||
3379 |
{
|
|
3380 |
ibool create_new_db; |
|
154
by Yasufumi Kinoshita
fix bug611960 |
3381 |
#ifdef XTRADB_BASED
|
3382 |
ibool create_new_doublewrite_file; |
|
3383 |
#endif
|
|
1
by kinoyasu
initial registration |
3384 |
ibool log_file_created; |
3385 |
ibool log_created = FALSE; |
|
3386 |
ibool log_opened = FALSE; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3387 |
LSN64 min_flushed_lsn; |
3388 |
LSN64 max_flushed_lsn; |
|
1
by kinoyasu
initial registration |
3389 |
ulint sum_of_new_sizes; |
3390 |
ulint err; |
|
3391 |
ulint i; |
|
3392 |
||
3393 |
||
3394 |
||
3395 |
||
3396 |
#define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD
|
|
3397 |
#define SRV_MAX_N_PENDING_SYNC_IOS 100
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3398 |
|
3399 |
#ifndef INNODB_VERSION_SHORT
|
|
1
by kinoyasu
initial registration |
3400 |
os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD |
3401 |
* srv_n_file_io_threads, |
|
3402 |
srv_n_file_io_threads, |
|
3403 |
SRV_MAX_N_PENDING_SYNC_IOS); |
|
3404 |
||
3405 |
fil_init(srv_max_n_open_files); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3406 |
#else
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
3407 |
srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads; |
3408 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3409 |
os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD, |
3410 |
srv_n_read_io_threads, |
|
3411 |
srv_n_write_io_threads, |
|
3412 |
SRV_MAX_N_PENDING_SYNC_IOS); |
|
3413 |
||
3414 |
fil_init(srv_file_per_table ? 50000 : 5000, |
|
3415 |
srv_max_n_open_files); |
|
3416 |
#endif
|
|
1
by kinoyasu
initial registration |
3417 |
|
3418 |
fsp_init(); |
|
3419 |
log_init(); |
|
3420 |
||
3421 |
lock_sys_create(srv_lock_table_size); |
|
3422 |
||
3423 |
for (i = 0; i < srv_n_file_io_threads; i++) { |
|
3424 |
n[i] = i; |
|
3425 |
||
3426 |
os_thread_create(io_handler_thread, n + i, thread_ids + i); |
|
3427 |
}
|
|
3428 |
||
136
by kinoyasu
port to Percona Server 5.1.47-11 |
3429 |
os_thread_sleep(200000); /*0.2 sec*/ |
3430 |
||
1
by kinoyasu
initial registration |
3431 |
err = open_or_create_data_files(&create_new_db, |
154
by Yasufumi Kinoshita
fix bug611960 |
3432 |
#ifdef XTRADB_BASED
|
3433 |
&create_new_doublewrite_file, |
|
3434 |
#endif
|
|
1
by kinoyasu
initial registration |
3435 |
&min_flushed_lsn, &max_flushed_lsn, |
3436 |
&sum_of_new_sizes); |
|
3437 |
if (err != DB_SUCCESS) { |
|
3438 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
3439 |
"xtrabackup: Could not open or create data files.\n" |
3440 |
"xtrabackup: If you tried to add new data files, and it failed here,\n" |
|
3441 |
"xtrabackup: you should now edit innodb_data_file_path in my.cnf back\n" |
|
3442 |
"xtrabackup: to what it was, and remove the new ibdata files InnoDB created\n" |
|
3443 |
"xtrabackup: in this failed attempt. InnoDB only wrote those files full of\n" |
|
3444 |
"xtrabackup: zeros, but did not yet use them in any way. But be careful: do not\n" |
|
3445 |
"xtrabackup: remove old data files which contain your precious data!\n"); |
|
1
by kinoyasu
initial registration |
3446 |
|
3447 |
//return((int) err);
|
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3448 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3449 |
}
|
3450 |
||
3451 |
/* create_new_db must not be TRUE.. */
|
|
3452 |
if (create_new_db) { |
|
45
by kinoyasu
messages are fixed a little |
3453 |
fprintf(stderr, "xtrabackup: Something wrong with source files...\n"); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3454 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3455 |
}
|
3456 |
||
3457 |
for (i = 0; i < srv_n_log_files; i++) { |
|
3458 |
err = open_or_create_log_file(create_new_db, &log_file_created, |
|
3459 |
log_opened, 0, i); |
|
3460 |
if (err != DB_SUCCESS) { |
|
3461 |
||
3462 |
//return((int) err);
|
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3463 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3464 |
}
|
3465 |
||
3466 |
if (log_file_created) { |
|
3467 |
log_created = TRUE; |
|
3468 |
} else { |
|
3469 |
log_opened = TRUE; |
|
3470 |
}
|
|
3471 |
if ((log_opened && create_new_db) |
|
3472 |
|| (log_opened && log_created)) { |
|
3473 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
3474 |
"xtrabackup: Error: all log files must be created at the same time.\n" |
3475 |
"xtrabackup: All log files must be created also in database creation.\n" |
|
3476 |
"xtrabackup: If you want bigger or smaller log files, shut down the\n" |
|
3477 |
"xtrabackup: database and make sure there were no errors in shutdown.\n" |
|
3478 |
"xtrabackup: Then delete the existing log files. Edit the .cnf file\n" |
|
3479 |
"xtrabackup: and start the database again.\n"); |
|
1
by kinoyasu
initial registration |
3480 |
|
3481 |
//return(DB_ERROR);
|
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3482 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3483 |
}
|
3484 |
}
|
|
3485 |
||
3486 |
/* log_file_created must not be TRUE, if online */
|
|
3487 |
if (log_file_created) { |
|
45
by kinoyasu
messages are fixed a little |
3488 |
fprintf(stderr, "xtrabackup: Something wrong with source files...\n"); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3489 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3490 |
}
|
3491 |
||
3492 |
fil_load_single_table_tablespaces(); |
|
3493 |
||
3494 |
}
|
|
3495 |
||
182.1.1
by Baron Schwartz
add --extra-lsndir to xtrabackup |
3496 |
/* create extra LSN dir if it does not exist. */
|
3497 |
if (xtrabackup_extra_lsndir |
|
3498 |
&&!my_stat(xtrabackup_extra_lsndir,&stat_info,MYF(0)) |
|
3499 |
&& (my_mkdir(xtrabackup_extra_lsndir,0777,MYF(0)) < 0)){ |
|
3500 |
fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,xtrabackup_extra_lsndir); |
|
208
by Alexey Kopytov
Manual merge from lp:~percona-dev/percona-xtrabackup/exit_codes |
3501 |
exit(EXIT_FAILURE); |
182.1.1
by Baron Schwartz
add --extra-lsndir to xtrabackup |
3502 |
}
|
3503 |
||
3504 |
||
14
by kinoyasu
using rsync for incremental backup |
3505 |
if (!xtrabackup_stream) { |
3506 |
||
1
by kinoyasu
initial registration |
3507 |
/* create target dir if not exist */
|
3508 |
if (!my_stat(xtrabackup_target_dir,&stat_info,MYF(0)) |
|
3509 |
&& (my_mkdir(xtrabackup_target_dir,0777,MYF(0)) < 0)){ |
|
45
by kinoyasu
messages are fixed a little |
3510 |
fprintf(stderr,"xtrabackup: Error: cannot mkdir %d: %s\n",my_errno,xtrabackup_target_dir); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3511 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3512 |
}
|
3513 |
||
14
by kinoyasu
using rsync for incremental backup |
3514 |
} else { |
45
by kinoyasu
messages are fixed a little |
3515 |
fprintf(stderr,"xtrabackup: Stream mode.\n"); |
14
by kinoyasu
using rsync for incremental backup |
3516 |
/* stdout can treat binary at Linux */
|
3517 |
//setmode(fileno(stdout), O_BINARY);
|
|
3518 |
}
|
|
1
by kinoyasu
initial registration |
3519 |
|
3520 |
{
|
|
3521 |
fil_system_t* system = fil_system; |
|
3522 |
||
3523 |
/* definition from recv_recovery_from_checkpoint_start() */
|
|
3524 |
log_group_t* max_cp_group; |
|
3525 |
ulint max_cp_field; |
|
3526 |
byte* buf; |
|
3527 |
byte log_hdr_buf_[LOG_FILE_HDR_SIZE + OS_FILE_LOG_BLOCK_SIZE]; |
|
3528 |
byte* log_hdr_buf; |
|
3529 |
ulint err; |
|
3530 |
||
3531 |
ibool success; |
|
3532 |
||
94
by kinoyasu
Windows conscious experimental change |
3533 |
/* start back ground thread to copy newer log */
|
3534 |
os_thread_id_t log_copying_thread_id; |
|
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3535 |
datafiles_iter_t *it; |
94
by kinoyasu
Windows conscious experimental change |
3536 |
|
1
by kinoyasu
initial registration |
3537 |
log_hdr_buf = ut_align(log_hdr_buf_, OS_FILE_LOG_BLOCK_SIZE); |
3538 |
||
3539 |
/* log space */
|
|
2
by kinoyasu
The first usable version. |
3540 |
//space = UT_LIST_GET_NEXT(space_list, UT_LIST_GET_FIRST(system->space_list));
|
3541 |
//printf("space: name=%s, id=%d, purpose=%d, size=%d\n",
|
|
3542 |
// space->name, space->id, space->purpose, space->size);
|
|
1
by kinoyasu
initial registration |
3543 |
|
3544 |
/* get current checkpoint_lsn */
|
|
3545 |
/* Look for the latest checkpoint from any of the log groups */
|
|
194.1.1
by kinoyasu
change overtaken-check to the more exact method. |
3546 |
|
1
by kinoyasu
initial registration |
3547 |
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field); |
3548 |
||
3549 |
if (err != DB_SUCCESS) { |
|
3550 |
||
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3551 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3552 |
}
|
3553 |
||
3554 |
log_group_read_checkpoint_info(max_cp_group, max_cp_field); |
|
3555 |
buf = log_sys->checkpoint_buf; |
|
3556 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3557 |
checkpoint_lsn_start = MACH_READ_64(buf + LOG_CHECKPOINT_LSN); |
3558 |
checkpoint_no_start = MACH_READ_64(buf + LOG_CHECKPOINT_NO); |
|
1
by kinoyasu
initial registration |
3559 |
|
3560 |
reread_log_header: |
|
3561 |
fil_io(OS_FILE_READ | OS_FILE_LOG, TRUE, max_cp_group->space_id, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3562 |
#ifdef INNODB_VERSION_SHORT
|
3563 |
0, |
|
3564 |
#endif
|
|
1
by kinoyasu
initial registration |
3565 |
0, 0, LOG_FILE_HDR_SIZE, |
3566 |
log_hdr_buf, max_cp_group); |
|
3567 |
||
3568 |
/* check consistency of log file header to copy */
|
|
3569 |
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field); |
|
3570 |
||
3571 |
if (err != DB_SUCCESS) { |
|
3572 |
||
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3573 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3574 |
}
|
3575 |
||
3576 |
log_group_read_checkpoint_info(max_cp_group, max_cp_field); |
|
3577 |
buf = log_sys->checkpoint_buf; |
|
3578 |
||
3579 |
if(ut_dulint_cmp(checkpoint_no_start, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3580 |
MACH_READ_64(buf + LOG_CHECKPOINT_NO)) != 0) { |
3581 |
checkpoint_lsn_start = MACH_READ_64(buf + LOG_CHECKPOINT_LSN); |
|
3582 |
checkpoint_no_start = MACH_READ_64(buf + LOG_CHECKPOINT_NO); |
|
1
by kinoyasu
initial registration |
3583 |
goto reread_log_header; |
3584 |
}
|
|
3585 |
||
14
by kinoyasu
using rsync for incremental backup |
3586 |
if (!xtrabackup_stream) { |
3587 |
||
3588 |
/* open 'xtrabackup_logfile' */
|
|
3589 |
sprintf(dst_log_path, "%s%s", xtrabackup_target_dir, "/xtrabackup_logfile"); |
|
96
by kinoyasu
Windows conscious change more |
3590 |
srv_normalize_path_for_win(dst_log_path); |
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3591 |
/* os_file_create reads srv_unix_file_flush_method for OS_DATA_FILE*/
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
3592 |
dst_log = os_file_create( |
3593 |
#if (MYSQL_VERSION_ID > 50500)
|
|
3594 |
0 /* dummy of innodb_file_data_key */, |
|
3595 |
#endif
|
|
3596 |
dst_log_path, OS_FILE_CREATE, |
|
3597 |
OS_FILE_NORMAL, OS_DATA_FILE, &success); |
|
99
by kinoyasu
refix bug 435634 |
3598 |
|
1
by kinoyasu
initial registration |
3599 |
if (!success) { |
3600 |
/* The following call prints an error message */
|
|
3601 |
os_file_get_last_error(TRUE); |
|
3602 |
||
3603 |
fprintf(stderr, |
|
46
by kinoyasu
make restricted not to overwrite backup |
3604 |
"xtrabackup: error: cannot open %s\n", |
1
by kinoyasu
initial registration |
3605 |
dst_log_path); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3606 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3607 |
}
|
3608 |
||
52
by kinoyasu
add to use posix_fadvise() if possible |
3609 |
#ifdef USE_POSIX_FADVISE
|
3610 |
posix_fadvise(dst_log, 0, 0, POSIX_FADV_DONTNEED); |
|
3611 |
#endif
|
|
3612 |
||
14
by kinoyasu
using rsync for incremental backup |
3613 |
}
|
3614 |
||
2
by kinoyasu
The first usable version. |
3615 |
/* label it */
|
3616 |
strcpy((char*) log_hdr_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, |
|
3617 |
"xtrabkup "); |
|
3618 |
ut_sprintf_timestamp( |
|
3619 |
(char*) log_hdr_buf + (LOG_FILE_WAS_CREATED_BY_HOT_BACKUP |
|
3620 |
+ (sizeof "xtrabkup ") - 1)); |
|
3621 |
||
14
by kinoyasu
using rsync for incremental backup |
3622 |
if (!xtrabackup_stream) { |
3623 |
success = os_file_write(dst_log_path, dst_log, log_hdr_buf, |
|
3624 |
0, 0, LOG_FILE_HDR_SIZE); |
|
3625 |
} else { |
|
3626 |
/* Stream */
|
|
3627 |
if (write(fileno(stdout), log_hdr_buf, LOG_FILE_HDR_SIZE) |
|
3628 |
== LOG_FILE_HDR_SIZE) { |
|
3629 |
success = TRUE; |
|
3630 |
} else { |
|
3631 |
success = FALSE; |
|
3632 |
}
|
|
3633 |
}
|
|
3634 |
||
1
by kinoyasu
initial registration |
3635 |
log_copy_offset += LOG_FILE_HDR_SIZE; |
3636 |
if (!success) { |
|
62
by kinoyasu
fix simple mistakes |
3637 |
if (dst_log != -1) |
1
by kinoyasu
initial registration |
3638 |
os_file_close(dst_log); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3639 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3640 |
}
|
3641 |
||
3
by kinoyasu
planned options are implemented |
3642 |
/* start flag */
|
3643 |
log_copying = TRUE; |
|
3644 |
||
3645 |
/* start io throttle */
|
|
3646 |
if(xtrabackup_throttle) { |
|
3647 |
os_thread_id_t io_watching_thread_id; |
|
3648 |
||
3649 |
io_ticket = xtrabackup_throttle; |
|
3650 |
wait_throttle = os_event_create(NULL); |
|
3651 |
||
3652 |
os_thread_create(io_watching_thread, NULL, &io_watching_thread_id); |
|
3653 |
}
|
|
3654 |
||
3655 |
||
1
by kinoyasu
initial registration |
3656 |
/* copy log file by current position */
|
14
by kinoyasu
using rsync for incremental backup |
3657 |
if(xtrabackup_copy_logfile(checkpoint_lsn_start, FALSE)) |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3658 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3659 |
|
3660 |
||
3661 |
os_thread_create(log_copying_thread, NULL, &log_copying_thread_id); |
|
3662 |
||
3663 |
||
3664 |
||
14
by kinoyasu
using rsync for incremental backup |
3665 |
if (!xtrabackup_stream) { /* stream mode is transaction log only */ |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3666 |
uint i; |
3667 |
uint count; |
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3668 |
os_mutex_t count_mutex; |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3669 |
data_thread_ctxt_t *data_threads; |
3670 |
||
3671 |
ut_a(parallel > 0); |
|
3672 |
||
3673 |
if (parallel > 1) |
|
3674 |
printf("xtrabackup: Starting %u threads for parallel " |
|
3675 |
"data files transfer\n", parallel); |
|
3676 |
||
3677 |
it = datafiles_iter_new(system); |
|
3678 |
if (it == NULL) { |
|
3679 |
fprintf(stderr, |
|
3680 |
"xtrabackup: Error: "
|
|
3681 |
"datafiles_iter_new() failed.\n"); |
|
208
by Alexey Kopytov
Manual merge from lp:~percona-dev/percona-xtrabackup/exit_codes |
3682 |
exit(EXIT_FAILURE); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3683 |
}
|
3684 |
||
3685 |
/* Create data copying threads */
|
|
3686 |
ut_a(parallel > 0); |
|
3687 |
||
3688 |
data_threads = (data_thread_ctxt_t *) |
|
3689 |
ut_malloc(sizeof(data_thread_ctxt_t) * parallel); |
|
3690 |
count = parallel; |
|
200
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3691 |
count_mutex = OS_MUTEX_CREATE(); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3692 |
|
3693 |
for (i = 0; i < parallel; i++) { |
|
3694 |
data_threads[i].it = it; |
|
3695 |
data_threads[i].num = i+1; |
|
3696 |
data_threads[i].count = &count; |
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3697 |
data_threads[i].count_mutex = count_mutex; |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3698 |
os_thread_create(data_copy_thread_func, |
3699 |
data_threads + i, |
|
3700 |
&data_threads[i].id); |
|
3701 |
}
|
|
3702 |
||
3703 |
/* Wait for threads to exit */
|
|
3704 |
while (1) { |
|
3705 |
os_thread_sleep(1000000); |
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3706 |
os_mutex_enter(count_mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3707 |
if (count == 0) { |
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3708 |
os_mutex_exit(count_mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3709 |
break; |
3710 |
}
|
|
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3711 |
os_mutex_exit(count_mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3712 |
}
|
3713 |
/* NOTE: It may not needed at "--backup" for now */
|
|
3714 |
/* mutex_enter(&(system->mutex)); */
|
|
3715 |
||
199
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
3716 |
os_mutex_free(count_mutex); |
195
by Alexey Kopytov
Implementation of parallel data files transfer for xtrabackup. |
3717 |
datafiles_iter_free(it); |
1
by kinoyasu
initial registration |
3718 |
|
14
by kinoyasu
using rsync for incremental backup |
3719 |
} //if (!xtrabackup_stream) |
3720 |
||
1
by kinoyasu
initial registration |
3721 |
//mutex_exit(&(system->mutex));
|
3722 |
}
|
|
3723 |
||
3724 |
||
3
by kinoyasu
planned options are implemented |
3725 |
/* suspend-at-end */
|
3726 |
if (xtrabackup_suspend_at_end) { |
|
3727 |
os_file_t suspend_file = -1; |
|
3728 |
char suspend_path[FN_REFLEN]; |
|
3729 |
ibool success, exists; |
|
3730 |
os_file_type_t type; |
|
3731 |
||
3732 |
sprintf(suspend_path, "%s%s", xtrabackup_target_dir, |
|
3733 |
"/xtrabackup_suspended"); |
|
3734 |
||
96
by kinoyasu
Windows conscious change more |
3735 |
srv_normalize_path_for_win(suspend_path); |
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
3736 |
/* os_file_create reads srv_unix_file_flush_method */
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
3737 |
suspend_file = os_file_create( |
3738 |
#if (MYSQL_VERSION_ID > 50500)
|
|
3739 |
0 /* dummy of innodb_file_data_key */, |
|
3740 |
#endif
|
|
3741 |
suspend_path, OS_FILE_OVERWRITE, |
|
3742 |
OS_FILE_NORMAL, OS_DATA_FILE, &success); |
|
99
by kinoyasu
refix bug 435634 |
3743 |
|
3
by kinoyasu
planned options are implemented |
3744 |
if (!success) { |
45
by kinoyasu
messages are fixed a little |
3745 |
fprintf(stderr, "xtrabackup: Error: failed to create file 'xtrabackup_suspended'\n"); |
3
by kinoyasu
planned options are implemented |
3746 |
}
|
3747 |
||
62
by kinoyasu
fix simple mistakes |
3748 |
if (suspend_file != -1) |
3
by kinoyasu
planned options are implemented |
3749 |
os_file_close(suspend_file); |
3750 |
||
3751 |
exists = TRUE; |
|
3752 |
while (exists) { |
|
94
by kinoyasu
Windows conscious experimental change |
3753 |
os_thread_sleep(200000); /*0.2 sec*/ |
3
by kinoyasu
planned options are implemented |
3754 |
success = os_file_status(suspend_path, &exists, &type); |
3755 |
if (!success) |
|
3756 |
break; |
|
3757 |
}
|
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
3758 |
xtrabackup_suspend_at_end = FALSE; /* suspend is 1 time */ |
3
by kinoyasu
planned options are implemented |
3759 |
}
|
3760 |
||
33
by kinoyasu
primitive implementation of incremental backup |
3761 |
/* read the latest checkpoint lsn */
|
94
by kinoyasu
Windows conscious experimental change |
3762 |
latest_cp = ut_dulint_zero; |
33
by kinoyasu
primitive implementation of incremental backup |
3763 |
{
|
3764 |
log_group_t* max_cp_group; |
|
3765 |
ulint max_cp_field; |
|
3766 |
ulint err; |
|
3767 |
||
3768 |
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field); |
|
3769 |
||
3770 |
if (err != DB_SUCCESS) { |
|
45
by kinoyasu
messages are fixed a little |
3771 |
fprintf(stderr, "xtrabackup: Error: recv_find_max_checkpoint() failed.\n"); |
33
by kinoyasu
primitive implementation of incremental backup |
3772 |
goto skip_last_cp; |
3773 |
}
|
|
3774 |
||
3775 |
log_group_read_checkpoint_info(max_cp_group, max_cp_field); |
|
3776 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3777 |
latest_cp = MACH_READ_64(log_sys->checkpoint_buf + LOG_CHECKPOINT_LSN); |
33
by kinoyasu
primitive implementation of incremental backup |
3778 |
|
3779 |
if (!xtrabackup_stream) { |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3780 |
#ifndef INNODB_VERSION_SHORT
|
45
by kinoyasu
messages are fixed a little |
3781 |
printf("xtrabackup: The latest check point (for incremental): '%lu:%lu'\n", |
33
by kinoyasu
primitive implementation of incremental backup |
3782 |
latest_cp.high, latest_cp.low); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3783 |
#else
|
3784 |
printf("xtrabackup: The latest check point (for incremental): '%llu'\n", |
|
3785 |
latest_cp); |
|
3786 |
#endif
|
|
33
by kinoyasu
primitive implementation of incremental backup |
3787 |
} else { |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3788 |
#ifndef INNODB_VERSION_SHORT
|
45
by kinoyasu
messages are fixed a little |
3789 |
fprintf(stderr, "xtrabackup: The latest check point (for incremental): '%lu:%lu'\n", |
33
by kinoyasu
primitive implementation of incremental backup |
3790 |
latest_cp.high, latest_cp.low); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3791 |
#else
|
3792 |
fprintf(stderr, "xtrabackup: The latest check point (for incremental): '%llu'\n", |
|
3793 |
latest_cp); |
|
3794 |
#endif
|
|
33
by kinoyasu
primitive implementation of incremental backup |
3795 |
}
|
3796 |
}
|
|
3797 |
skip_last_cp: |
|
1
by kinoyasu
initial registration |
3798 |
/* stop log_copying_thread */
|
3799 |
log_copying = FALSE; |
|
11
by kinoyasu
fix tribials |
3800 |
if (!xtrabackup_stream) { |
45
by kinoyasu
messages are fixed a little |
3801 |
printf("xtrabackup: Stopping log copying thread"); |
11
by kinoyasu
fix tribials |
3802 |
while (log_copying_running) { |
3803 |
printf("."); |
|
94
by kinoyasu
Windows conscious experimental change |
3804 |
os_thread_sleep(200000); /*0.2 sec*/ |
11
by kinoyasu
fix tribials |
3805 |
}
|
3806 |
printf("\n"); |
|
14
by kinoyasu
using rsync for incremental backup |
3807 |
} else { |
3808 |
while (log_copying_running) |
|
94
by kinoyasu
Windows conscious experimental change |
3809 |
os_thread_sleep(200000); /*0.2 sec*/ |
1
by kinoyasu
initial registration |
3810 |
}
|
14
by kinoyasu
using rsync for incremental backup |
3811 |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
3812 |
/* output to metadata file */
|
3813 |
{
|
|
3814 |
char filename[FN_REFLEN]; |
|
3815 |
||
3816 |
if(!xtrabackup_incremental) { |
|
3817 |
strcpy(metadata_type, "full-backuped"); |
|
3818 |
metadata_from_lsn = ut_dulint_zero; |
|
3819 |
} else { |
|
3820 |
strcpy(metadata_type, "incremental"); |
|
3821 |
metadata_from_lsn = incremental_lsn; |
|
3822 |
}
|
|
3823 |
metadata_to_lsn = latest_cp; |
|
3824 |
metadata_last_lsn = log_copy_scanned_lsn; |
|
3825 |
||
3826 |
sprintf(filename, "%s/%s", xtrabackup_target_dir, XTRABACKUP_METADATA_FILENAME); |
|
3827 |
if (xtrabackup_write_metadata(filename)) |
|
3828 |
fprintf(stderr, "xtrabackup: error: xtrabackup_write_metadata(xtrabackup_target_dir)\n"); |
|
3829 |
||
3830 |
if(xtrabackup_extra_lsndir) { |
|
3831 |
sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, XTRABACKUP_METADATA_FILENAME); |
|
3832 |
if (xtrabackup_write_metadata(filename)) |
|
3833 |
fprintf(stderr, "xtrabackup: error: xtrabackup_write_metadata(xtrabackup_extra_lsndir)\n"); |
|
3834 |
}
|
|
3835 |
}
|
|
3836 |
||
1
by kinoyasu
initial registration |
3837 |
if (!log_copying_succeed) { |
45
by kinoyasu
messages are fixed a little |
3838 |
fprintf(stderr, "xtrabackup: Error: log_copying_thread failed.\n"); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
3839 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
3840 |
}
|
3841 |
||
14
by kinoyasu
using rsync for incremental backup |
3842 |
if (!xtrabackup_stream) |
3843 |
os_file_close(dst_log); |
|
1
by kinoyasu
initial registration |
3844 |
|
3
by kinoyasu
planned options are implemented |
3845 |
if (wait_throttle) |
3846 |
os_event_free(wait_throttle); |
|
3847 |
||
11
by kinoyasu
fix tribials |
3848 |
if (!xtrabackup_stream) { |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3849 |
#ifndef INNODB_VERSION_SHORT
|
45
by kinoyasu
messages are fixed a little |
3850 |
printf("xtrabackup: Transaction log of lsn (%lu %lu) to (%lu %lu) was copied.\n", |
11
by kinoyasu
fix tribials |
3851 |
checkpoint_lsn_start.high, checkpoint_lsn_start.low, |
3852 |
log_copy_scanned_lsn.high, log_copy_scanned_lsn.low); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3853 |
#else
|
3854 |
printf("xtrabackup: Transaction log of lsn (%llu) to (%llu) was copied.\n", |
|
3855 |
checkpoint_lsn_start, log_copy_scanned_lsn); |
|
3856 |
#endif
|
|
11
by kinoyasu
fix tribials |
3857 |
} else { |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3858 |
#ifndef INNODB_VERSION_SHORT
|
45
by kinoyasu
messages are fixed a little |
3859 |
fprintf(stderr, "xtrabackup: Transaction log of lsn (%lu %lu) to (%lu %lu) was copied.\n", |
11
by kinoyasu
fix tribials |
3860 |
checkpoint_lsn_start.high, checkpoint_lsn_start.low, |
3861 |
log_copy_scanned_lsn.high, log_copy_scanned_lsn.low); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3862 |
#else
|
3863 |
fprintf(stderr, "xtrabackup: Transaction log of lsn (%llu) to (%llu) was copied.\n", |
|
3864 |
checkpoint_lsn_start, log_copy_scanned_lsn); |
|
3865 |
#endif
|
|
182.1.2
by Baron Schwartz
Make it write the --extra-lsndir even in --log-stream mode |
3866 |
if(xtrabackup_extra_lsndir) { |
3867 |
char filename[FN_REFLEN]; |
|
3868 |
sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, XTRABACKUP_METADATA_FILENAME); |
|
3869 |
if (xtrabackup_write_metadata(filename)) |
|
3870 |
fprintf(stderr, "xtrabackup: error: xtrabackup_write_metadata(xtrabackup_extra_lsndir)\n"); |
|
3871 |
}
|
|
11
by kinoyasu
fix tribials |
3872 |
}
|
1
by kinoyasu
initial registration |
3873 |
}
|
3874 |
||
85
by kinoyasu
new option --stats to gather index stats |
3875 |
/* ================= stats ================= */
|
3876 |
my_bool
|
|
3877 |
xtrabackup_stats_level( |
|
3878 |
dict_index_t* index, |
|
3879 |
ulint level) |
|
3880 |
{
|
|
3881 |
ulint space; |
|
3882 |
page_t* page; |
|
3883 |
||
3884 |
rec_t* node_ptr; |
|
3885 |
||
3886 |
ulint right_page_no; |
|
3887 |
||
3888 |
page_cur_t cursor; |
|
3889 |
||
3890 |
mtr_t mtr; |
|
3891 |
mem_heap_t* heap = mem_heap_create(256); |
|
3892 |
||
3893 |
ulint* offsets = NULL; |
|
3894 |
||
3895 |
ulonglong n_pages, n_pages_extern; |
|
3896 |
ulonglong sum_data, sum_data_extern; |
|
3897 |
ulonglong n_recs; |
|
106.2.1
by akuzminsky
Fixed bug479665 |
3898 |
ulint page_size; |
85
by kinoyasu
new option --stats to gather index stats |
3899 |
|
3900 |
n_pages = sum_data = n_recs = 0; |
|
3901 |
n_pages_extern = sum_data_extern = 0; |
|
3902 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3903 |
#ifdef INNODB_VERSION_SHORT
|
3904 |
buf_block_t* block; |
|
3905 |
ulint zip_size; |
|
3906 |
#endif
|
|
3907 |
||
85
by kinoyasu
new option --stats to gather index stats |
3908 |
if (level == 0) |
3909 |
fprintf(stdout, " leaf pages: "); |
|
3910 |
else
|
|
3911 |
fprintf(stdout, " level %lu pages: ", level); |
|
3912 |
||
3913 |
mtr_start(&mtr); |
|
3914 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3915 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
3916 |
#if (MYSQL_VERSION_ID < 50100)
|
3917 |
mtr_x_lock(&(index->tree->lock), &mtr); |
|
3918 |
page = btr_root_get(index->tree, &mtr); |
|
3919 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
3920 |
mtr_x_lock(&(index->lock), &mtr); |
|
3921 |
page = btr_root_get(index, &mtr); |
|
3922 |
#endif
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3923 |
#else
|
3924 |
mtr_x_lock(&(index->lock), &mtr); |
|
3925 |
block = btr_root_block_get(index, &mtr); |
|
3926 |
page = buf_block_get_frame(block); |
|
3927 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
3928 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3929 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
3930 |
space = buf_frame_get_space_id(page); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3931 |
#else
|
3932 |
space = page_get_space_id(page); |
|
3933 |
zip_size = fil_space_get_zip_size(space); |
|
3934 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
3935 |
|
3936 |
while (level != btr_page_get_level(page, &mtr)) { |
|
3937 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3938 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
3939 |
ut_a(btr_page_get_level(page, &mtr) > 0); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3940 |
#else
|
3941 |
ut_a(space == buf_block_get_space(block)); |
|
3942 |
ut_a(space == page_get_space_id(page)); |
|
3943 |
ut_a(!page_is_leaf(page)); |
|
3944 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
3945 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3946 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
3947 |
page_cur_set_before_first(page, &cursor); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3948 |
#else
|
3949 |
page_cur_set_before_first(block, &cursor); |
|
3950 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
3951 |
page_cur_move_to_next(&cursor); |
3952 |
||
3953 |
node_ptr = page_cur_get_rec(&cursor); |
|
3954 |
offsets = rec_get_offsets(node_ptr, index, offsets, |
|
3955 |
ULINT_UNDEFINED, &heap); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
3956 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
3957 |
page = btr_node_ptr_get_child(node_ptr, offsets, &mtr); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3958 |
#else
|
3959 |
block = btr_node_ptr_get_child(node_ptr, index, offsets, &mtr); |
|
3960 |
page = buf_block_get_frame(block); |
|
3961 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
3962 |
}
|
3963 |
||
3964 |
loop: |
|
3965 |
mem_heap_empty(heap); |
|
3966 |
offsets = NULL; |
|
3967 |
#if (MYSQL_VERSION_ID < 50100)
|
|
3968 |
mtr_x_lock(&(index->tree->lock), &mtr); |
|
3969 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
3970 |
mtr_x_lock(&(index->lock), &mtr); |
|
3971 |
#endif
|
|
3972 |
||
3973 |
right_page_no = btr_page_get_next(page, &mtr); |
|
3974 |
||
3975 |
||
3976 |
/*=================================*/
|
|
3977 |
//fprintf(stdout, "%lu ", (ulint) buf_frame_get_page_no(page));
|
|
3978 |
||
3979 |
n_pages++; |
|
3980 |
sum_data += page_get_data_size(page); |
|
3981 |
n_recs += page_get_n_recs(page); |
|
3982 |
||
3983 |
||
3984 |
if (level == 0) { |
|
3985 |
page_cur_t cur; |
|
3986 |
ulint n_fields; |
|
3987 |
ulint i; |
|
3988 |
mem_heap_t* heap = NULL; |
|
3989 |
ulint offsets_[REC_OFFS_NORMAL_SIZE]; |
|
3990 |
ulint* offsets = offsets_; |
|
3991 |
||
3992 |
*offsets_ = (sizeof offsets_) / sizeof *offsets_; |
|
3993 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
3994 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
3995 |
page_cur_set_before_first(page, &cur); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
3996 |
#else
|
3997 |
page_cur_set_before_first(block, &cur); |
|
3998 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
3999 |
page_cur_move_to_next(&cur); |
4000 |
||
4001 |
for (;;) { |
|
4002 |
if (page_cur_is_after_last(&cur)) { |
|
4003 |
break; |
|
4004 |
}
|
|
4005 |
||
4006 |
offsets = rec_get_offsets(cur.rec, index, offsets, |
|
4007 |
ULINT_UNDEFINED, &heap); |
|
4008 |
n_fields = rec_offs_n_fields(offsets); |
|
4009 |
||
4010 |
for (i = 0; i < n_fields; i++) { |
|
4011 |
if (rec_offs_nth_extern(offsets, i)) { |
|
4012 |
page_t* page; |
|
4013 |
ulint space_id; |
|
4014 |
ulint page_no; |
|
4015 |
ulint offset; |
|
4016 |
ulint extern_len; |
|
4017 |
byte* blob_header; |
|
4018 |
ulint part_len; |
|
4019 |
mtr_t mtr; |
|
4020 |
ulint local_len; |
|
4021 |
byte* data; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4022 |
#ifdef INNODB_VERSION_SHORT
|
4023 |
buf_block_t* block; |
|
4024 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
4025 |
|
4026 |
data = rec_get_nth_field(cur.rec, offsets, i, &local_len); |
|
4027 |
||
4028 |
ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); |
|
4029 |
local_len -= BTR_EXTERN_FIELD_REF_SIZE; |
|
4030 |
||
4031 |
space_id = mach_read_from_4(data + local_len + BTR_EXTERN_SPACE_ID); |
|
4032 |
page_no = mach_read_from_4(data + local_len + BTR_EXTERN_PAGE_NO); |
|
4033 |
offset = mach_read_from_4(data + local_len + BTR_EXTERN_OFFSET); |
|
4034 |
extern_len = mach_read_from_4(data + local_len + BTR_EXTERN_LEN + 4); |
|
4035 |
||
4036 |
if (offset != FIL_PAGE_DATA) |
|
4037 |
fprintf(stderr, "\nWarning: several record may share same external page.\n"); |
|
4038 |
||
4039 |
for (;;) { |
|
4040 |
mtr_start(&mtr); |
|
4041 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
4042 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
4043 |
page = buf_page_get(space_id, page_no, RW_S_LATCH, &mtr); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
4044 |
#else
|
4045 |
block = btr_block_get(space_id, zip_size, page_no, RW_S_LATCH, &mtr); |
|
4046 |
page = buf_block_get_frame(block); |
|
4047 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
4048 |
blob_header = page + offset; |
4049 |
#define BTR_BLOB_HDR_PART_LEN 0
|
|
4050 |
#define BTR_BLOB_HDR_NEXT_PAGE_NO 4
|
|
4051 |
//part_len = btr_blob_get_part_len(blob_header);
|
|
4052 |
part_len = mach_read_from_4(blob_header + BTR_BLOB_HDR_PART_LEN); |
|
4053 |
||
4054 |
//page_no = btr_blob_get_next_page_no(blob_header);
|
|
4055 |
page_no = mach_read_from_4(blob_header + BTR_BLOB_HDR_NEXT_PAGE_NO); |
|
4056 |
||
4057 |
offset = FIL_PAGE_DATA; |
|
4058 |
||
4059 |
||
4060 |
||
4061 |
||
4062 |
/*=================================*/
|
|
4063 |
//fprintf(stdout, "[%lu] ", (ulint) buf_frame_get_page_no(page));
|
|
4064 |
||
4065 |
n_pages_extern++; |
|
4066 |
sum_data_extern += part_len; |
|
4067 |
||
4068 |
||
4069 |
mtr_commit(&mtr); |
|
4070 |
||
4071 |
if (page_no == FIL_NULL) |
|
4072 |
break; |
|
4073 |
}
|
|
4074 |
}
|
|
4075 |
}
|
|
4076 |
||
4077 |
page_cur_move_to_next(&cur); |
|
4078 |
}
|
|
4079 |
}
|
|
4080 |
||
4081 |
||
4082 |
||
4083 |
||
4084 |
mtr_commit(&mtr); |
|
4085 |
if (right_page_no != FIL_NULL) { |
|
4086 |
mtr_start(&mtr); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4087 |
#ifndef INNODB_VERSION_SHORT
|
85
by kinoyasu
new option --stats to gather index stats |
4088 |
page = btr_page_get(space, right_page_no, RW_X_LATCH, &mtr); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
4089 |
#else
|
4090 |
block = btr_block_get(space, zip_size, right_page_no, RW_X_LATCH, &mtr); |
|
4091 |
page = buf_block_get_frame(block); |
|
4092 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
4093 |
goto loop; |
4094 |
}
|
|
4095 |
mem_heap_free(heap); |
|
4096 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
4097 |
#ifndef INNODB_VERSION_SHORT
|
4098 |
page_size = UNIV_PAGE_SIZE; |
|
4099 |
#else
|
|
4100 |
if (zip_size) { |
|
4101 |
page_size = zip_size; |
|
4102 |
} else { |
|
4103 |
page_size = UNIV_PAGE_SIZE; |
|
4104 |
}
|
|
4105 |
#endif
|
|
4106 |
||
85
by kinoyasu
new option --stats to gather index stats |
4107 |
if (level == 0) |
4108 |
fprintf(stdout, "recs=%lld, ", n_recs); |
|
4109 |
||
86
by kinoyasu
fix misc |
4110 |
fprintf(stdout, "pages=%lld, data=%lld bytes, data/pages=%lld%%", |
85
by kinoyasu
new option --stats to gather index stats |
4111 |
n_pages, sum_data, |
100
by kinoyasu
initial implementation for InnoDB Plugin |
4112 |
((sum_data * 100)/ page_size)/n_pages); |
85
by kinoyasu
new option --stats to gather index stats |
4113 |
|
4114 |
||
4115 |
if (level == 0 && n_pages_extern) { |
|
4116 |
putc('\n', stdout); |
|
4117 |
/* also scan blob pages*/
|
|
86
by kinoyasu
fix misc |
4118 |
fprintf(stdout, " external pages: "); |
85
by kinoyasu
new option --stats to gather index stats |
4119 |
|
86
by kinoyasu
fix misc |
4120 |
fprintf(stdout, "pages=%lld, data=%lld bytes, data/pages=%lld%%", |
85
by kinoyasu
new option --stats to gather index stats |
4121 |
n_pages_extern, sum_data_extern, |
100
by kinoyasu
initial implementation for InnoDB Plugin |
4122 |
((sum_data_extern * 100)/ page_size)/n_pages_extern); |
85
by kinoyasu
new option --stats to gather index stats |
4123 |
}
|
4124 |
||
4125 |
putc('\n', stdout); |
|
4126 |
||
4127 |
if (level > 0) { |
|
4128 |
xtrabackup_stats_level(index, level - 1); |
|
4129 |
}
|
|
4130 |
||
4131 |
return(TRUE); |
|
4132 |
}
|
|
4133 |
||
4134 |
void
|
|
4135 |
xtrabackup_stats_func(void) |
|
4136 |
{
|
|
4137 |
/* cd to datadir */
|
|
4138 |
||
4139 |
if (my_setwd(mysql_real_data_home,MYF(MY_WME))) |
|
4140 |
{
|
|
4141 |
fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", mysql_real_data_home); |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
4142 |
exit(EXIT_FAILURE); |
85
by kinoyasu
new option --stats to gather index stats |
4143 |
}
|
4144 |
fprintf(stderr, "xtrabackup: cd to %s\n", mysql_real_data_home); |
|
4145 |
||
4146 |
mysql_data_home= mysql_data_home_buff; |
|
4147 |
mysql_data_home[0]=FN_CURLIB; // all paths are relative from here |
|
4148 |
mysql_data_home[1]=0; |
|
4149 |
||
4150 |
/* set read only */
|
|
4151 |
srv_read_only = TRUE; |
|
88
by kinoyasu
fix fatal bug at --backup when added --stats |
4152 |
srv_fake_write = TRUE; |
85
by kinoyasu
new option --stats to gather index stats |
4153 |
|
4154 |
/* initialize components */
|
|
4155 |
if(innodb_init_param()) |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
4156 |
exit(EXIT_FAILURE); |
85
by kinoyasu
new option --stats to gather index stats |
4157 |
|
4158 |
fprintf(stderr, "xtrabackup: Starting 'read-only' InnoDB instance to gather index statistics.\n" |
|
4159 |
"xtrabackup: Using %lld bytes for buffer pool (set by --use-memory parameter)\n", |
|
4160 |
xtrabackup_use_memory); |
|
4161 |
||
4162 |
if(innodb_init()) |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
4163 |
exit(EXIT_FAILURE); |
85
by kinoyasu
new option --stats to gather index stats |
4164 |
|
4165 |
fprintf(stdout, "\n\n<INDEX STATISTICS>\n"); |
|
4166 |
||
4167 |
/* gather stats */
|
|
4168 |
||
4169 |
{
|
|
4170 |
dict_table_t* sys_tables; |
|
4171 |
dict_index_t* sys_index; |
|
4172 |
dict_table_t* table; |
|
4173 |
btr_pcur_t pcur; |
|
4174 |
rec_t* rec; |
|
4175 |
byte* field; |
|
4176 |
ulint len; |
|
4177 |
mtr_t mtr; |
|
4178 |
||
4179 |
/* Enlarge the fatal semaphore wait timeout during the InnoDB table
|
|
4180 |
monitor printout */
|
|
4181 |
||
4182 |
mutex_enter(&kernel_mutex); |
|
4183 |
srv_fatal_semaphore_wait_threshold += 72000; /* 20 hours */ |
|
4184 |
mutex_exit(&kernel_mutex); |
|
4185 |
||
4186 |
mutex_enter(&(dict_sys->mutex)); |
|
4187 |
||
4188 |
mtr_start(&mtr); |
|
4189 |
||
4190 |
sys_tables = dict_table_get_low("SYS_TABLES"); |
|
4191 |
sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); |
|
4192 |
||
4193 |
btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur, |
|
4194 |
TRUE, &mtr); |
|
4195 |
loop: |
|
4196 |
btr_pcur_move_to_next_user_rec(&pcur, &mtr); |
|
4197 |
||
4198 |
rec = btr_pcur_get_rec(&pcur); |
|
4199 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
4200 |
#ifndef INNODB_VERSION_SHORT
|
4201 |
if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) |
|
4202 |
#else
|
|
4203 |
if (!btr_pcur_is_on_user_rec(&pcur)) |
|
4204 |
#endif
|
|
4205 |
{
|
|
85
by kinoyasu
new option --stats to gather index stats |
4206 |
/* end of index */
|
4207 |
||
4208 |
btr_pcur_close(&pcur); |
|
4209 |
mtr_commit(&mtr); |
|
4210 |
||
4211 |
mutex_exit(&(dict_sys->mutex)); |
|
4212 |
||
4213 |
/* Restore the fatal semaphore wait timeout */
|
|
4214 |
||
4215 |
mutex_enter(&kernel_mutex); |
|
4216 |
srv_fatal_semaphore_wait_threshold -= 72000; /* 20 hours */ |
|
4217 |
mutex_exit(&kernel_mutex); |
|
4218 |
||
4219 |
goto end; |
|
4220 |
}
|
|
4221 |
||
4222 |
field = rec_get_nth_field_old(rec, 0, &len); |
|
4223 |
||
4224 |
#if (MYSQL_VERSION_ID < 50100)
|
|
4225 |
if (!rec_get_deleted_flag(rec, sys_tables->comp)) |
|
4226 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
4227 |
if (!rec_get_deleted_flag(rec, 0)) |
|
4228 |
#endif
|
|
4229 |
{
|
|
4230 |
||
4231 |
/* We found one */
|
|
4232 |
||
4233 |
char* table_name = mem_strdupl((char*) field, len); |
|
4234 |
||
4235 |
btr_pcur_store_position(&pcur, &mtr); |
|
4236 |
||
4237 |
mtr_commit(&mtr); |
|
4238 |
||
4239 |
table = dict_table_get_low(table_name); |
|
4240 |
mem_free(table_name); |
|
4241 |
||
4242 |
||
4243 |
if (xtrabackup_tables) { |
|
4244 |
char *p; |
|
4245 |
int regres; |
|
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
4246 |
int i; |
85
by kinoyasu
new option --stats to gather index stats |
4247 |
|
96
by kinoyasu
Windows conscious change more |
4248 |
p = strstr(table->name, SRV_PATH_SEPARATOR_STR); |
85
by kinoyasu
new option --stats to gather index stats |
4249 |
|
4250 |
if (p) |
|
4251 |
*p = '.'; |
|
4252 |
||
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
4253 |
for (i = 0; i < tables_regex_num; i++) { |
4254 |
regres = regexec(&tables_regex[i], table->name, 1, tables_regmatch, 0); |
|
4255 |
if (regres != REG_NOMATCH) |
|
4256 |
break; |
|
4257 |
}
|
|
85
by kinoyasu
new option --stats to gather index stats |
4258 |
|
4259 |
if (p) |
|
96
by kinoyasu
Windows conscious change more |
4260 |
*p = SRV_PATH_SEPARATOR; |
85
by kinoyasu
new option --stats to gather index stats |
4261 |
|
4262 |
if ( regres == REG_NOMATCH ) |
|
4263 |
goto skip; |
|
4264 |
}
|
|
4265 |
||
158
by kinoyasu
new option --tables_file is added |
4266 |
if (xtrabackup_tables_file) { |
4267 |
xtrabackup_tables_t* xtable; |
|
4268 |
||
4269 |
HASH_SEARCH(name_hash, tables_hash, ut_fold_string(table->name), |
|
159
by kinoyasu
recover 5.1 builtin base version support, and remove unused or obsolete patches |
4270 |
#ifdef INNODB_VERSION_SHORT
|
4271 |
xtrabackup_tables_t*, |
|
4272 |
#endif
|
|
4273 |
xtable, |
|
4274 |
#ifdef INNODB_VERSION_SHORT
|
|
4275 |
ut_ad(xtable->name), |
|
4276 |
#endif
|
|
158
by kinoyasu
new option --tables_file is added |
4277 |
!strcmp(xtable->name, table->name)); |
4278 |
||
4279 |
if (!xtable) |
|
4280 |
goto skip; |
|
4281 |
}
|
|
4282 |
||
85
by kinoyasu
new option --stats to gather index stats |
4283 |
|
4284 |
if (table == NULL) { |
|
4285 |
fputs("InnoDB: Failed to load table ", stderr); |
|
4286 |
#if (MYSQL_VERSION_ID < 50100)
|
|
4287 |
ut_print_namel(stderr, NULL, (char*) field, len); |
|
4288 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
4289 |
ut_print_namel(stderr, NULL, TRUE, (char*) field, len); |
|
4290 |
#endif
|
|
4291 |
putc('\n', stderr); |
|
4292 |
} else { |
|
94
by kinoyasu
Windows conscious experimental change |
4293 |
dict_index_t* index; |
4294 |
||
85
by kinoyasu
new option --stats to gather index stats |
4295 |
/* The table definition was corrupt if there
|
4296 |
is no index */
|
|
4297 |
||
4298 |
if (dict_table_get_first_index(table)) { |
|
200
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
4299 |
#ifdef XTRADB_BASED
|
4300 |
dict_update_statistics_low(table, TRUE, FALSE); |
|
206.1.1
by Ignacio Nin
Compile against 5.5.8 |
4301 |
#elif MYSQL_VERSION_ID >= 50508
|
4302 |
dict_update_statistics(table, TRUE); |
|
200
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
4303 |
#else
|
85
by kinoyasu
new option --stats to gather index stats |
4304 |
dict_update_statistics_low(table, TRUE); |
200
by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5 |
4305 |
#endif
|
85
by kinoyasu
new option --stats to gather index stats |
4306 |
}
|
4307 |
||
4308 |
//dict_table_print_low(table);
|
|
4309 |
||
4310 |
index = UT_LIST_GET_FIRST(table->indexes); |
|
4311 |
while (index != NULL) { |
|
4312 |
{
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4313 |
IB_INT64 n_vals; |
85
by kinoyasu
new option --stats to gather index stats |
4314 |
|
4315 |
if (index->n_user_defined_cols > 0) { |
|
4316 |
n_vals = index->stat_n_diff_key_vals[ |
|
4317 |
index->n_user_defined_cols]; |
|
4318 |
} else { |
|
4319 |
n_vals = index->stat_n_diff_key_vals[1]; |
|
4320 |
}
|
|
4321 |
||
4322 |
fprintf(stdout, |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4323 |
" table: %s, index: %s, space id: %lu, root page: %lu"
|
4324 |
#ifdef INNODB_VERSION_SHORT
|
|
4325 |
", zip size: %lu"
|
|
4326 |
#endif
|
|
4327 |
"\n estimated statistics in dictionary:\n" |
|
4328 |
" key vals: %lu, leaf pages: %lu, size pages: %lu\n" |
|
85
by kinoyasu
new option --stats to gather index stats |
4329 |
" real statistics:\n", |
4330 |
table->name, index->name, |
|
4331 |
(ulong) index->space, |
|
4332 |
#if (MYSQL_VERSION_ID < 50100)
|
|
4333 |
(ulong) index->tree->page, |
|
4334 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
4335 |
(ulong) index->page, |
|
4336 |
#endif
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4337 |
#ifdef INNODB_VERSION_SHORT
|
4338 |
(ulong) fil_space_get_zip_size(index->space), |
|
4339 |
#endif
|
|
85
by kinoyasu
new option --stats to gather index stats |
4340 |
(ulong) n_vals, |
4341 |
(ulong) index->stat_n_leaf_pages, |
|
4342 |
(ulong) index->stat_index_size); |
|
4343 |
||
4344 |
{
|
|
4345 |
mtr_t mtr; |
|
4346 |
page_t* root; |
|
4347 |
ulint n; |
|
4348 |
||
4349 |
mtr_start(&mtr); |
|
4350 |
||
4351 |
#if (MYSQL_VERSION_ID < 50100)
|
|
4352 |
mtr_x_lock(&(index->tree->lock), &mtr); |
|
4353 |
root = btr_root_get(index->tree, &mtr); |
|
4354 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
4355 |
mtr_x_lock(&(index->lock), &mtr); |
|
4356 |
root = btr_root_get(index, &mtr); |
|
4357 |
#endif
|
|
4358 |
n = btr_page_get_level(root, &mtr); |
|
4359 |
||
4360 |
xtrabackup_stats_level(index, n); |
|
4361 |
||
4362 |
mtr_commit(&mtr); |
|
4363 |
}
|
|
4364 |
||
4365 |
putc('\n', stdout); |
|
4366 |
}
|
|
4367 |
index = UT_LIST_GET_NEXT(indexes, index); |
|
4368 |
}
|
|
4369 |
}
|
|
4370 |
||
4371 |
skip: |
|
4372 |
mtr_start(&mtr); |
|
4373 |
||
4374 |
btr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr); |
|
4375 |
}
|
|
4376 |
||
4377 |
goto loop; |
|
4378 |
}
|
|
4379 |
||
4380 |
end: |
|
4381 |
putc('\n', stdout); |
|
4382 |
||
4383 |
/* shutdown InnoDB */
|
|
4384 |
if(innodb_end()) |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
4385 |
exit(EXIT_FAILURE); |
85
by kinoyasu
new option --stats to gather index stats |
4386 |
}
|
4387 |
||
1
by kinoyasu
initial registration |
4388 |
/* ================= prepare ================= */
|
4389 |
||
18
by kinoyasu
supporting MySQL 5.1 |
4390 |
my_bool
|
2
by kinoyasu
The first usable version. |
4391 |
xtrabackup_init_temp_log(void) |
4392 |
{
|
|
4393 |
os_file_t src_file = -1; |
|
4394 |
char src_path[FN_REFLEN]; |
|
4395 |
char dst_path[FN_REFLEN]; |
|
4396 |
ibool success; |
|
4397 |
||
4398 |
ulint field; |
|
4399 |
byte* log_buf; |
|
4400 |
byte* log_buf_ = NULL; |
|
4401 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
4402 |
IB_INT64 file_size; |
2
by kinoyasu
The first usable version. |
4403 |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4404 |
LSN64 max_no; |
4405 |
LSN64 max_lsn; |
|
2
by kinoyasu
The first usable version. |
4406 |
ulint max_field; |
100
by kinoyasu
initial implementation for InnoDB Plugin |
4407 |
LSN64 checkpoint_no; |
2
by kinoyasu
The first usable version. |
4408 |
|
94
by kinoyasu
Windows conscious experimental change |
4409 |
ulint fold; |
2
by kinoyasu
The first usable version. |
4410 |
|
4411 |
max_no = ut_dulint_zero; |
|
4412 |
||
34
by kinoyasu
more user-friendly incremental backup |
4413 |
if(!xtrabackup_incremental_dir) { |
4414 |
sprintf(dst_path, "%s%s", xtrabackup_target_dir, "/ib_logfile0"); |
|
4415 |
sprintf(src_path, "%s%s", xtrabackup_target_dir, "/xtrabackup_logfile"); |
|
4416 |
} else { |
|
4417 |
sprintf(dst_path, "%s%s", xtrabackup_incremental_dir, "/ib_logfile0"); |
|
4418 |
sprintf(src_path, "%s%s", xtrabackup_incremental_dir, "/xtrabackup_logfile"); |
|
4419 |
}
|
|
2
by kinoyasu
The first usable version. |
4420 |
|
96
by kinoyasu
Windows conscious change more |
4421 |
srv_normalize_path_for_win(dst_path); |
4422 |
srv_normalize_path_for_win(src_path); |
|
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
4423 |
retry: |
2
by kinoyasu
The first usable version. |
4424 |
src_file = os_file_create_simple_no_error_handling( |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
4425 |
#if (MYSQL_VERSION_ID > 50500)
|
4426 |
0 /* dummy of innodb_file_data_key */, |
|
4427 |
#endif
|
|
2
by kinoyasu
The first usable version. |
4428 |
src_path, OS_FILE_OPEN, |
4429 |
OS_FILE_READ_WRITE /* OS_FILE_READ_ONLY */, &success); |
|
4430 |
if (!success) { |
|
4431 |
/* The following call prints an error message */
|
|
4432 |
os_file_get_last_error(TRUE); |
|
4433 |
||
4434 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
4435 |
"xtrabackup: Warning: cannot open %s. will try to find.\n", |
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
4436 |
src_path); |
4437 |
||
4438 |
/* check if ib_logfile0 may be xtrabackup_logfile */
|
|
4439 |
src_file = os_file_create_simple_no_error_handling( |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
4440 |
#if (MYSQL_VERSION_ID > 50500)
|
4441 |
0 /* dummy of innodb_file_data_key */, |
|
4442 |
#endif
|
|
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
4443 |
dst_path, OS_FILE_OPEN, |
4444 |
OS_FILE_READ_WRITE /* OS_FILE_READ_ONLY */, &success); |
|
4445 |
if (!success) { |
|
4446 |
os_file_get_last_error(TRUE); |
|
4447 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
4448 |
" xtrabackup: Fatal error: cannot find %s.\n", |
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
4449 |
src_path); |
4450 |
||
4451 |
goto error; |
|
4452 |
}
|
|
4453 |
||
4454 |
log_buf_ = ut_malloc(LOG_FILE_HDR_SIZE * 2); |
|
4455 |
log_buf = ut_align(log_buf_, LOG_FILE_HDR_SIZE); |
|
4456 |
||
4457 |
success = os_file_read(src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE); |
|
4458 |
if (!success) { |
|
4459 |
goto error; |
|
4460 |
}
|
|
4461 |
||
4462 |
if ( ut_memcmp(log_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, |
|
4463 |
(byte*)"xtrabkup", (sizeof "xtrabkup") - 1) == 0) { |
|
4464 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
4465 |
" xtrabackup: 'ib_logfile0' seems to be 'xtrabackup_logfile'. will retry.\n"); |
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
4466 |
|
4467 |
ut_free(log_buf_); |
|
4468 |
log_buf_ = NULL; |
|
4469 |
||
4470 |
os_file_close(src_file); |
|
4471 |
src_file = -1; |
|
4472 |
||
4473 |
/* rename and try again */
|
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
4474 |
success = os_file_rename( |
4475 |
#if (MYSQL_VERSION_ID > 50500)
|
|
4476 |
0 /* dummy of innodb_file_data_key */, |
|
4477 |
#endif
|
|
4478 |
dst_path, src_path); |
|
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
4479 |
if (!success) { |
4480 |
goto error; |
|
4481 |
}
|
|
4482 |
||
4483 |
goto retry; |
|
4484 |
}
|
|
4485 |
||
4486 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
4487 |
" xtrabackup: Fatal error: cannot find %s.\n", |
13
by kinoyasu
fix handling of xtrabackup_logfile not found |
4488 |
src_path); |
4489 |
||
4490 |
ut_free(log_buf_); |
|
4491 |
log_buf_ = NULL; |
|
4492 |
||
4493 |
os_file_close(src_file); |
|
4494 |
src_file = -1; |
|
4495 |
||
2
by kinoyasu
The first usable version. |
4496 |
goto error; |
4497 |
}
|
|
4498 |
||
52
by kinoyasu
add to use posix_fadvise() if possible |
4499 |
#ifdef USE_POSIX_FADVISE
|
4500 |
posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL); |
|
4501 |
posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED); |
|
4502 |
#endif
|
|
4503 |
||
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
4504 |
if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { |
4505 |
os_file_set_nocache(src_file, src_path, "OPEN"); |
|
4506 |
}
|
|
4507 |
||
2
by kinoyasu
The first usable version. |
4508 |
file_size = os_file_get_size_as_iblonglong(src_file); |
4509 |
||
4510 |
||
4511 |
/* TODO: We should skip the following modifies, if it is not the first time. */
|
|
35
by kinoyasu
fix somebugs: bug 339013, bug 352742 |
4512 |
log_buf_ = ut_malloc(UNIV_PAGE_SIZE * 129); |
2
by kinoyasu
The first usable version. |
4513 |
log_buf = ut_align(log_buf_, UNIV_PAGE_SIZE); |
4514 |
||
4515 |
/* read log file header */
|
|
4516 |
success = os_file_read(src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE); |
|
4517 |
if (!success) { |
|
4518 |
goto error; |
|
4519 |
}
|
|
4520 |
||
4521 |
if ( ut_memcmp(log_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, |
|
4522 |
(byte*)"xtrabkup", (sizeof "xtrabkup") - 1) != 0 ) { |
|
45
by kinoyasu
messages are fixed a little |
4523 |
printf("xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.\n"); |
2
by kinoyasu
The first usable version. |
4524 |
goto skip_modify; |
4525 |
} else { |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
4526 |
/* clear it later */
|
4527 |
//memset(log_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP,
|
|
4528 |
// ' ', 4);
|
|
2
by kinoyasu
The first usable version. |
4529 |
}
|
4530 |
||
4531 |
/* read last checkpoint lsn */
|
|
4532 |
for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; |
|
4533 |
field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { |
|
4534 |
if (!recv_check_cp_is_consistent(log_buf + field)) |
|
4535 |
goto not_consistent; |
|
4536 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
4537 |
checkpoint_no = MACH_READ_64(log_buf + field + LOG_CHECKPOINT_NO); |
2
by kinoyasu
The first usable version. |
4538 |
|
4539 |
if (ut_dulint_cmp(checkpoint_no, max_no) >= 0) { |
|
4540 |
max_no = checkpoint_no; |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4541 |
max_lsn = MACH_READ_64(log_buf + field + LOG_CHECKPOINT_LSN); |
2
by kinoyasu
The first usable version. |
4542 |
max_field = field; |
4543 |
/*
|
|
4544 |
mach_write_to_4(log_buf + field + LOG_CHECKPOINT_OFFSET,
|
|
4545 |
LOG_FILE_HDR_SIZE + ut_dulint_minus(max_lsn,
|
|
4546 |
ut_dulint_align_down(max_lsn,OS_FILE_LOG_BLOCK_SIZE)));
|
|
4547 |
||
4548 |
ulint fold;
|
|
4549 |
fold = ut_fold_binary(log_buf + field, LOG_CHECKPOINT_CHECKSUM_1);
|
|
4550 |
mach_write_to_4(log_buf + field + LOG_CHECKPOINT_CHECKSUM_1, fold);
|
|
4551 |
||
4552 |
fold = ut_fold_binary(log_buf + field + LOG_CHECKPOINT_LSN,
|
|
4553 |
LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN);
|
|
4554 |
mach_write_to_4(log_buf + field + LOG_CHECKPOINT_CHECKSUM_2, fold);
|
|
4555 |
*/
|
|
4556 |
}
|
|
4557 |
not_consistent: |
|
4558 |
;
|
|
4559 |
}
|
|
4560 |
||
4561 |
if (ut_dulint_cmp(max_no, ut_dulint_zero) == 0) { |
|
45
by kinoyasu
messages are fixed a little |
4562 |
fprintf(stderr, "xtrabackup: No valid checkpoint found.\n"); |
2
by kinoyasu
The first usable version. |
4563 |
goto error; |
4564 |
}
|
|
4565 |
||
4566 |
||
4567 |
/* It seems to be needed to overwrite the both checkpoint area. */
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
4568 |
MACH_WRITE_64(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_LSN, max_lsn); |
2
by kinoyasu
The first usable version. |
4569 |
mach_write_to_4(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_OFFSET, |
4570 |
LOG_FILE_HDR_SIZE + ut_dulint_minus(max_lsn, |
|
4571 |
ut_dulint_align_down(max_lsn,OS_FILE_LOG_BLOCK_SIZE))); |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
4572 |
#ifdef XTRADB_BASED
|
4573 |
MACH_WRITE_64(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_ARCHIVED_LSN, |
|
4574 |
(ib_uint64_t)(LOG_FILE_HDR_SIZE + ut_dulint_minus(max_lsn, |
|
4575 |
ut_dulint_align_down(max_lsn,OS_FILE_LOG_BLOCK_SIZE)))); |
|
4576 |
#endif
|
|
2
by kinoyasu
The first usable version. |
4577 |
fold = ut_fold_binary(log_buf + LOG_CHECKPOINT_1, LOG_CHECKPOINT_CHECKSUM_1); |
4578 |
mach_write_to_4(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_CHECKSUM_1, fold); |
|
4579 |
||
4580 |
fold = ut_fold_binary(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_LSN, |
|
4581 |
LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); |
|
4582 |
mach_write_to_4(log_buf + LOG_CHECKPOINT_1 + LOG_CHECKPOINT_CHECKSUM_2, fold); |
|
4583 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
4584 |
MACH_WRITE_64(log_buf + LOG_CHECKPOINT_2 + LOG_CHECKPOINT_LSN, max_lsn); |
2
by kinoyasu
The first usable version. |
4585 |
mach_write_to_4(log_buf + LOG_CHECKPOINT_2 + LOG_CHECKPOINT_OFFSET, |
4586 |
LOG_FILE_HDR_SIZE + ut_dulint_minus(max_lsn, |
|
4587 |
ut_dulint_align_down(max_lsn,OS_FILE_LOG_BLOCK_SIZE))); |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
4588 |
#ifdef XTRADB_BASED
|
4589 |
MACH_WRITE_64(log_buf + LOG_CHECKPOINT_2 + LOG_CHECKPOINT_ARCHIVED_LSN, |
|
4590 |
(ib_uint64_t)(LOG_FILE_HDR_SIZE + ut_dulint_minus(max_lsn, |
|
4591 |
ut_dulint_align_down(max_lsn,OS_FILE_LOG_BLOCK_SIZE)))); |
|
4592 |
#endif
|
|
2
by kinoyasu
The first usable version. |
4593 |
fold = ut_fold_binary(log_buf + LOG_CHECKPOINT_2, LOG_CHECKPOINT_CHECKSUM_1); |
4594 |
mach_write_to_4(log_buf + LOG_CHECKPOINT_2 + LOG_CHECKPOINT_CHECKSUM_1, fold); |
|
4595 |
||
4596 |
fold = ut_fold_binary(log_buf + LOG_CHECKPOINT_2 + LOG_CHECKPOINT_LSN, |
|
4597 |
LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); |
|
4598 |
mach_write_to_4(log_buf + LOG_CHECKPOINT_2 + LOG_CHECKPOINT_CHECKSUM_2, fold); |
|
4599 |
||
4600 |
||
4601 |
success = os_file_write(src_path, src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE); |
|
4602 |
if (!success) { |
|
4603 |
goto error; |
|
4604 |
}
|
|
4605 |
||
35
by kinoyasu
fix somebugs: bug 339013, bug 352742 |
4606 |
/* expand file size (9/8) and align to UNIV_PAGE_SIZE */
|
2
by kinoyasu
The first usable version. |
4607 |
|
4608 |
if (file_size % UNIV_PAGE_SIZE) { |
|
4609 |
memset(log_buf, 0, UNIV_PAGE_SIZE); |
|
4610 |
success = os_file_write(src_path, src_file, log_buf, |
|
4611 |
(ulint)(file_size & 0xFFFFFFFFUL), |
|
4612 |
(ulint)(file_size >> 32), |
|
4613 |
UNIV_PAGE_SIZE - (file_size % UNIV_PAGE_SIZE)); |
|
4614 |
if (!success) { |
|
4615 |
goto error; |
|
4616 |
}
|
|
4617 |
||
4618 |
file_size = os_file_get_size_as_iblonglong(src_file); |
|
4619 |
}
|
|
4620 |
||
41
by kinoyasu
some performance tuning |
4621 |
/* TODO: We should judge whether the file is already expanded or not... */
|
35
by kinoyasu
fix somebugs: bug 339013, bug 352742 |
4622 |
{
|
4623 |
ulint expand; |
|
4624 |
||
4625 |
memset(log_buf, 0, UNIV_PAGE_SIZE * 128); |
|
4626 |
expand = file_size / UNIV_PAGE_SIZE / 8; |
|
4627 |
||
4628 |
for (; expand > 128; expand -= 128) { |
|
4629 |
success = os_file_write(src_path, src_file, log_buf, |
|
4630 |
(ulint)(file_size & 0xFFFFFFFFUL), |
|
4631 |
(ulint)(file_size >> 32), |
|
4632 |
UNIV_PAGE_SIZE * 128); |
|
4633 |
if (!success) { |
|
4634 |
goto error; |
|
4635 |
}
|
|
4636 |
file_size += UNIV_PAGE_SIZE * 128; |
|
4637 |
}
|
|
4638 |
||
4639 |
if (expand) { |
|
4640 |
success = os_file_write(src_path, src_file, log_buf, |
|
4641 |
(ulint)(file_size & 0xFFFFFFFFUL), |
|
4642 |
(ulint)(file_size >> 32), |
|
4643 |
expand * UNIV_PAGE_SIZE); |
|
4644 |
if (!success) { |
|
4645 |
goto error; |
|
4646 |
}
|
|
4647 |
file_size += UNIV_PAGE_SIZE * expand; |
|
4648 |
}
|
|
4649 |
}
|
|
4650 |
||
2
by kinoyasu
The first usable version. |
4651 |
/* make larger than 2MB */
|
4652 |
if (file_size < 2*1024*1024L) { |
|
4653 |
memset(log_buf, 0, UNIV_PAGE_SIZE); |
|
4654 |
while (file_size < 2*1024*1024L) { |
|
4655 |
success = os_file_write(src_path, src_file, log_buf, |
|
4656 |
(ulint)(file_size & 0xFFFFFFFFUL), |
|
4657 |
(ulint)(file_size >> 32), |
|
4658 |
UNIV_PAGE_SIZE); |
|
4659 |
if (!success) { |
|
4660 |
goto error; |
|
4661 |
}
|
|
4662 |
file_size += UNIV_PAGE_SIZE; |
|
4663 |
}
|
|
4664 |
file_size = os_file_get_size_as_iblonglong(src_file); |
|
4665 |
}
|
|
4666 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
4667 |
#ifndef INNODB_VERSION_SHORT
|
45
by kinoyasu
messages are fixed a little |
4668 |
printf("xtrabackup: xtrabackup_logfile detected: size=%lld, start_lsn=(%lu %lu)\n", |
2
by kinoyasu
The first usable version. |
4669 |
file_size, max_lsn.high, max_lsn.low); |
100
by kinoyasu
initial implementation for InnoDB Plugin |
4670 |
#else
|
4671 |
printf("xtrabackup: xtrabackup_logfile detected: size=%lld, start_lsn=(%llu)\n", |
|
4672 |
file_size, max_lsn); |
|
4673 |
#endif
|
|
2
by kinoyasu
The first usable version. |
4674 |
|
4675 |
os_file_close(src_file); |
|
4676 |
src_file = -1; |
|
4677 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
4678 |
/* Backup log parameters */
|
4679 |
innobase_log_group_home_dir_backup = innobase_log_group_home_dir; |
|
4680 |
innobase_log_file_size_backup = innobase_log_file_size; |
|
4681 |
innobase_log_files_in_group_backup = innobase_log_files_in_group; |
|
4682 |
||
2
by kinoyasu
The first usable version. |
4683 |
/* fake InnoDB */
|
4684 |
innobase_log_group_home_dir = NULL; |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
4685 |
innobase_log_file_size = file_size; |
2
by kinoyasu
The first usable version. |
4686 |
innobase_log_files_in_group = 1; |
5
by kinoyasu
add innobackup support patch, fix some bugs |
4687 |
|
2
by kinoyasu
The first usable version. |
4688 |
srv_thread_concurrency = 0; |
4689 |
||
4690 |
/* rename 'xtrabackup_logfile' to 'ib_logfile0' */
|
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
4691 |
success = os_file_rename( |
4692 |
#if (MYSQL_VERSION_ID > 50500)
|
|
4693 |
0 /* dummy of innodb_file_data_key */, |
|
4694 |
#endif
|
|
4695 |
src_path, dst_path); |
|
2
by kinoyasu
The first usable version. |
4696 |
if (!success) { |
4697 |
goto error; |
|
4698 |
}
|
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
4699 |
xtrabackup_logfile_is_renamed = TRUE; |
4700 |
||
4701 |
ut_free(log_buf_); |
|
4702 |
||
4703 |
return(FALSE); |
|
4704 |
||
4705 |
skip_modify: |
|
4706 |
os_file_close(src_file); |
|
4707 |
src_file = -1; |
|
4708 |
ut_free(log_buf_); |
|
2
by kinoyasu
The first usable version. |
4709 |
return(FALSE); |
4710 |
||
4711 |
error: |
|
4712 |
if (src_file != -1) |
|
4713 |
os_file_close(src_file); |
|
4714 |
if (log_buf_) |
|
4715 |
ut_free(log_buf_); |
|
45
by kinoyasu
messages are fixed a little |
4716 |
fprintf(stderr, "xtrabackup: Error: xtrabackup_init_temp_log() failed.\n"); |
2
by kinoyasu
The first usable version. |
4717 |
return(TRUE); /*ERROR*/ |
4718 |
}
|
|
4719 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4720 |
/***********************************************************************
|
4721 |
Generates path to the meta file path from a given path to an incremental .delta
|
|
4722 |
by replacing trailing ".delta" with ".meta", or returns error if 'delta_path'
|
|
4723 |
does not end with the ".delta" character sequence.
|
|
4724 |
@return TRUE on success, FALSE on error. */
|
|
4725 |
static
|
|
4726 |
ibool
|
|
4727 |
get_meta_path( |
|
4728 |
const char *delta_path, /* in: path to a .delta file */ |
|
4729 |
char *meta_path) /* out: path to the corresponding .meta |
|
4730 |
file */
|
|
4731 |
{
|
|
4732 |
size_t len = strlen(delta_path); |
|
4733 |
||
4734 |
if (len <= 6 || strcmp(delta_path + len - 6, ".delta")) { |
|
4735 |
return FALSE; |
|
4736 |
}
|
|
4737 |
memcpy(meta_path, delta_path, len - 6); |
|
4738 |
strcpy(meta_path + len - 6, XB_DELTA_INFO_SUFFIX); |
|
4739 |
||
4740 |
return TRUE; |
|
4741 |
}
|
|
4742 |
||
33
by kinoyasu
primitive implementation of incremental backup |
4743 |
void
|
4744 |
xtrabackup_apply_delta( |
|
34
by kinoyasu
more user-friendly incremental backup |
4745 |
const char* dirname, /* in: dir name of incremental */ |
4746 |
const char* dbname, /* in: database name (ibdata: NULL) */ |
|
33
by kinoyasu
primitive implementation of incremental backup |
4747 |
const char* filename, /* in: file name (not a path), |
4748 |
including the .delta extension */
|
|
4749 |
my_bool check_newer) |
|
4750 |
{
|
|
4751 |
os_file_t src_file = -1; |
|
4752 |
os_file_t dst_file = -1; |
|
4753 |
char src_path[FN_REFLEN]; |
|
4754 |
char dst_path[FN_REFLEN]; |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4755 |
char meta_path[FN_REFLEN]; |
33
by kinoyasu
primitive implementation of incremental backup |
4756 |
ibool success; |
4757 |
||
4758 |
ibool last_buffer = FALSE; |
|
4759 |
ulint page_in_buffer; |
|
4760 |
ulint incremental_buffers = 0; |
|
4761 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4762 |
xb_delta_info_t info; |
4763 |
ulint page_size; |
|
4764 |
ulint page_size_shift; |
|
33
by kinoyasu
primitive implementation of incremental backup |
4765 |
|
4766 |
ut_a(xtrabackup_incremental); |
|
4767 |
||
34
by kinoyasu
more user-friendly incremental backup |
4768 |
if (dbname) { |
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4769 |
snprintf(src_path, sizeof(src_path), "%s/%s/%s", |
4770 |
dirname, dbname, filename); |
|
4771 |
snprintf(dst_path, sizeof(dst_path), "%s/%s/%s", |
|
4772 |
xtrabackup_real_target_dir, dbname, filename); |
|
34
by kinoyasu
more user-friendly incremental backup |
4773 |
} else { |
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4774 |
snprintf(src_path, sizeof(src_path), "%s/%s", |
4775 |
dirname, filename); |
|
4776 |
snprintf(dst_path, sizeof(dst_path), "%s/%s", |
|
4777 |
xtrabackup_real_target_dir, filename); |
|
34
by kinoyasu
more user-friendly incremental backup |
4778 |
}
|
33
by kinoyasu
primitive implementation of incremental backup |
4779 |
dst_path[strlen(dst_path) - 6] = '\0'; |
4780 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4781 |
if (!get_meta_path(src_path, meta_path)) { |
4782 |
goto error; |
|
4783 |
}
|
|
4784 |
||
96
by kinoyasu
Windows conscious change more |
4785 |
srv_normalize_path_for_win(dst_path); |
4786 |
srv_normalize_path_for_win(src_path); |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4787 |
srv_normalize_path_for_win(meta_path); |
4788 |
||
4789 |
if (!xb_read_delta_metadata(meta_path, &info)) { |
|
4790 |
goto error; |
|
4791 |
}
|
|
4792 |
||
4793 |
page_size = info.page_size; |
|
4794 |
page_size_shift = get_page_size_shift(page_size); |
|
4795 |
fprintf(stderr, "xtrabackup: page size for %s is %lu bytes\n", |
|
4796 |
src_path, page_size); |
|
4797 |
if (page_size_shift < 10 || |
|
4798 |
page_size_shift > UNIV_PAGE_SIZE_SHIFT_MAX) { |
|
4799 |
fprintf(stderr, |
|
4800 |
"xtrabackup: error: invalid value of page_size "
|
|
4801 |
"(%lu bytes) read from %s\n", page_size, meta_path); |
|
4802 |
goto error; |
|
4803 |
}
|
|
4804 |
||
33
by kinoyasu
primitive implementation of incremental backup |
4805 |
src_file = os_file_create_simple_no_error_handling( |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
4806 |
#if (MYSQL_VERSION_ID > 50500)
|
4807 |
0 /* dummy of innodb_file_data_key */, |
|
4808 |
#endif
|
|
4809 |
src_path, OS_FILE_OPEN, OS_FILE_READ_WRITE, &success); |
|
33
by kinoyasu
primitive implementation of incremental backup |
4810 |
if (!success) { |
4811 |
os_file_get_last_error(TRUE); |
|
4812 |
fprintf(stderr, |
|
46
by kinoyasu
make restricted not to overwrite backup |
4813 |
"xtrabackup: error: cannot open %s\n", |
33
by kinoyasu
primitive implementation of incremental backup |
4814 |
src_path); |
4815 |
goto error; |
|
4816 |
}
|
|
52
by kinoyasu
add to use posix_fadvise() if possible |
4817 |
|
4818 |
#ifdef USE_POSIX_FADVISE
|
|
4819 |
posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL); |
|
4820 |
posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED); |
|
4821 |
#endif
|
|
4822 |
||
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
4823 |
if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { |
4824 |
os_file_set_nocache(src_file, src_path, "OPEN"); |
|
4825 |
}
|
|
33
by kinoyasu
primitive implementation of incremental backup |
4826 |
|
4827 |
dst_file = os_file_create_simple_no_error_handling( |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
4828 |
#if (MYSQL_VERSION_ID > 50500)
|
4829 |
0 /* dummy of innodb_file_data_key */, |
|
4830 |
#endif
|
|
4831 |
dst_path, OS_FILE_OPEN, OS_FILE_READ_WRITE, &success); |
|
33
by kinoyasu
primitive implementation of incremental backup |
4832 |
if (!success) { |
4833 |
os_file_get_last_error(TRUE); |
|
4834 |
fprintf(stderr, |
|
46
by kinoyasu
make restricted not to overwrite backup |
4835 |
"xtrabackup: error: cannot open %s\n", |
33
by kinoyasu
primitive implementation of incremental backup |
4836 |
dst_path); |
4837 |
goto error; |
|
4838 |
}
|
|
52
by kinoyasu
add to use posix_fadvise() if possible |
4839 |
|
4840 |
#ifdef USE_POSIX_FADVISE
|
|
4841 |
posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED); |
|
4842 |
#endif
|
|
4843 |
||
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
4844 |
if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { |
4845 |
os_file_set_nocache(dst_file, dst_path, "OPEN"); |
|
4846 |
}
|
|
33
by kinoyasu
primitive implementation of incremental backup |
4847 |
|
4848 |
printf("Applying %s ...\n", src_path); |
|
4849 |
||
4850 |
while (!last_buffer) { |
|
4851 |
ulint cluster_header; |
|
4852 |
||
4853 |
/* read to buffer */
|
|
4854 |
/* first block of block cluster */
|
|
4855 |
success = os_file_read(src_file, incremental_buffer, |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4856 |
((incremental_buffers * (page_size / 4)) |
4857 |
<< page_size_shift) & 0xFFFFFFFFUL, |
|
4858 |
(incremental_buffers * (page_size / 4)) |
|
4859 |
>> (32 - page_size_shift), |
|
4860 |
page_size); |
|
33
by kinoyasu
primitive implementation of incremental backup |
4861 |
if (!success) { |
4862 |
goto error; |
|
4863 |
}
|
|
4864 |
||
4865 |
cluster_header = mach_read_from_4(incremental_buffer); |
|
4866 |
switch(cluster_header) { |
|
4867 |
case 0x78747261UL: /*"xtra"*/ |
|
4868 |
break; |
|
4869 |
case 0x58545241UL: /*"XTRA"*/ |
|
4870 |
last_buffer = TRUE; |
|
4871 |
break; |
|
85
by kinoyasu
new option --stats to gather index stats |
4872 |
default: |
33
by kinoyasu
primitive implementation of incremental backup |
4873 |
fprintf(stderr, |
45
by kinoyasu
messages are fixed a little |
4874 |
"xtrabackup: error: %s seems not .delta file.\n", |
33
by kinoyasu
primitive implementation of incremental backup |
4875 |
src_path); |
4876 |
goto error; |
|
4877 |
}
|
|
4878 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4879 |
for (page_in_buffer = 1; page_in_buffer < page_size / 4; |
4880 |
page_in_buffer++) { |
|
33
by kinoyasu
primitive implementation of incremental backup |
4881 |
if (mach_read_from_4(incremental_buffer + page_in_buffer * 4) |
4882 |
== 0xFFFFFFFFUL) |
|
4883 |
break; |
|
4884 |
}
|
|
4885 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4886 |
ut_a(last_buffer || page_in_buffer == page_size / 4); |
33
by kinoyasu
primitive implementation of incremental backup |
4887 |
|
4888 |
/* read whole of the cluster */
|
|
4889 |
success = os_file_read(src_file, incremental_buffer, |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4890 |
((incremental_buffers * (page_size / 4)) |
4891 |
<< page_size_shift) & 0xFFFFFFFFUL, |
|
4892 |
(incremental_buffers * (page_size / 4)) |
|
4893 |
>> (32 - page_size_shift), |
|
4894 |
page_in_buffer * page_size); |
|
33
by kinoyasu
primitive implementation of incremental backup |
4895 |
if (!success) { |
4896 |
goto error; |
|
4897 |
}
|
|
4898 |
||
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4899 |
for (page_in_buffer = 1; page_in_buffer < page_size / 4; |
4900 |
page_in_buffer++) { |
|
33
by kinoyasu
primitive implementation of incremental backup |
4901 |
ulint page_offset; |
4902 |
||
4903 |
page_offset = mach_read_from_4(incremental_buffer + page_in_buffer * 4); |
|
4904 |
||
4905 |
if (page_offset == 0xFFFFFFFFUL) |
|
4906 |
break; |
|
4907 |
||
4908 |
/* apply blocks in the cluster */
|
|
186
by kinoyasu
.delta file also includes the pages of FIL_PAGE_LSN is 0 (just brand-new pages) |
4909 |
// if (ut_dulint_cmp(incremental_lsn,
|
4910 |
// MACH_READ_64(incremental_buffer
|
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4911 |
// + page_in_buffer * page_size
|
186
by kinoyasu
.delta file also includes the pages of FIL_PAGE_LSN is 0 (just brand-new pages) |
4912 |
// + FIL_PAGE_LSN)) >= 0)
|
4913 |
// continue;
|
|
33
by kinoyasu
primitive implementation of incremental backup |
4914 |
|
4915 |
success = os_file_write(dst_path, dst_file, |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
4916 |
incremental_buffer + |
4917 |
page_in_buffer * page_size, |
|
4918 |
(page_offset << page_size_shift) & |
|
4919 |
0xFFFFFFFFUL, |
|
4920 |
page_offset >> (32 - page_size_shift), |
|
4921 |
page_size); |
|
33
by kinoyasu
primitive implementation of incremental backup |
4922 |
if (!success) { |
4923 |
goto error; |
|
4924 |
}
|
|
4925 |
}
|
|
4926 |
||
4927 |
incremental_buffers++; |
|
4928 |
}
|
|
4929 |
||
62
by kinoyasu
fix simple mistakes |
4930 |
if (src_file != -1) |
33
by kinoyasu
primitive implementation of incremental backup |
4931 |
os_file_close(src_file); |
62
by kinoyasu
fix simple mistakes |
4932 |
if (dst_file != -1) |
33
by kinoyasu
primitive implementation of incremental backup |
4933 |
os_file_close(dst_file); |
4934 |
return; |
|
4935 |
||
4936 |
error: |
|
62
by kinoyasu
fix simple mistakes |
4937 |
if (src_file != -1) |
33
by kinoyasu
primitive implementation of incremental backup |
4938 |
os_file_close(src_file); |
62
by kinoyasu
fix simple mistakes |
4939 |
if (dst_file != -1) |
33
by kinoyasu
primitive implementation of incremental backup |
4940 |
os_file_close(dst_file); |
45
by kinoyasu
messages are fixed a little |
4941 |
fprintf(stderr, "xtrabackup: Error: xtrabackup_apply_delta() failed.\n"); |
33
by kinoyasu
primitive implementation of incremental backup |
4942 |
return; |
4943 |
}
|
|
4944 |
||
4945 |
void
|
|
4946 |
xtrabackup_apply_deltas(my_bool check_newer) |
|
4947 |
{
|
|
4948 |
int ret; |
|
4949 |
char dbpath[FN_REFLEN]; |
|
4950 |
os_file_dir_t dir; |
|
4951 |
os_file_dir_t dbdir; |
|
4952 |
os_file_stat_t dbinfo; |
|
4953 |
os_file_stat_t fileinfo; |
|
4954 |
ulint err = DB_SUCCESS; |
|
4955 |
static char current_dir[2]; |
|
4956 |
||
4957 |
current_dir[0] = FN_CURLIB; |
|
4958 |
current_dir[1] = 0; |
|
34
by kinoyasu
more user-friendly incremental backup |
4959 |
srv_data_home = current_dir; |
33
by kinoyasu
primitive implementation of incremental backup |
4960 |
|
4961 |
/* datafile */
|
|
34
by kinoyasu
more user-friendly incremental backup |
4962 |
dbdir = os_file_opendir(xtrabackup_incremental_dir, FALSE); |
33
by kinoyasu
primitive implementation of incremental backup |
4963 |
|
4964 |
if (dbdir != NULL) { |
|
34
by kinoyasu
more user-friendly incremental backup |
4965 |
ret = fil_file_readdir_next_file(&err, xtrabackup_incremental_dir, dbdir, |
33
by kinoyasu
primitive implementation of incremental backup |
4966 |
&fileinfo); |
4967 |
while (ret == 0) { |
|
4968 |
if (fileinfo.type == OS_FILE_TYPE_DIR) { |
|
4969 |
goto next_file_item_1; |
|
4970 |
}
|
|
4971 |
||
4972 |
if (strlen(fileinfo.name) > 6 |
|
4973 |
&& 0 == strcmp(fileinfo.name + |
|
4974 |
strlen(fileinfo.name) - 6, |
|
4975 |
".delta")) { |
|
4976 |
xtrabackup_apply_delta( |
|
34
by kinoyasu
more user-friendly incremental backup |
4977 |
xtrabackup_incremental_dir, NULL, |
4978 |
fileinfo.name, check_newer); |
|
33
by kinoyasu
primitive implementation of incremental backup |
4979 |
}
|
4980 |
next_file_item_1: |
|
4981 |
ret = fil_file_readdir_next_file(&err, |
|
34
by kinoyasu
more user-friendly incremental backup |
4982 |
xtrabackup_incremental_dir, dbdir, |
33
by kinoyasu
primitive implementation of incremental backup |
4983 |
&fileinfo); |
4984 |
}
|
|
4985 |
||
4986 |
os_file_closedir(dbdir); |
|
4987 |
} else { |
|
45
by kinoyasu
messages are fixed a little |
4988 |
fprintf(stderr, "xtrabackup: Cannot open dir %s\n", xtrabackup_incremental_dir); |
33
by kinoyasu
primitive implementation of incremental backup |
4989 |
}
|
4990 |
||
4991 |
/* single table tablespaces */
|
|
34
by kinoyasu
more user-friendly incremental backup |
4992 |
dir = os_file_opendir(xtrabackup_incremental_dir, FALSE); |
33
by kinoyasu
primitive implementation of incremental backup |
4993 |
|
4994 |
if (dir == NULL) { |
|
45
by kinoyasu
messages are fixed a little |
4995 |
fprintf(stderr, "xtrabackup: Cannot open dir %s\n", xtrabackup_incremental_dir); |
33
by kinoyasu
primitive implementation of incremental backup |
4996 |
}
|
4997 |
||
34
by kinoyasu
more user-friendly incremental backup |
4998 |
ret = fil_file_readdir_next_file(&err, xtrabackup_incremental_dir, dir, |
33
by kinoyasu
primitive implementation of incremental backup |
4999 |
&dbinfo); |
5000 |
while (ret == 0) { |
|
5001 |
if (dbinfo.type == OS_FILE_TYPE_FILE |
|
5002 |
|| dbinfo.type == OS_FILE_TYPE_UNKNOWN) { |
|
5003 |
||
5004 |
goto next_datadir_item; |
|
5005 |
}
|
|
5006 |
||
34
by kinoyasu
more user-friendly incremental backup |
5007 |
sprintf(dbpath, "%s/%s", xtrabackup_incremental_dir, |
33
by kinoyasu
primitive implementation of incremental backup |
5008 |
dbinfo.name); |
5009 |
srv_normalize_path_for_win(dbpath); |
|
5010 |
||
5011 |
dbdir = os_file_opendir(dbpath, FALSE); |
|
5012 |
||
5013 |
if (dbdir != NULL) { |
|
5014 |
||
5015 |
ret = fil_file_readdir_next_file(&err, dbpath, dbdir, |
|
5016 |
&fileinfo); |
|
5017 |
while (ret == 0) { |
|
5018 |
||
5019 |
if (fileinfo.type == OS_FILE_TYPE_DIR) { |
|
5020 |
||
5021 |
goto next_file_item_2; |
|
5022 |
}
|
|
5023 |
||
5024 |
if (strlen(fileinfo.name) > 6 |
|
5025 |
&& 0 == strcmp(fileinfo.name + |
|
5026 |
strlen(fileinfo.name) - 6, |
|
5027 |
".delta")) { |
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
5028 |
/* The name ends in .delta; try opening
|
33
by kinoyasu
primitive implementation of incremental backup |
5029 |
the file */
|
5030 |
xtrabackup_apply_delta( |
|
34
by kinoyasu
more user-friendly incremental backup |
5031 |
xtrabackup_incremental_dir, dbinfo.name, |
5032 |
fileinfo.name, check_newer); |
|
33
by kinoyasu
primitive implementation of incremental backup |
5033 |
}
|
5034 |
next_file_item_2: |
|
5035 |
ret = fil_file_readdir_next_file(&err, |
|
5036 |
dbpath, dbdir, |
|
5037 |
&fileinfo); |
|
5038 |
}
|
|
5039 |
||
5040 |
os_file_closedir(dbdir); |
|
5041 |
}
|
|
5042 |
next_datadir_item: |
|
5043 |
ret = fil_file_readdir_next_file(&err, |
|
34
by kinoyasu
more user-friendly incremental backup |
5044 |
xtrabackup_incremental_dir, |
33
by kinoyasu
primitive implementation of incremental backup |
5045 |
dir, &dbinfo); |
5046 |
}
|
|
5047 |
||
5048 |
os_file_closedir(dir); |
|
5049 |
||
5050 |
}
|
|
5051 |
||
18
by kinoyasu
supporting MySQL 5.1 |
5052 |
my_bool
|
5053 |
xtrabackup_close_temp_log(my_bool clear_flag) |
|
2
by kinoyasu
The first usable version. |
5054 |
{
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5055 |
os_file_t src_file = -1; |
2
by kinoyasu
The first usable version. |
5056 |
char src_path[FN_REFLEN]; |
5057 |
char dst_path[FN_REFLEN]; |
|
5058 |
ibool success; |
|
5059 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
5060 |
byte* log_buf; |
5061 |
byte* log_buf_ = NULL; |
|
5062 |
||
5063 |
||
5064 |
if (!xtrabackup_logfile_is_renamed) |
|
5065 |
return(FALSE); |
|
5066 |
||
5067 |
/* Restore log parameters */
|
|
5068 |
innobase_log_group_home_dir = innobase_log_group_home_dir_backup; |
|
5069 |
innobase_log_file_size = innobase_log_file_size_backup; |
|
5070 |
innobase_log_files_in_group = innobase_log_files_in_group_backup; |
|
2
by kinoyasu
The first usable version. |
5071 |
|
5072 |
/* rename 'ib_logfile0' to 'xtrabackup_logfile' */
|
|
34
by kinoyasu
more user-friendly incremental backup |
5073 |
if(!xtrabackup_incremental_dir) { |
5074 |
sprintf(dst_path, "%s%s", xtrabackup_target_dir, "/ib_logfile0"); |
|
5075 |
sprintf(src_path, "%s%s", xtrabackup_target_dir, "/xtrabackup_logfile"); |
|
5076 |
} else { |
|
5077 |
sprintf(dst_path, "%s%s", xtrabackup_incremental_dir, "/ib_logfile0"); |
|
5078 |
sprintf(src_path, "%s%s", xtrabackup_incremental_dir, "/xtrabackup_logfile"); |
|
5079 |
}
|
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5080 |
|
96
by kinoyasu
Windows conscious change more |
5081 |
srv_normalize_path_for_win(dst_path); |
5082 |
srv_normalize_path_for_win(src_path); |
|
5083 |
||
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
5084 |
success = os_file_rename( |
5085 |
#if (MYSQL_VERSION_ID > 50500)
|
|
5086 |
0 /* dummy of innodb_file_data_key */, |
|
5087 |
#endif
|
|
5088 |
dst_path, src_path); |
|
2
by kinoyasu
The first usable version. |
5089 |
if (!success) { |
5090 |
goto error; |
|
5091 |
}
|
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5092 |
xtrabackup_logfile_is_renamed = FALSE; |
5093 |
||
5094 |
if (!clear_flag) |
|
5095 |
return(FALSE); |
|
5096 |
||
5097 |
/* clear LOG_FILE_WAS_CREATED_BY_HOT_BACKUP field */
|
|
5098 |
src_file = os_file_create_simple_no_error_handling( |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
5099 |
#if (MYSQL_VERSION_ID > 50500)
|
5100 |
0 /* dummy of innodb_file_data_key */, |
|
5101 |
#endif
|
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5102 |
src_path, OS_FILE_OPEN, |
5103 |
OS_FILE_READ_WRITE, &success); |
|
5104 |
if (!success) { |
|
5105 |
goto error; |
|
5106 |
}
|
|
52
by kinoyasu
add to use posix_fadvise() if possible |
5107 |
|
5108 |
#ifdef USE_POSIX_FADVISE
|
|
5109 |
posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED); |
|
5110 |
#endif
|
|
5111 |
||
51
by kinoyasu
change --backup to be affected by --innodb_flush_method=O_DIRECT |
5112 |
if (srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) { |
5113 |
os_file_set_nocache(src_file, src_path, "OPEN"); |
|
5114 |
}
|
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5115 |
|
5116 |
log_buf_ = ut_malloc(LOG_FILE_HDR_SIZE * 2); |
|
5117 |
log_buf = ut_align(log_buf_, LOG_FILE_HDR_SIZE); |
|
5118 |
||
5119 |
success = os_file_read(src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE); |
|
5120 |
if (!success) { |
|
5121 |
goto error; |
|
5122 |
}
|
|
5123 |
||
5124 |
memset(log_buf + LOG_FILE_WAS_CREATED_BY_HOT_BACKUP, ' ', 4); |
|
5125 |
||
5126 |
success = os_file_write(src_path, src_file, log_buf, 0, 0, LOG_FILE_HDR_SIZE); |
|
5127 |
if (!success) { |
|
5128 |
goto error; |
|
5129 |
}
|
|
5130 |
||
5131 |
os_file_close(src_file); |
|
5132 |
src_file = -1; |
|
2
by kinoyasu
The first usable version. |
5133 |
|
5134 |
return(FALSE); |
|
5135 |
error: |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5136 |
if (src_file != -1) |
5137 |
os_file_close(src_file); |
|
5138 |
if (log_buf_) |
|
5139 |
ut_free(log_buf_); |
|
45
by kinoyasu
messages are fixed a little |
5140 |
fprintf(stderr, "xtrabackup: Error: xtrabackup_close_temp_log() failed.\n"); |
2
by kinoyasu
The first usable version. |
5141 |
return(TRUE); /*ERROR*/ |
5142 |
}
|
|
5143 |
||
1
by kinoyasu
initial registration |
5144 |
void
|
5145 |
xtrabackup_prepare_func(void) |
|
5146 |
{
|
|
5147 |
/* cd to target-dir */
|
|
5148 |
||
5149 |
if (my_setwd(xtrabackup_real_target_dir,MYF(MY_WME))) |
|
5150 |
{
|
|
45
by kinoyasu
messages are fixed a little |
5151 |
fprintf(stderr, "xtrabackup: cannot my_setwd %s\n", xtrabackup_real_target_dir); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5152 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
5153 |
}
|
45
by kinoyasu
messages are fixed a little |
5154 |
fprintf(stderr, "xtrabackup: cd to %s\n", xtrabackup_real_target_dir); |
5155 |
||
1
by kinoyasu
initial registration |
5156 |
xtrabackup_target_dir= mysql_data_home_buff; |
5157 |
xtrabackup_target_dir[0]=FN_CURLIB; // all paths are relative from here |
|
5158 |
xtrabackup_target_dir[1]=0; |
|
5159 |
||
34
by kinoyasu
more user-friendly incremental backup |
5160 |
/* read metadata of target */
|
5161 |
{
|
|
5162 |
char filename[FN_REFLEN]; |
|
5163 |
||
5164 |
sprintf(filename, "%s/%s", xtrabackup_target_dir, XTRABACKUP_METADATA_FILENAME); |
|
5165 |
||
5166 |
if (xtrabackup_read_metadata(filename)) |
|
45
by kinoyasu
messages are fixed a little |
5167 |
fprintf(stderr, "xtrabackup: error: xtrabackup_read_metadata()\n"); |
34
by kinoyasu
more user-friendly incremental backup |
5168 |
|
5169 |
if (!strcmp(metadata_type, "full-backuped")) { |
|
5170 |
fprintf(stderr, "xtrabackup: This target seems to be not prepared yet.\n"); |
|
5171 |
} else if (!strcmp(metadata_type, "full-prepared")) { |
|
5172 |
fprintf(stderr, "xtrabackup: This target seems to be already prepared.\n"); |
|
5173 |
goto skip_check; |
|
5174 |
} else { |
|
5175 |
fprintf(stderr, "xtrabackup: This target seems not to have correct metadata...\n"); |
|
5176 |
}
|
|
5177 |
||
5178 |
if (xtrabackup_incremental) { |
|
5179 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
5180 |
"xtrabackup: error: applying incremental backup needs target prepared.\n"); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5181 |
exit(EXIT_FAILURE); |
34
by kinoyasu
more user-friendly incremental backup |
5182 |
}
|
5183 |
skip_check: |
|
5184 |
if (xtrabackup_incremental |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
5185 |
&& ut_dulint_cmp(metadata_to_lsn, incremental_lsn) != 0) { |
34
by kinoyasu
more user-friendly incremental backup |
5186 |
fprintf(stderr, |
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
5187 |
"xtrabackup: error: This incremental backup seems not to be proper for the target.\n" |
5188 |
"xtrabackup: Check 'to_lsn' of the target and 'from_lsn' of the incremental.\n"); |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5189 |
exit(EXIT_FAILURE); |
34
by kinoyasu
more user-friendly incremental backup |
5190 |
}
|
5191 |
}
|
|
1
by kinoyasu
initial registration |
5192 |
|
2
by kinoyasu
The first usable version. |
5193 |
/* Create logfiles for recovery from 'xtrabackup_logfile', before start InnoDB */
|
5194 |
srv_max_n_threads = 1000; |
|
5195 |
os_sync_mutex = NULL; |
|
104
by kinoyasu
fix bug 440119 |
5196 |
#ifdef INNODB_VERSION_SHORT
|
5197 |
ut_mem_init(); |
|
126
by kinoyasu
add XtraDB-10 base build support, and fix bug550776 |
5198 |
#ifdef XTRADB_BASED
|
5199 |
/* temporally dummy value to avoid crash */
|
|
5200 |
srv_page_size_shift = 14; |
|
5201 |
srv_page_size = (1 << srv_page_size_shift); |
|
5202 |
#endif
|
|
104
by kinoyasu
fix bug 440119 |
5203 |
#endif
|
2
by kinoyasu
The first usable version. |
5204 |
os_sync_init(); |
5205 |
sync_init(); |
|
5206 |
os_io_init_simple(); |
|
5207 |
if(xtrabackup_init_temp_log()) |
|
5208 |
goto error; |
|
33
by kinoyasu
primitive implementation of incremental backup |
5209 |
|
5210 |
if(xtrabackup_incremental) |
|
5211 |
xtrabackup_apply_deltas(TRUE); |
|
5212 |
||
2
by kinoyasu
The first usable version. |
5213 |
sync_close(); |
5214 |
sync_initialized = FALSE; |
|
5215 |
os_sync_free(); |
|
5216 |
os_sync_mutex = NULL; |
|
104
by kinoyasu
fix bug 440119 |
5217 |
ut_free_all_mem(); |
1
by kinoyasu
initial registration |
5218 |
|
5219 |
/* check the accessibility of target-dir */
|
|
5220 |
/* ############# TODO ##################### */
|
|
5221 |
||
5222 |
if(innodb_init_param()) |
|
2
by kinoyasu
The first usable version. |
5223 |
goto error; |
1
by kinoyasu
initial registration |
5224 |
|
179
by kinoyasu
add --apply-log-only option for test only for based on 5.5 version for now. It may be needed for incremental --prepare operation exactly. |
5225 |
srv_apply_log_only = (ibool) xtrabackup_apply_log_only; |
5226 |
||
41
by kinoyasu
some performance tuning |
5227 |
/* increase IO threads */
|
5228 |
if(srv_n_file_io_threads < 10) { |
|
5229 |
srv_n_file_io_threads = 10; |
|
5230 |
}
|
|
34
by kinoyasu
more user-friendly incremental backup |
5231 |
|
28
by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture |
5232 |
fprintf(stderr, "xtrabackup: Starting InnoDB instance for recovery.\n" |
5233 |
"xtrabackup: Using %lld bytes for buffer pool (set by --use-memory parameter)\n", |
|
5234 |
xtrabackup_use_memory); |
|
5235 |
||
1
by kinoyasu
initial registration |
5236 |
if(innodb_init()) |
2
by kinoyasu
The first usable version. |
5237 |
goto error; |
1
by kinoyasu
initial registration |
5238 |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5239 |
//printf("Hello InnoDB world!\n");
|
1
by kinoyasu
initial registration |
5240 |
|
5241 |
/* TEST: innodb status*/
|
|
2
by kinoyasu
The first usable version. |
5242 |
/*
|
1
by kinoyasu
initial registration |
5243 |
ulint trx_list_start = ULINT_UNDEFINED;
|
5244 |
ulint trx_list_end = ULINT_UNDEFINED;
|
|
5245 |
srv_printf_innodb_monitor(stdout, &trx_list_start, &trx_list_end);
|
|
2
by kinoyasu
The first usable version. |
5246 |
*/
|
1
by kinoyasu
initial registration |
5247 |
/* TEST: list of datafiles and transaction log files and LSN*/
|
2
by kinoyasu
The first usable version. |
5248 |
/*
|
1
by kinoyasu
initial registration |
5249 |
{
|
5250 |
fil_system_t* system = fil_system;
|
|
5251 |
fil_space_t* space;
|
|
5252 |
fil_node_t* node;
|
|
5253 |
||
5254 |
mutex_enter(&(system->mutex));
|
|
5255 |
||
5256 |
space = UT_LIST_GET_FIRST(system->space_list);
|
|
5257 |
||
5258 |
while (space != NULL) {
|
|
5259 |
printf("space: name=%s, id=%d, purpose=%d, size=%d\n",
|
|
5260 |
space->name, space->id, space->purpose, space->size);
|
|
5261 |
||
5262 |
node = UT_LIST_GET_FIRST(space->chain);
|
|
5263 |
||
5264 |
while (node != NULL) {
|
|
5265 |
printf("node: name=%s, open=%d, size=%d\n",
|
|
5266 |
node->name, node->open, node->size);
|
|
5267 |
||
5268 |
node = UT_LIST_GET_NEXT(chain, node);
|
|
5269 |
}
|
|
5270 |
space = UT_LIST_GET_NEXT(space_list, space);
|
|
5271 |
}
|
|
5272 |
||
5273 |
mutex_exit(&(system->mutex));
|
|
5274 |
}
|
|
2
by kinoyasu
The first usable version. |
5275 |
*/
|
103
by kinoyasu
fix bug 461099 |
5276 |
/* align space sizes along with fsp header */
|
5277 |
{
|
|
5278 |
fil_system_t* system = fil_system; |
|
5279 |
fil_space_t* space; |
|
5280 |
fil_node_t* node; |
|
5281 |
||
5282 |
mutex_enter(&(system->mutex)); |
|
5283 |
space = UT_LIST_GET_FIRST(system->space_list); |
|
5284 |
||
5285 |
while (space != NULL) { |
|
5286 |
byte* header; |
|
5287 |
ulint size; |
|
5288 |
ulint actual_size; |
|
5289 |
mtr_t mtr; |
|
5290 |
#ifdef INNODB_VERSION_SHORT
|
|
5291 |
buf_block_t* block; |
|
5292 |
ulint flags; |
|
5293 |
#endif
|
|
5294 |
||
5295 |
if (space->purpose == FIL_TABLESPACE) { |
|
5296 |
mutex_exit(&(system->mutex)); |
|
5297 |
||
5298 |
mtr_start(&mtr); |
|
5299 |
||
5300 |
#ifndef INNODB_VERSION_SHORT
|
|
5301 |
mtr_s_lock(fil_space_get_latch(space->id), &mtr); |
|
5302 |
||
5303 |
header = FIL_PAGE_DATA + buf_page_get(space->id, 0, RW_S_LATCH, &mtr); |
|
5304 |
#else
|
|
5305 |
mtr_s_lock(fil_space_get_latch(space->id, &flags), &mtr); |
|
5306 |
||
5307 |
block = buf_page_get(space->id, |
|
5308 |
dict_table_flags_to_zip_size(flags), |
|
5309 |
0, RW_S_LATCH, &mtr); |
|
5310 |
header = FIL_PAGE_DATA /*FSP_HEADER_OFFSET*/ |
|
5311 |
+ buf_block_get_frame(block); |
|
5312 |
#endif
|
|
5313 |
||
5314 |
size = mtr_read_ulint(header + 8 /* FSP_SIZE */, MLOG_4BYTES, &mtr); |
|
5315 |
||
5316 |
mtr_commit(&mtr); |
|
5317 |
||
5318 |
//printf("%d, %d\n", space->id, size);
|
|
5319 |
||
5320 |
fil_extend_space_to_desired_size(&actual_size, space->id, size); |
|
5321 |
||
5322 |
mutex_enter(&(system->mutex)); |
|
5323 |
}
|
|
5324 |
||
5325 |
space = UT_LIST_GET_NEXT(space_list, space); |
|
5326 |
}
|
|
5327 |
||
5328 |
mutex_exit(&(system->mutex)); |
|
5329 |
}
|
|
5330 |
||
5331 |
||
5332 |
||
60
by kinoyasu
experimantal option --export is added |
5333 |
if (xtrabackup_export) { |
5334 |
printf("xtrabackup: export option is specified.\n"); |
|
5335 |
if (innobase_file_per_table) { |
|
5336 |
fil_system_t* system = fil_system; |
|
5337 |
fil_space_t* space; |
|
5338 |
fil_node_t* node; |
|
5339 |
os_file_t info_file = -1; |
|
5340 |
char info_file_path[FN_REFLEN]; |
|
5341 |
ibool success; |
|
5342 |
char table_name[FN_REFLEN]; |
|
5343 |
||
5344 |
byte* page; |
|
5345 |
byte* buf = NULL; |
|
5346 |
||
5347 |
buf = ut_malloc(UNIV_PAGE_SIZE * 2); |
|
5348 |
page = ut_align(buf, UNIV_PAGE_SIZE); |
|
5349 |
||
5350 |
/* flush insert buffer at shutdwon */
|
|
5351 |
innobase_fast_shutdown = 0; |
|
5352 |
||
5353 |
mutex_enter(&(system->mutex)); |
|
5354 |
||
5355 |
space = UT_LIST_GET_FIRST(system->space_list); |
|
5356 |
while (space != NULL) { |
|
5357 |
/* treat file_per_table only */
|
|
5358 |
if (space->purpose != FIL_TABLESPACE |
|
136
by kinoyasu
port to Percona Server 5.1.47-11 |
5359 |
#ifdef XTRADB_BASED
|
5360 |
|| trx_sys_sys_space(space->id) |
|
5361 |
#else
|
|
5362 |
|| space->id == 0 |
|
5363 |
#endif
|
|
5364 |
)
|
|
5365 |
{
|
|
60
by kinoyasu
experimantal option --export is added |
5366 |
space = UT_LIST_GET_NEXT(space_list, space); |
5367 |
continue; |
|
5368 |
}
|
|
5369 |
||
5370 |
node = UT_LIST_GET_FIRST(space->chain); |
|
5371 |
while (node != NULL) { |
|
5372 |
int len; |
|
5373 |
char *next, *prev, *p; |
|
5374 |
dict_table_t* table; |
|
5375 |
dict_index_t* index; |
|
5376 |
ulint n_index; |
|
5377 |
||
5378 |
/* node exist == file exist, here */
|
|
5379 |
strncpy(info_file_path, node->name, FN_REFLEN); |
|
5380 |
len = strlen(info_file_path); |
|
5381 |
info_file_path[len - 3] = 'e'; |
|
5382 |
info_file_path[len - 2] = 'x'; |
|
5383 |
info_file_path[len - 1] = 'p'; |
|
5384 |
||
5385 |
p = info_file_path; |
|
5386 |
prev = NULL; |
|
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
5387 |
while ((next = strstr(p, SRV_PATH_SEPARATOR_STR)) != NULL) |
96
by kinoyasu
Windows conscious change more |
5388 |
{
|
60
by kinoyasu
experimantal option --export is added |
5389 |
prev = p; |
5390 |
p = next + 1; |
|
5391 |
}
|
|
5392 |
info_file_path[len - 4] = 0; |
|
5393 |
strncpy(table_name, prev, FN_REFLEN); |
|
5394 |
||
5395 |
info_file_path[len - 4] = '.'; |
|
5396 |
||
5397 |
mutex_exit(&(system->mutex)); |
|
5398 |
mutex_enter(&(dict_sys->mutex)); |
|
5399 |
||
5400 |
table = dict_table_get_low(table_name); |
|
5401 |
if (!table) { |
|
5402 |
fprintf(stderr, |
|
5403 |
"xtrabackup: error: cannot find dictionary record of table %s\n", table_name); |
|
5404 |
goto next_node; |
|
5405 |
}
|
|
5406 |
index = dict_table_get_first_index(table); |
|
5407 |
n_index = UT_LIST_GET_LEN(table->indexes); |
|
5408 |
if (n_index > 31) { |
|
5409 |
fprintf(stderr, |
|
5410 |
"xtrabackup: error: sorry, cannot export over 31 indexes for now.\n"); |
|
5411 |
goto next_node; |
|
5412 |
}
|
|
5413 |
||
5414 |
/* init exp file */
|
|
5415 |
bzero(page, UNIV_PAGE_SIZE); |
|
5416 |
mach_write_to_4(page , 0x78706f72UL); |
|
5417 |
mach_write_to_4(page + 4, 0x74696e66UL);/*"xportinf"*/ |
|
5418 |
mach_write_to_4(page + 8, n_index); |
|
5419 |
strncpy(page + 12, table_name, 500); |
|
5420 |
||
5421 |
printf( |
|
85
by kinoyasu
new option --stats to gather index stats |
5422 |
"xtrabackup: export metadata of table '%s' to file `%s` (%lu indexes)\n", |
60
by kinoyasu
experimantal option --export is added |
5423 |
table_name, info_file_path, n_index); |
5424 |
||
5425 |
n_index = 1; |
|
5426 |
while (index) { |
|
5427 |
mach_write_to_8(page + n_index * 512, index->id); |
|
73
by kinoyasu
fix bug 394781, bug 394374 |
5428 |
mach_write_to_4(page + n_index * 512 + 8, |
5429 |
#if (MYSQL_VERSION_ID < 50100)
|
|
5430 |
index->tree->page); |
|
5431 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
5432 |
index->page); |
|
5433 |
#endif
|
|
60
by kinoyasu
experimantal option --export is added |
5434 |
strncpy(page + n_index * 512 + 12, index->name, 500); |
5435 |
||
5436 |
printf( |
|
85
by kinoyasu
new option --stats to gather index stats |
5437 |
"xtrabackup: name=%s, id.low=%lu, page=%lu\n", |
60
by kinoyasu
experimantal option --export is added |
5438 |
index->name, |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
5439 |
#if (MYSQL_VERSION_ID < 50500)
|
73
by kinoyasu
fix bug 394781, bug 394374 |
5440 |
index->id.low, |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
5441 |
#else
|
5442 |
(ulint)(index->id & 0xFFFFFFFFUL), |
|
5443 |
#endif
|
|
73
by kinoyasu
fix bug 394781, bug 394374 |
5444 |
#if (MYSQL_VERSION_ID < 50100)
|
5445 |
index->tree->page); |
|
5446 |
#else /* MYSQL_VERSION_ID < 51000 */ |
|
5447 |
index->page); |
|
5448 |
#endif
|
|
60
by kinoyasu
experimantal option --export is added |
5449 |
|
5450 |
index = dict_table_get_next_index(index); |
|
5451 |
n_index++; |
|
5452 |
}
|
|
5453 |
||
96
by kinoyasu
Windows conscious change more |
5454 |
srv_normalize_path_for_win(info_file_path); |
177
by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin) |
5455 |
info_file = os_file_create( |
5456 |
#if (MYSQL_VERSION_ID > 50500)
|
|
5457 |
0 /* dummy of innodb_file_data_key */, |
|
5458 |
#endif
|
|
5459 |
info_file_path, OS_FILE_OVERWRITE, |
|
97
by kinoyasu
fix bug 437788 maybe |
5460 |
OS_FILE_NORMAL, OS_DATA_FILE, &success); |
60
by kinoyasu
experimantal option --export is added |
5461 |
if (!success) { |
5462 |
os_file_get_last_error(TRUE); |
|
5463 |
goto next_node; |
|
5464 |
}
|
|
5465 |
success = os_file_write(info_file_path, info_file, page, |
|
5466 |
0, 0, UNIV_PAGE_SIZE); |
|
5467 |
if (!success) { |
|
5468 |
os_file_get_last_error(TRUE); |
|
5469 |
goto next_node; |
|
5470 |
}
|
|
5471 |
success = os_file_flush(info_file); |
|
5472 |
if (!success) { |
|
5473 |
os_file_get_last_error(TRUE); |
|
5474 |
goto next_node; |
|
5475 |
}
|
|
5476 |
next_node: |
|
62
by kinoyasu
fix simple mistakes |
5477 |
if (info_file != -1) { |
60
by kinoyasu
experimantal option --export is added |
5478 |
os_file_close(info_file); |
5479 |
info_file = -1; |
|
5480 |
}
|
|
5481 |
mutex_exit(&(dict_sys->mutex)); |
|
5482 |
mutex_enter(&(system->mutex)); |
|
5483 |
||
5484 |
node = UT_LIST_GET_NEXT(chain, node); |
|
5485 |
}
|
|
5486 |
||
5487 |
space = UT_LIST_GET_NEXT(space_list, space); |
|
5488 |
}
|
|
5489 |
mutex_exit(&(system->mutex)); |
|
5490 |
||
5491 |
ut_free(buf); |
|
5492 |
} else { |
|
5493 |
printf("xtrabackup: export option is for file_per_table only, disabled.\n"); |
|
5494 |
}
|
|
5495 |
}
|
|
2
by kinoyasu
The first usable version. |
5496 |
|
5497 |
/* print binlog position (again?) */
|
|
5498 |
printf("\n[notice (again)]\n" |
|
5499 |
" If you use binary log and don't use any hack of group commit,\n" |
|
5500 |
" the binary log position seems to be:\n"); |
|
5501 |
trx_sys_print_mysql_binlog_offset(); |
|
5502 |
printf("\n"); |
|
1
by kinoyasu
initial registration |
5503 |
|
167
by kinoyasu
xtrabackup_binlog_pos_innodb is output when --prepare, if the information exist. |
5504 |
/* output to xtrabackup_binlog_pos_innodb */
|
5505 |
if (*trx_sys_mysql_bin_log_name != '\0') { |
|
5506 |
FILE *fp; |
|
5507 |
||
5508 |
fp = fopen("xtrabackup_binlog_pos_innodb", "w"); |
|
5509 |
if (fp) { |
|
5510 |
fprintf(fp, "%s\t%llu\n", |
|
5511 |
trx_sys_mysql_bin_log_name, |
|
5512 |
trx_sys_mysql_bin_log_pos); |
|
5513 |
fclose(fp); |
|
5514 |
} else { |
|
5515 |
printf("xtrabackup: failed to open 'xtrabackup_binlog_pos_innodb'\n"); |
|
5516 |
}
|
|
5517 |
}
|
|
5518 |
||
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
5519 |
/* Check whether the log is applied enough or not. */
|
5520 |
if ((xtrabackup_incremental |
|
5521 |
&& ut_dulint_cmp(srv_start_lsn, incremental_last_lsn) < 0) |
|
5522 |
||(!xtrabackup_incremental |
|
5523 |
&& ut_dulint_cmp(srv_start_lsn, metadata_last_lsn) < 0)) { |
|
5524 |
printf( "xtrabackup: ########################################################\n" |
|
5525 |
"xtrabackup: # !!WARNING!! #\n" |
|
5526 |
"xtrabackup: # The transaction log file should be wrong or corrupt. #\n" |
|
5527 |
"xtrabackup: # The log was not applied to the intended LSN! #\n" |
|
5528 |
"xtrabackup: ########################################################\n"); |
|
5529 |
if (xtrabackup_incremental) { |
|
5530 |
#ifndef INNODB_VERSION_SHORT
|
|
5531 |
printf("xtrabackup: The intended lsn is %lu:%lu\n", |
|
5532 |
incremental_last_lsn.high, incremental_last_lsn.low); |
|
5533 |
#else
|
|
5534 |
printf("xtrabackup: The intended lsn is %llu\n", |
|
5535 |
incremental_last_lsn); |
|
5536 |
#endif
|
|
5537 |
} else { |
|
5538 |
#ifndef INNODB_VERSION_SHORT
|
|
5539 |
printf("xtrabackup: The intended lsn is %lu:%lu\n", |
|
5540 |
metadata_last_lsn.high, metadata_last_lsn.low); |
|
5541 |
#else
|
|
5542 |
printf("xtrabackup: The intended lsn is %llu\n", |
|
5543 |
metadata_last_lsn); |
|
5544 |
#endif
|
|
5545 |
}
|
|
5546 |
}
|
|
5547 |
||
1
by kinoyasu
initial registration |
5548 |
if(innodb_end()) |
2
by kinoyasu
The first usable version. |
5549 |
goto error; |
5550 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
5551 |
sync_initialized = FALSE; |
5552 |
os_sync_mutex = NULL; |
|
5553 |
||
89
by kinoyasu
fix bug 386535, bug 402884, probability to crash --prepare |
5554 |
/* re-init necessary components */
|
104
by kinoyasu
fix bug 440119 |
5555 |
#ifdef INNODB_VERSION_SHORT
|
5556 |
ut_mem_init(); |
|
5557 |
#endif
|
|
89
by kinoyasu
fix bug 386535, bug 402884, probability to crash --prepare |
5558 |
os_sync_init(); |
5559 |
sync_init(); |
|
5560 |
os_io_init_simple(); |
|
5561 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
5562 |
if(xtrabackup_close_temp_log(TRUE)) |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5563 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
5564 |
|
34
by kinoyasu
more user-friendly incremental backup |
5565 |
/* output to metadata file */
|
5566 |
{
|
|
5567 |
char filename[FN_REFLEN]; |
|
5568 |
||
5569 |
strcpy(metadata_type, "full-prepared"); |
|
5570 |
||
5571 |
if(xtrabackup_incremental |
|
5572 |
&& ut_dulint_cmp(metadata_to_lsn, incremental_to_lsn) < 0) |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
5573 |
{
|
34
by kinoyasu
more user-friendly incremental backup |
5574 |
metadata_to_lsn = incremental_to_lsn; |
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
5575 |
metadata_last_lsn = incremental_last_lsn; |
5576 |
}
|
|
34
by kinoyasu
more user-friendly incremental backup |
5577 |
|
182.1.1
by Baron Schwartz
add --extra-lsndir to xtrabackup |
5578 |
sprintf(filename, "%s/%s", xtrabackup_target_dir, XTRABACKUP_METADATA_FILENAME); |
34
by kinoyasu
more user-friendly incremental backup |
5579 |
if (xtrabackup_write_metadata(filename)) |
182.1.1
by Baron Schwartz
add --extra-lsndir to xtrabackup |
5580 |
fprintf(stderr, "xtrabackup: error: xtrabackup_write_metadata(xtrabackup_target_dir)\n"); |
5581 |
||
5582 |
if(xtrabackup_extra_lsndir) { |
|
5583 |
sprintf(filename, "%s/%s", xtrabackup_extra_lsndir, XTRABACKUP_METADATA_FILENAME); |
|
5584 |
if (xtrabackup_write_metadata(filename)) |
|
5585 |
fprintf(stderr, "xtrabackup: error: xtrabackup_write_metadata(xtrabackup_extra_lsndir)\n"); |
|
5586 |
}
|
|
34
by kinoyasu
more user-friendly incremental backup |
5587 |
}
|
5588 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
5589 |
if(!xtrabackup_create_ib_logfile) |
5590 |
return; |
|
5591 |
||
5592 |
/* TODO: make more smart */
|
|
5593 |
||
5594 |
printf("\n[notice]\nWe cannot call InnoDB second time during the process lifetime.\n"); |
|
5595 |
printf("Please re-execte to create ib_logfile*. Sorry.\n"); |
|
5596 |
/*
|
|
5597 |
printf("Restart InnoDB to create ib_logfile*.\n");
|
|
5598 |
||
5599 |
if(innodb_init_param())
|
|
5600 |
goto error;
|
|
5601 |
||
5602 |
if(innodb_init())
|
|
5603 |
goto error;
|
|
5604 |
||
5605 |
if(innodb_end())
|
|
5606 |
goto error;
|
|
5607 |
*/
|
|
5608 |
||
2
by kinoyasu
The first usable version. |
5609 |
return; |
5610 |
||
5611 |
error: |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5612 |
xtrabackup_close_temp_log(FALSE); |
2
by kinoyasu
The first usable version. |
5613 |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5614 |
exit(EXIT_FAILURE); |
1
by kinoyasu
initial registration |
5615 |
}
|
5616 |
||
5617 |
/* ================= main =================== */
|
|
5618 |
||
5619 |
int main(int argc, char **argv) |
|
5620 |
{
|
|
5621 |
int ho_error; |
|
5622 |
||
5623 |
MY_INIT(argv[0]); |
|
5624 |
||
5625 |
load_defaults("my",load_default_groups,&argc,&argv); |
|
5626 |
||
5627 |
/* ignore unsupported options */
|
|
5628 |
{
|
|
5629 |
int i,j,argc_new,find; |
|
5630 |
char *optend, *prev_found; |
|
5631 |
argc_new = argc; |
|
5632 |
||
5633 |
j=1; |
|
5634 |
for (i=1 ; i < argc ; i++) { |
|
5635 |
uint count; |
|
5636 |
struct my_option *opt= (struct my_option *) my_long_options; |
|
94
by kinoyasu
Windows conscious experimental change |
5637 |
optend= strcend((argv)[i], '='); |
1
by kinoyasu
initial registration |
5638 |
for (count= 0; opt->name; opt++) { |
5639 |
if (!getopt_compare_strings(opt->name, (argv)[i] + 2, |
|
5640 |
(uint)(optend - (argv)[i] - 2))) /* match found */ |
|
5641 |
{
|
|
5642 |
if (!opt->name[(uint)(optend - (argv)[i] - 2)]) { |
|
5643 |
find = 1; |
|
5644 |
goto next_opt; |
|
5645 |
}
|
|
5646 |
if (!count) { |
|
5647 |
count= 1; |
|
5648 |
prev_found= (char *) opt->name; |
|
5649 |
}
|
|
5650 |
else if (strcmp(prev_found, opt->name)) { |
|
5651 |
count++; |
|
5652 |
}
|
|
5653 |
}
|
|
5654 |
}
|
|
5655 |
find = count; |
|
5656 |
next_opt: |
|
5657 |
if(!find){ |
|
5658 |
argc_new--; |
|
5659 |
} else { |
|
5660 |
(argv)[j]=(argv)[i]; |
|
5661 |
j++; |
|
5662 |
}
|
|
5663 |
}
|
|
5664 |
argc = argc_new; |
|
43
by kinoyasu
fix bug 358266, bug 359341 |
5665 |
argv[argc] = NULL; |
1
by kinoyasu
initial registration |
5666 |
}
|
5667 |
||
5668 |
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) |
|
5669 |
exit(ho_error); |
|
5670 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
5671 |
if (strcmp(mysql_data_home, "./") == 0) { |
5672 |
if (!xtrabackup_print_param) |
|
5673 |
usage(); |
|
45
by kinoyasu
messages are fixed a little |
5674 |
printf("\nxtrabackup: Error: Please set parameter 'datadir'\n"); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5675 |
exit(EXIT_FAILURE); |
5
by kinoyasu
add innobackup support patch, fix some bugs |
5676 |
}
|
5677 |
||
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
5678 |
if (xtrabackup_tables) { |
5679 |
/* init regexp */
|
|
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
5680 |
char *p, *next; |
5681 |
int i; |
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
5682 |
char errbuf[100]; |
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
5683 |
|
5684 |
tables_regex_num = 1; |
|
5685 |
||
5686 |
p = xtrabackup_tables; |
|
5687 |
while ((p = strchr(p, ',')) != NULL) { |
|
5688 |
p++; |
|
5689 |
tables_regex_num++; |
|
5690 |
}
|
|
5691 |
||
5692 |
tables_regex = ut_malloc(sizeof(regex_t) * tables_regex_num); |
|
5693 |
||
5694 |
p = xtrabackup_tables; |
|
5695 |
for (i=0; i < tables_regex_num; i++) { |
|
5696 |
next = strchr(p, ','); |
|
5697 |
ut_a(next || i == tables_regex_num - 1); |
|
5698 |
||
5699 |
next++; |
|
5700 |
if (i != tables_regex_num - 1) |
|
5701 |
*(next - 1) = '\0'; |
|
5702 |
||
5703 |
regerror(regcomp(&tables_regex[i],p,REG_EXTENDED), |
|
5704 |
&tables_regex[i],errbuf,sizeof(errbuf)); |
|
5705 |
fprintf(stderr, "xtrabackup: tables regcomp(%s): %s\n",p,errbuf); |
|
5706 |
||
5707 |
if (i != tables_regex_num - 1) |
|
5708 |
*(next - 1) = ','; |
|
5709 |
p = next; |
|
5710 |
}
|
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
5711 |
}
|
5712 |
||
158
by kinoyasu
new option --tables_file is added |
5713 |
if (xtrabackup_tables_file) { |
5714 |
char name_buf[NAME_LEN*2+2]; |
|
5715 |
FILE *fp; |
|
5716 |
||
176
by kinoyasu
treat correctly --tables_file with --stream (show warning and ignore) |
5717 |
if (xtrabackup_stream) { |
5718 |
fprintf(stderr, "xtrabackup: Warning: --tables_file option doesn't affect with --stream.\n", xtrabackup_tables_file); |
|
5719 |
xtrabackup_tables_file = NULL; |
|
5720 |
goto skip_tables_file_register; |
|
5721 |
}
|
|
5722 |
||
158
by kinoyasu
new option --tables_file is added |
5723 |
name_buf[NAME_LEN*2+1] = '\0'; |
5724 |
||
5725 |
/* init tables_hash */
|
|
5726 |
tables_hash = hash_create(1000); |
|
5727 |
||
5728 |
/* read and store the filenames */
|
|
5729 |
fp = fopen(xtrabackup_tables_file,"r"); |
|
5730 |
if (!fp) { |
|
5731 |
fprintf(stderr, "xtrabackup: cannot open %s\n", xtrabackup_tables_file); |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5732 |
exit(EXIT_FAILURE); |
158
by kinoyasu
new option --tables_file is added |
5733 |
}
|
5734 |
for (;;) { |
|
5735 |
xtrabackup_tables_t* table; |
|
5736 |
char* p = name_buf; |
|
5737 |
||
5738 |
if ( fgets(name_buf, NAME_LEN*2+1, fp) == 0 ) { |
|
5739 |
break; |
|
5740 |
}
|
|
5741 |
||
5742 |
while (*p != '\0') { |
|
5743 |
if (*p == '.') { |
|
5744 |
*p = '/'; |
|
5745 |
}
|
|
5746 |
p++; |
|
5747 |
}
|
|
5748 |
p = strchr(name_buf, '\n'); |
|
5749 |
if (p) |
|
5750 |
{
|
|
5751 |
*p = '\0'; |
|
5752 |
}
|
|
5753 |
||
5754 |
table = malloc(sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1); |
|
5755 |
memset(table, '\0', sizeof(xtrabackup_tables_t) + strlen(name_buf) + 1); |
|
5756 |
table->name = ((char*)table) + sizeof(xtrabackup_tables_t); |
|
5757 |
strcpy(table->name, name_buf); |
|
5758 |
||
5759 |
HASH_INSERT(xtrabackup_tables_t, name_hash, tables_hash, |
|
5760 |
ut_fold_string(table->name), table); |
|
5761 |
||
5762 |
printf("xtrabackup: table '%s' is registerd to the list.\n", table->name); |
|
5763 |
}
|
|
5764 |
}
|
|
176
by kinoyasu
treat correctly --tables_file with --stream (show warning and ignore) |
5765 |
skip_tables_file_register: |
158
by kinoyasu
new option --tables_file is added |
5766 |
|
132
by Yasufumi Kinoshita
fix bug561106 |
5767 |
#ifdef XTRADB_BASED
|
5768 |
/* temporary setting of enough size */
|
|
5769 |
srv_page_size_shift = UNIV_PAGE_SIZE_SHIFT_MAX; |
|
5770 |
srv_page_size = UNIV_PAGE_SIZE_MAX; |
|
5771 |
#endif
|
|
34
by kinoyasu
more user-friendly incremental backup |
5772 |
if (xtrabackup_backup && xtrabackup_incremental) { |
5773 |
/* direct specification is only for --backup */
|
|
5774 |
/* and the lsn is prior to the other option */
|
|
5775 |
||
33
by kinoyasu
primitive implementation of incremental backup |
5776 |
char* incremental_low; |
5777 |
char* endchar; |
|
5778 |
long long lsn_high, lsn_low; |
|
5779 |
int error = 0; |
|
5780 |
||
100
by kinoyasu
initial implementation for InnoDB Plugin |
5781 |
#ifndef INNODB_VERSION_SHORT
|
33
by kinoyasu
primitive implementation of incremental backup |
5782 |
incremental_low = strstr(xtrabackup_incremental, ":"); |
5783 |
if (incremental_low) { |
|
5784 |
*incremental_low = '\0'; |
|
5785 |
||
5786 |
lsn_high = strtoll(xtrabackup_incremental, &endchar, 10); |
|
5787 |
if (*endchar != '\0' || (lsn_high >> 32)) |
|
5788 |
error = 1; |
|
5789 |
||
5790 |
*incremental_low = ':'; |
|
5791 |
incremental_low++; |
|
5792 |
||
5793 |
lsn_low = strtoll(incremental_low, &endchar, 10); |
|
5794 |
||
5795 |
if (*endchar != '\0' || (lsn_low >> 32)) |
|
5796 |
error = 1; |
|
5797 |
||
5798 |
incremental_lsn = ut_dulint_create((ulint)lsn_high, (ulint)lsn_low); |
|
5799 |
} else { |
|
5800 |
error = 1; |
|
5801 |
}
|
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
5802 |
#else
|
5803 |
incremental_lsn = strtoll(xtrabackup_incremental, &endchar, 10); |
|
5804 |
if (*endchar != '\0') |
|
5805 |
error = 1; |
|
5806 |
#endif
|
|
33
by kinoyasu
primitive implementation of incremental backup |
5807 |
|
5808 |
if (error) { |
|
45
by kinoyasu
messages are fixed a little |
5809 |
fprintf(stderr, "xtrabackup: value '%s' may be wrong format for incremental option.\n", |
33
by kinoyasu
primitive implementation of incremental backup |
5810 |
xtrabackup_incremental); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5811 |
exit(EXIT_FAILURE); |
33
by kinoyasu
primitive implementation of incremental backup |
5812 |
}
|
5813 |
||
34
by kinoyasu
more user-friendly incremental backup |
5814 |
/* allocate buffer for incremental backup (4096 pages) */
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
5815 |
incremental_buffer_base = malloc((UNIV_PAGE_SIZE_MAX / 4 + 1) * |
5816 |
UNIV_PAGE_SIZE_MAX); |
|
5817 |
incremental_buffer = ut_align(incremental_buffer_base, |
|
5818 |
UNIV_PAGE_SIZE_MAX); |
|
34
by kinoyasu
more user-friendly incremental backup |
5819 |
} else if (xtrabackup_backup && xtrabackup_incremental_basedir) { |
5820 |
char filename[FN_REFLEN]; |
|
5821 |
||
5822 |
sprintf(filename, "%s/%s", xtrabackup_incremental_basedir, XTRABACKUP_METADATA_FILENAME); |
|
5823 |
||
5824 |
if (xtrabackup_read_metadata(filename)) { |
|
5825 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
5826 |
"xtrabackup: error: failed to read metadata from %s\n", |
34
by kinoyasu
more user-friendly incremental backup |
5827 |
filename); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5828 |
exit(EXIT_FAILURE); |
34
by kinoyasu
more user-friendly incremental backup |
5829 |
}
|
5830 |
||
5831 |
incremental_lsn = metadata_to_lsn; |
|
5832 |
xtrabackup_incremental = xtrabackup_incremental_basedir; //dummy |
|
5833 |
||
5834 |
/* allocate buffer for incremental backup (4096 pages) */
|
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
5835 |
incremental_buffer_base = malloc((UNIV_PAGE_SIZE_MAX / 4 + 1) * |
5836 |
UNIV_PAGE_SIZE_MAX); |
|
5837 |
incremental_buffer = ut_align(incremental_buffer_base, |
|
5838 |
UNIV_PAGE_SIZE_MAX); |
|
34
by kinoyasu
more user-friendly incremental backup |
5839 |
} else if (xtrabackup_prepare && xtrabackup_incremental_dir) { |
5840 |
char filename[FN_REFLEN]; |
|
5841 |
||
5842 |
sprintf(filename, "%s/%s", xtrabackup_incremental_dir, XTRABACKUP_METADATA_FILENAME); |
|
5843 |
||
5844 |
if (xtrabackup_read_metadata(filename)) { |
|
5845 |
fprintf(stderr, |
|
45
by kinoyasu
messages are fixed a little |
5846 |
"xtrabackup: error: failed to read metadata from %s\n", |
34
by kinoyasu
more user-friendly incremental backup |
5847 |
filename); |
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5848 |
exit(EXIT_FAILURE); |
34
by kinoyasu
more user-friendly incremental backup |
5849 |
}
|
5850 |
||
5851 |
incremental_lsn = metadata_from_lsn; |
|
5852 |
incremental_to_lsn = metadata_to_lsn; |
|
191
by kinoyasu
add check of the last lsn of the backup and applied lsn of the prepare |
5853 |
incremental_last_lsn = metadata_last_lsn; |
34
by kinoyasu
more user-friendly incremental backup |
5854 |
xtrabackup_incremental = xtrabackup_incremental_dir; //dummy |
33
by kinoyasu
primitive implementation of incremental backup |
5855 |
|
5856 |
/* allocate buffer for incremental backup (4096 pages) */
|
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
5857 |
incremental_buffer_base = malloc((UNIV_PAGE_SIZE / 4 + 1) * |
5858 |
UNIV_PAGE_SIZE); |
|
5859 |
incremental_buffer = ut_align(incremental_buffer_base, |
|
5860 |
UNIV_PAGE_SIZE); |
|
33
by kinoyasu
primitive implementation of incremental backup |
5861 |
} else { |
5862 |
/* allocate buffer for applying incremental (for header page only) */
|
|
206.2.1
by Alexey Kopytov
InnoDB compression support for incremental backups. |
5863 |
incremental_buffer_base = malloc((1 + 1) * UNIV_PAGE_SIZE_MAX); |
5864 |
incremental_buffer = ut_align(incremental_buffer_base, |
|
5865 |
UNIV_PAGE_SIZE_MAX); |
|
34
by kinoyasu
more user-friendly incremental backup |
5866 |
|
5867 |
xtrabackup_incremental = NULL; |
|
33
by kinoyasu
primitive implementation of incremental backup |
5868 |
}
|
5869 |
||
5
by kinoyasu
add innobackup support patch, fix some bugs |
5870 |
/* --print-param */
|
5871 |
if (xtrabackup_print_param) { |
|
22
by kinoyasu
"innobackup --stream=tar" is supported |
5872 |
/* === some variables from mysqld === */
|
94
by kinoyasu
Windows conscious experimental change |
5873 |
bzero((G_PTR) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); |
22
by kinoyasu
"innobackup --stream=tar" is supported |
5874 |
|
5875 |
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir)) |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5876 |
exit(EXIT_FAILURE); |
22
by kinoyasu
"innobackup --stream=tar" is supported |
5877 |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5878 |
printf("# This MySQL options file was generated by XtraBackup.\n"); |
5879 |
printf("[mysqld]\n"); |
|
106.1.1
by Aleksandr Kuzminsky
Fixed Bug#485011: Put path and file names into quotes when --print-param |
5880 |
printf("datadir = \"%s\"\n", mysql_data_home); |
5881 |
printf("tmpdir = \"%s\"\n", mysql_tmpdir_list.list[0]); |
|
5882 |
printf("innodb_data_home_dir = \"%s\"\n", |
|
5
by kinoyasu
add innobackup support patch, fix some bugs |
5883 |
innobase_data_home_dir ? innobase_data_home_dir : mysql_data_home); |
106.1.1
by Aleksandr Kuzminsky
Fixed Bug#485011: Put path and file names into quotes when --print-param |
5884 |
printf("innodb_data_file_path = \"%s\"\n", |
5
by kinoyasu
add innobackup support patch, fix some bugs |
5885 |
innobase_data_file_path ? innobase_data_file_path : "ibdata1:10M:autoextend"); |
106.1.1
by Aleksandr Kuzminsky
Fixed Bug#485011: Put path and file names into quotes when --print-param |
5886 |
printf("innodb_log_group_home_dir = \"%s\"\n", |
5
by kinoyasu
add innobackup support patch, fix some bugs |
5887 |
innobase_log_group_home_dir ? innobase_log_group_home_dir : mysql_data_home); |
14
by kinoyasu
using rsync for incremental backup |
5888 |
printf("innodb_log_files_in_group = %ld\n", innobase_log_files_in_group); |
5889 |
printf("innodb_log_file_size = %lld\n", innobase_log_file_size); |
|
226
by Alexey Kopytov
Addendum to the patch for bug #606981. |
5890 |
printf("innodb_flush_method = \"%s\"\n", |
224
by Alexey Kopytov
Bug #606981: linux + o_direct + stream backup = broken? |
5891 |
(innobase_unix_file_flush_method != NULL) ? |
5892 |
innobase_unix_file_flush_method : ""); |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5893 |
exit(EXIT_SUCCESS); |
5
by kinoyasu
add innobackup support patch, fix some bugs |
5894 |
}
|
5895 |
||
14
by kinoyasu
using rsync for incremental backup |
5896 |
if (!xtrabackup_stream) { |
11
by kinoyasu
fix tribials |
5897 |
print_version(); |
34
by kinoyasu
more user-friendly incremental backup |
5898 |
if (xtrabackup_incremental) { |
100
by kinoyasu
initial implementation for InnoDB Plugin |
5899 |
#ifndef INNODB_VERSION_SHORT
|
34
by kinoyasu
more user-friendly incremental backup |
5900 |
printf("incremental backup from %lu:%lu is enabled.\n", |
5901 |
incremental_lsn.high, incremental_lsn.low); |
|
100
by kinoyasu
initial implementation for InnoDB Plugin |
5902 |
#else
|
5903 |
printf("incremental backup from %llu is enabled.\n", |
|
5904 |
incremental_lsn); |
|
5905 |
#endif
|
|
34
by kinoyasu
more user-friendly incremental backup |
5906 |
}
|
14
by kinoyasu
using rsync for incremental backup |
5907 |
} else { |
5908 |
if (xtrabackup_backup) { |
|
5909 |
xtrabackup_suspend_at_end = TRUE; |
|
45
by kinoyasu
messages are fixed a little |
5910 |
fprintf(stderr, "xtrabackup: suspend-at-end is enabled.\n"); |
14
by kinoyasu
using rsync for incremental backup |
5911 |
}
|
5912 |
}
|
|
11
by kinoyasu
fix tribials |
5913 |
|
1
by kinoyasu
initial registration |
5914 |
/* cannot execute both for now */
|
85
by kinoyasu
new option --stats to gather index stats |
5915 |
{
|
5916 |
int num = 0; |
|
5917 |
||
5918 |
if (xtrabackup_backup) num++; |
|
5919 |
if (xtrabackup_stats) num++; |
|
5920 |
if (xtrabackup_prepare) num++; |
|
5921 |
if (num != 1) { /* !XOR (for now) */ |
|
5922 |
usage(); |
|
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5923 |
exit(EXIT_FAILURE); |
85
by kinoyasu
new option --stats to gather index stats |
5924 |
}
|
1
by kinoyasu
initial registration |
5925 |
}
|
5926 |
||
5927 |
/* --backup */
|
|
5928 |
if (xtrabackup_backup) |
|
5929 |
xtrabackup_backup_func(); |
|
5930 |
||
85
by kinoyasu
new option --stats to gather index stats |
5931 |
/* --stats */
|
5932 |
if (xtrabackup_stats) |
|
5933 |
xtrabackup_stats_func(); |
|
5934 |
||
1
by kinoyasu
initial registration |
5935 |
/* --prepare */
|
5936 |
if (xtrabackup_prepare) |
|
5937 |
xtrabackup_prepare_func(); |
|
5938 |
||
33
by kinoyasu
primitive implementation of incremental backup |
5939 |
free(incremental_buffer_base); |
5940 |
||
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
5941 |
if (xtrabackup_tables) { |
5942 |
/* free regexp */
|
|
149
by kinoyasu
extend --table of xtrabackup to accept several regexp separated by "," |
5943 |
int i; |
5944 |
||
5945 |
for (i = 0; i < tables_regex_num; i++) { |
|
5946 |
regfree(&tables_regex[i]); |
|
5947 |
}
|
|
5948 |
ut_free(tables_regex); |
|
19
by kinoyasu
xtrabackup --tables=REGEXP, innobackup --index=REGEXP |
5949 |
}
|
5950 |
||
158
by kinoyasu
new option --tables_file is added |
5951 |
if (xtrabackup_tables_file) { |
5952 |
ulint i; |
|
5953 |
||
5954 |
/* free the hash elements */
|
|
5955 |
for (i = 0; i < hash_get_n_cells(tables_hash); i++) { |
|
5956 |
xtrabackup_tables_t* table; |
|
5957 |
||
5958 |
table = HASH_GET_FIRST(tables_hash, i); |
|
5959 |
||
5960 |
while (table) { |
|
5961 |
xtrabackup_tables_t* prev_table = table; |
|
5962 |
||
5963 |
table = HASH_GET_NEXT(name_hash, prev_table); |
|
5964 |
||
5965 |
HASH_DELETE(xtrabackup_tables_t, name_hash, tables_hash, |
|
5966 |
ut_fold_string(prev_table->name), prev_table); |
|
5967 |
free(prev_table); |
|
5968 |
}
|
|
5969 |
}
|
|
5970 |
||
5971 |
/* free tables_hash */
|
|
5972 |
hash_table_free(tables_hash); |
|
5973 |
}
|
|
5974 |
||
188.1.1
by Aleksandr Kuzminsky
fixed exit codes: EXIT_SUCCESS on success and EXIT_FAILURE on a failure |
5975 |
exit(EXIT_SUCCESS); |
1
by kinoyasu
initial registration |
5976 |
}
|