Merge lp:~sergei.glushchenko/percona-xtrabackup/xb21-bug932623 into lp:percona-xtrabackup/2.1
- xb21-bug932623
- Merge into 2.1
Proposed by
Sergei Glushchenko
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Alexey Kopytov | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 416 | ||||
Proposed branch: | lp:~sergei.glushchenko/percona-xtrabackup/xb21-bug932623 | ||||
Merge into: | lp:percona-xtrabackup/2.1 | ||||
Diff against target: |
955 lines (+594/-111) 9 files modified
patches/innodb51_builtin.patch (+67/-4) src/fil_cur.c (+1/-0) src/fil_cur.h (+1/-0) src/innodb_int.c (+76/-0) src/innodb_int.h (+29/-0) src/write_filt.c (+1/-0) src/xtrabackup.c (+333/-107) src/xtrabackup.h (+1/-0) test/t/bug932623.sh (+85/-0) |
||||
To merge this branch: | bzr merge lp:~sergei.glushchenko/percona-xtrabackup/xb21-bug932623 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Approve | ||
Review via email: mp+114363@code.launchpad.net |
Commit message
Description of the change
Merge fix for #932623 from 2.0 series
http://
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) : | # |
review:
Approve
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Bug 1031324, one-liner fix MP'ed.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'patches/innodb51_builtin.patch' | |||
2 | --- patches/innodb51_builtin.patch 2012-02-10 05:04:04 +0000 | |||
3 | +++ patches/innodb51_builtin.patch 2012-07-11 09:06:21 +0000 | |||
4 | @@ -613,7 +613,21 @@ | |||
5 | 613 | 613 | ||
6 | 614 | --- a/storage/innobase/include/mem0mem.h | 614 | --- a/storage/innobase/include/mem0mem.h |
7 | 615 | +++ b/storage/innobase/include/mem0mem.h | 615 | +++ b/storage/innobase/include/mem0mem.h |
9 | 616 | @@ -401,6 +401,7 @@ | 616 | @@ -63,6 +63,13 @@ |
10 | 617 | mem_init( | ||
11 | 618 | /*=====*/ | ||
12 | 619 | ulint size); /* in: common pool size in bytes */ | ||
13 | 620 | + | ||
14 | 621 | +/******************************************************************//** | ||
15 | 622 | +Closes the memory system. */ | ||
16 | 623 | +void | ||
17 | 624 | +mem_close(void); | ||
18 | 625 | +/*===========*/ | ||
19 | 626 | + | ||
20 | 627 | /****************************************************************** | ||
21 | 628 | Use this macro instead of the corresponding function! Macro for memory | ||
22 | 629 | heap creation. */ | ||
23 | 630 | @@ -401,6 +409,7 @@ | ||
24 | 617 | allocated buffer frame, which can be appended as a | 631 | allocated buffer frame, which can be appended as a |
25 | 618 | free block to the heap, if we need more space; | 632 | free block to the heap, if we need more space; |
26 | 619 | otherwise, this is NULL */ | 633 | otherwise, this is NULL */ |
27 | @@ -654,6 +668,21 @@ | |||
28 | 654 | 668 | ||
29 | 655 | if (heap->free_block) { | 669 | if (heap->free_block) { |
30 | 656 | size += UNIV_PAGE_SIZE; | 670 | size += UNIV_PAGE_SIZE; |
31 | 671 | --- a/storage/innobase/include/mem0pool.h | ||
32 | 672 | +++ b/storage/innobase/include/mem0pool.h | ||
33 | 673 | @@ -42,6 +42,12 @@ | ||
34 | 674 | /*============*/ | ||
35 | 675 | /* out: memory pool */ | ||
36 | 676 | ulint size); /* in: pool size in bytes */ | ||
37 | 677 | +/********************************************************************//** | ||
38 | 678 | +Frees a memory pool. */ | ||
39 | 679 | +void | ||
40 | 680 | +mem_pool_free( | ||
41 | 681 | +/*==========*/ | ||
42 | 682 | + mem_pool_t* pool); /*!< in, own: memory pool */ | ||
43 | 683 | /************************************************************************ | ||
44 | 684 | Allocates memory from a pool. NOTE: This low-level function should only be | ||
45 | 685 | used in mem0mem.*! */ | ||
46 | 657 | --- a/storage/innobase/include/srv0srv.h | 686 | --- a/storage/innobase/include/srv0srv.h |
47 | 658 | +++ b/storage/innobase/include/srv0srv.h | 687 | +++ b/storage/innobase/include/srv0srv.h |
48 | 659 | @@ -60,6 +60,8 @@ | 688 | @@ -60,6 +60,8 @@ |
49 | @@ -958,7 +987,7 @@ | |||
50 | 958 | /********************************************************** | 987 | /********************************************************** |
51 | 959 | --- a/storage/innobase/mem/mem0dbg.c | 988 | --- a/storage/innobase/mem/mem0dbg.c |
52 | 960 | +++ b/storage/innobase/mem/mem0dbg.c | 989 | +++ b/storage/innobase/mem/mem0dbg.c |
54 | 961 | @@ -133,6 +133,14 @@ | 990 | @@ -133,9 +133,30 @@ |
55 | 962 | mem_hash_initialized = TRUE; | 991 | mem_hash_initialized = TRUE; |
56 | 963 | #endif | 992 | #endif |
57 | 964 | 993 | ||
58 | @@ -973,6 +1002,22 @@ | |||
59 | 973 | mem_comm_pool = mem_pool_create(size); | 1002 | mem_comm_pool = mem_pool_create(size); |
60 | 974 | } | 1003 | } |
61 | 975 | 1004 | ||
62 | 1005 | +/******************************************************************//** | ||
63 | 1006 | +Closes the memory system. */ | ||
64 | 1007 | +void | ||
65 | 1008 | +mem_close(void) | ||
66 | 1009 | +/*===========*/ | ||
67 | 1010 | +{ | ||
68 | 1011 | + mem_pool_free(mem_comm_pool); | ||
69 | 1012 | + mem_comm_pool = NULL; | ||
70 | 1013 | +#ifdef UNIV_MEM_DEBUG | ||
71 | 1014 | + mem_hash_initialized = FALSE; | ||
72 | 1015 | +#endif /* UNIV_MEM_DEBUG */ | ||
73 | 1016 | +} | ||
74 | 1017 | + | ||
75 | 1018 | #ifdef UNIV_MEM_DEBUG | ||
76 | 1019 | /********************************************************************** | ||
77 | 1020 | Initializes an allocated memory field in the debug version. */ | ||
78 | 976 | --- a/storage/innobase/mem/mem0mem.c | 1021 | --- a/storage/innobase/mem/mem0mem.c |
79 | 977 | +++ b/storage/innobase/mem/mem0mem.c | 1022 | +++ b/storage/innobase/mem/mem0mem.c |
80 | 978 | @@ -472,6 +472,7 @@ | 1023 | @@ -472,6 +472,7 @@ |
81 | @@ -1026,7 +1071,25 @@ | |||
82 | 1026 | pool = ut_malloc(sizeof(mem_pool_t)); | 1071 | pool = ut_malloc(sizeof(mem_pool_t)); |
83 | 1027 | 1072 | ||
84 | 1028 | /* We do not set the memory to zero (FALSE) in the pool, | 1073 | /* We do not set the memory to zero (FALSE) in the pool, |
86 | 1029 | @@ -333,6 +332,10 @@ | 1074 | @@ -244,6 +243,17 @@ |
87 | 1075 | return(pool); | ||
88 | 1076 | } | ||
89 | 1077 | |||
90 | 1078 | +/********************************************************************//** | ||
91 | 1079 | +Frees a memory pool. */ | ||
92 | 1080 | +void | ||
93 | 1081 | +mem_pool_free( | ||
94 | 1082 | +/*==========*/ | ||
95 | 1083 | + mem_pool_t* pool) /*!< in, own: memory pool */ | ||
96 | 1084 | +{ | ||
97 | 1085 | + ut_free(pool->buf); | ||
98 | 1086 | + ut_free(pool); | ||
99 | 1087 | +} | ||
100 | 1088 | + | ||
101 | 1089 | /************************************************************************ | ||
102 | 1090 | Fills the specified free list. */ | ||
103 | 1091 | static | ||
104 | 1092 | @@ -333,6 +344,10 @@ | ||
105 | 1030 | ulint n; | 1093 | ulint n; |
106 | 1031 | ibool ret; | 1094 | ibool ret; |
107 | 1032 | 1095 | ||
108 | @@ -1037,7 +1100,7 @@ | |||
109 | 1037 | n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE)); | 1100 | n = ut_2_log(ut_max(size + MEM_AREA_EXTRA_SIZE, MEM_AREA_MIN_SIZE)); |
110 | 1038 | 1101 | ||
111 | 1039 | mutex_enter(&(pool->mutex)); | 1102 | mutex_enter(&(pool->mutex)); |
113 | 1040 | @@ -465,6 +468,11 @@ | 1103 | @@ -465,6 +480,11 @@ |
114 | 1041 | ulint size; | 1104 | ulint size; |
115 | 1042 | ulint n; | 1105 | ulint n; |
116 | 1043 | 1106 | ||
117 | 1044 | 1107 | ||
118 | === modified file 'src/fil_cur.c' | |||
119 | --- src/fil_cur.c 2012-05-28 16:49:14 +0000 | |||
120 | +++ src/fil_cur.c 2012-07-11 09:06:21 +0000 | |||
121 | @@ -54,6 +54,7 @@ | |||
122 | 54 | cursor->orig_buf = NULL; | 54 | cursor->orig_buf = NULL; |
123 | 55 | cursor->file = XB_FILE_UNDEFINED; | 55 | cursor->file = XB_FILE_UNDEFINED; |
124 | 56 | 56 | ||
125 | 57 | cursor->space_id = node->space->id; | ||
126 | 57 | cursor->is_system = trx_sys_sys_space(node->space->id); | 58 | cursor->is_system = trx_sys_sys_space(node->space->id); |
127 | 58 | 59 | ||
128 | 59 | /* Make the file path relative to the backup root, | 60 | /* Make the file path relative to the backup root, |
129 | 60 | 61 | ||
130 | === modified file 'src/fil_cur.h' | |||
131 | --- src/fil_cur.h 2012-05-25 11:38:15 +0000 | |||
132 | +++ src/fil_cur.h 2012-07-11 09:06:21 +0000 | |||
133 | @@ -53,6 +53,7 @@ | |||
134 | 53 | ulint buf_page_no; /*!< number of the first page in | 53 | ulint buf_page_no; /*!< number of the first page in |
135 | 54 | buffer */ | 54 | buffer */ |
136 | 55 | ulint thread_n; /*!< thread number for diagnostics */ | 55 | ulint thread_n; /*!< thread number for diagnostics */ |
137 | 56 | ulint space_id; /*!< ID of tablespace */ | ||
138 | 56 | } xb_fil_cur_t; | 57 | } xb_fil_cur_t; |
139 | 57 | 58 | ||
140 | 58 | typedef enum { | 59 | typedef enum { |
141 | 59 | 60 | ||
142 | === modified file 'src/innodb_int.c' | |||
143 | --- src/innodb_int.c 2012-02-16 18:02:07 +0000 | |||
144 | +++ src/innodb_int.c 2012-07-11 09:06:21 +0000 | |||
145 | @@ -151,6 +151,82 @@ | |||
146 | 151 | return os_file_flush(file); | 151 | return os_file_flush(file); |
147 | 152 | #endif | 152 | #endif |
148 | 153 | } | 153 | } |
149 | 154 | /*******************************************************************//** | ||
150 | 155 | Returns the table space by a given id, NULL if not found. */ | ||
151 | 156 | fil_space_t* | ||
152 | 157 | xb_space_get_by_id( | ||
153 | 158 | /*================*/ | ||
154 | 159 | ulint id) /*!< in: space id */ | ||
155 | 160 | { | ||
156 | 161 | fil_space_t* space; | ||
157 | 162 | |||
158 | 163 | ut_ad(mutex_own(&fil_system->mutex)); | ||
159 | 164 | |||
160 | 165 | #ifdef INNODB_VERSION_SHORT | ||
161 | 166 | HASH_SEARCH(hash, fil_system->spaces, id, | ||
162 | 167 | fil_space_t*, space, | ||
163 | 168 | ut_ad(space->magic_n == FIL_SPACE_MAGIC_N), | ||
164 | 169 | space->id == id); | ||
165 | 170 | #else | ||
166 | 171 | HASH_SEARCH(hash, fil_system->spaces, id, space, space->id == id); | ||
167 | 172 | #endif | ||
168 | 173 | |||
169 | 174 | return(space); | ||
170 | 175 | } | ||
171 | 176 | |||
172 | 177 | /*******************************************************************//** | ||
173 | 178 | Returns the table space by a given name, NULL if not found. */ | ||
174 | 179 | fil_space_t* | ||
175 | 180 | xb_space_get_by_name( | ||
176 | 181 | /*==================*/ | ||
177 | 182 | const char* name) /*!< in: space name */ | ||
178 | 183 | { | ||
179 | 184 | fil_space_t* space; | ||
180 | 185 | ulint fold; | ||
181 | 186 | |||
182 | 187 | ut_ad(mutex_own(&fil_system->mutex)); | ||
183 | 188 | |||
184 | 189 | #ifdef INNODB_VERSION_SHORT | ||
185 | 190 | fold = ut_fold_string(name); | ||
186 | 191 | HASH_SEARCH(name_hash, fil_system->name_hash, fold, | ||
187 | 192 | fil_space_t*, space, | ||
188 | 193 | ut_ad(space->magic_n == FIL_SPACE_MAGIC_N), | ||
189 | 194 | !strcmp(name, space->name)); | ||
190 | 195 | #else | ||
191 | 196 | HASH_SEARCH(name_hash, fil_system->name_hash, ut_fold_string(name), | ||
192 | 197 | space, 0 == strcmp(name, space->name)); | ||
193 | 198 | #endif | ||
194 | 199 | |||
195 | 200 | return(space); | ||
196 | 201 | } | ||
197 | 202 | |||
198 | 203 | #ifndef INNODB_VERSION_SHORT | ||
199 | 204 | |||
200 | 205 | /*******************************************************************//** | ||
201 | 206 | Free all spaces in space_list. */ | ||
202 | 207 | void | ||
203 | 208 | fil_free_all_spaces(void) | ||
204 | 209 | /*=====================*/ | ||
205 | 210 | { | ||
206 | 211 | fil_space_t* space; | ||
207 | 212 | |||
208 | 213 | mutex_enter(&fil_system->mutex); | ||
209 | 214 | |||
210 | 215 | space = UT_LIST_GET_FIRST(fil_system->space_list); | ||
211 | 216 | |||
212 | 217 | while (space != NULL) { | ||
213 | 218 | fil_node_t* node; | ||
214 | 219 | fil_space_t* prev_space = space; | ||
215 | 220 | |||
216 | 221 | space = UT_LIST_GET_NEXT(space_list, space); | ||
217 | 222 | |||
218 | 223 | fil_space_free(prev_space->id, FALSE); | ||
219 | 224 | } | ||
220 | 225 | |||
221 | 226 | mutex_exit(&fil_system->mutex); | ||
222 | 227 | } | ||
223 | 228 | |||
224 | 229 | #endif | ||
225 | 154 | 230 | ||
226 | 155 | void | 231 | void |
227 | 156 | innobase_invalidate_query_cache( | 232 | innobase_invalidate_query_cache( |
228 | 157 | 233 | ||
229 | === modified file 'src/innodb_int.h' | |||
230 | --- src/innodb_int.h 2012-05-25 11:38:15 +0000 | |||
231 | +++ src/innodb_int.h 2012-07-11 09:06:21 +0000 | |||
232 | @@ -410,6 +410,9 @@ | |||
233 | 410 | extern char *opt_mysql_tmpdir; | 410 | extern char *opt_mysql_tmpdir; |
234 | 411 | extern MY_TMPDIR mysql_tmpdir_list; | 411 | extern MY_TMPDIR mysql_tmpdir_list; |
235 | 412 | 412 | ||
236 | 413 | /** Value of fil_space_struct::magic_n */ | ||
237 | 414 | #define FIL_SPACE_MAGIC_N 89472 | ||
238 | 415 | |||
239 | 413 | /* ==end=== definition at fil0fil.c === */ | 416 | /* ==end=== definition at fil0fil.c === */ |
240 | 414 | 417 | ||
241 | 415 | /* prototypes for static functions in original */ | 418 | /* prototypes for static functions in original */ |
242 | @@ -581,6 +584,32 @@ | |||
243 | 581 | /*==========*/ | 584 | /*==========*/ |
244 | 582 | os_file_t file); /*!< in, own: handle to a file */ | 585 | os_file_t file); /*!< in, own: handle to a file */ |
245 | 583 | 586 | ||
246 | 587 | /*******************************************************************//** | ||
247 | 588 | Returns the table space by a given id, NULL if not found. */ | ||
248 | 589 | fil_space_t* | ||
249 | 590 | xb_space_get_by_id( | ||
250 | 591 | /*================*/ | ||
251 | 592 | ulint id); /*!< in: space id */ | ||
252 | 593 | |||
253 | 594 | /*******************************************************************//** | ||
254 | 595 | Returns the table space by a given name, NULL if not found. */ | ||
255 | 596 | fil_space_t* | ||
256 | 597 | xb_space_get_by_name( | ||
257 | 598 | /*==================*/ | ||
258 | 599 | const char* name); /*!< in: space name */ | ||
259 | 600 | |||
260 | 601 | #ifndef INNODB_VERSION_SHORT | ||
261 | 602 | |||
262 | 603 | #define SRV_SHUTDOWN_NONE 0 | ||
263 | 604 | |||
264 | 605 | /*******************************************************************//** | ||
265 | 606 | Free all spaces in space_list. */ | ||
266 | 607 | void | ||
267 | 608 | fil_free_all_spaces(void); | ||
268 | 609 | /*=====================*/ | ||
269 | 610 | |||
270 | 611 | #endif | ||
271 | 612 | |||
272 | 584 | void | 613 | void |
273 | 585 | innobase_mysql_prepare_print_arbitrary_thd(void); | 614 | innobase_mysql_prepare_print_arbitrary_thd(void); |
274 | 586 | 615 | ||
275 | 587 | 616 | ||
276 | === modified file 'src/write_filt.c' | |||
277 | --- src/write_filt.c 2012-05-25 11:38:15 +0000 | |||
278 | +++ src/write_filt.c 2012-07-11 09:06:21 +0000 | |||
279 | @@ -102,6 +102,7 @@ | |||
280 | 102 | snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name, | 102 | snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name, |
281 | 103 | XB_DELTA_INFO_SUFFIX); | 103 | XB_DELTA_INFO_SUFFIX); |
282 | 104 | info.page_size = cursor->page_size; | 104 | info.page_size = cursor->page_size; |
283 | 105 | info.space_id = cursor->space_id; | ||
284 | 105 | if (!xb_write_delta_metadata(meta_name, &info)) { | 106 | if (!xb_write_delta_metadata(meta_name, &info)) { |
285 | 106 | msg("[%02lu] xtrabackup: Error: " | 107 | msg("[%02lu] xtrabackup: Error: " |
286 | 107 | "failed to write meta info for %s\n", | 108 | "failed to write meta info for %s\n", |
287 | 108 | 109 | ||
288 | === modified file 'src/xtrabackup.c' | |||
289 | --- src/xtrabackup.c 2012-06-20 16:23:58 +0000 | |||
290 | +++ src/xtrabackup.c 2012-07-11 09:06:21 +0000 | |||
291 | @@ -1500,7 +1500,8 @@ | |||
292 | 1500 | return(TRUE); | 1500 | return(TRUE); |
293 | 1501 | } | 1501 | } |
294 | 1502 | 1502 | ||
296 | 1503 | if (fscanf(fp, "page_size = %lu\n", &info->page_size) != 1) | 1503 | if (fscanf(fp, "page_size = %lu\nspace_id = %lu\n", |
297 | 1504 | &info->page_size, &info->space_id) != 2) | ||
298 | 1504 | r= FALSE; | 1505 | r= FALSE; |
299 | 1505 | 1506 | ||
300 | 1506 | fclose(fp); | 1507 | fclose(fp); |
301 | @@ -1515,14 +1516,16 @@ | |||
302 | 1515 | xb_write_delta_metadata(const char *filename, const xb_delta_info_t *info) | 1516 | xb_write_delta_metadata(const char *filename, const xb_delta_info_t *info) |
303 | 1516 | { | 1517 | { |
304 | 1517 | ds_file_t *f; | 1518 | ds_file_t *f; |
306 | 1518 | char buf[32]; | 1519 | char buf[64]; |
307 | 1519 | my_bool ret; | 1520 | my_bool ret; |
308 | 1520 | size_t len; | 1521 | size_t len; |
309 | 1521 | MY_STAT mystat; | 1522 | MY_STAT mystat; |
310 | 1522 | 1523 | ||
313 | 1523 | snprintf(buf, sizeof(buf), "page_size = %lu\n", info->page_size); | 1524 | snprintf(buf, sizeof(buf), |
314 | 1524 | 1525 | "page_size = %lu\nspace_id = %lu\n", | |
315 | 1526 | info->page_size, info->space_id); | ||
316 | 1525 | len = strlen(buf); | 1527 | len = strlen(buf); |
317 | 1528 | |||
318 | 1526 | mystat.st_size = len; | 1529 | mystat.st_size = len; |
319 | 1527 | mystat.st_mtime = my_time(0); | 1530 | mystat.st_mtime = my_time(0); |
320 | 1528 | 1531 | ||
321 | @@ -2108,11 +2111,11 @@ | |||
322 | 2108 | void* arg) | 2111 | void* arg) |
323 | 2109 | { | 2112 | { |
324 | 2110 | ulint segment; | 2113 | ulint segment; |
326 | 2111 | ulint i; | 2114 | |
327 | 2112 | 2115 | ||
328 | 2113 | segment = *((ulint*)arg); | 2116 | segment = *((ulint*)arg); |
329 | 2114 | 2117 | ||
331 | 2115 | for (i = 0;; i++) { | 2118 | while (srv_shutdown_state != SRV_SHUTDOWN_EXIT_THREADS) { |
332 | 2116 | fil_aio_wait(segment); | 2119 | fil_aio_wait(segment); |
333 | 2117 | } | 2120 | } |
334 | 2118 | 2121 | ||
335 | @@ -2265,6 +2268,141 @@ | |||
336 | 2265 | ds_meta = NULL; | 2268 | ds_meta = NULL; |
337 | 2266 | } | 2269 | } |
338 | 2267 | 2270 | ||
339 | 2271 | #define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD | ||
340 | 2272 | #define SRV_MAX_N_PENDING_SYNC_IOS 100 | ||
341 | 2273 | |||
342 | 2274 | /************************************************************************ | ||
343 | 2275 | Initialize the tablespace memory cache and populate it by scanning for and | ||
344 | 2276 | opening data files. | ||
345 | 2277 | @returns DB_SUCCESS or error code.*/ | ||
346 | 2278 | ulint | ||
347 | 2279 | xb_data_files_init(void) | ||
348 | 2280 | /*====================*/ | ||
349 | 2281 | { | ||
350 | 2282 | ulint i; | ||
351 | 2283 | ibool create_new_db; | ||
352 | 2284 | #ifdef XTRADB_BASED | ||
353 | 2285 | ibool create_new_doublewrite_file; | ||
354 | 2286 | #endif | ||
355 | 2287 | ulint err; | ||
356 | 2288 | LSN64 min_flushed_lsn; | ||
357 | 2289 | LSN64 max_flushed_lsn; | ||
358 | 2290 | ulint sum_of_new_sizes; | ||
359 | 2291 | |||
360 | 2292 | #ifndef INNODB_VERSION_SHORT | ||
361 | 2293 | os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD | ||
362 | 2294 | * srv_n_file_io_threads, | ||
363 | 2295 | srv_n_file_io_threads, | ||
364 | 2296 | SRV_MAX_N_PENDING_SYNC_IOS); | ||
365 | 2297 | |||
366 | 2298 | fil_init(srv_max_n_open_files); | ||
367 | 2299 | #else | ||
368 | 2300 | srv_n_file_io_threads = 2 + srv_n_read_io_threads + | ||
369 | 2301 | srv_n_write_io_threads; | ||
370 | 2302 | |||
371 | 2303 | os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD, | ||
372 | 2304 | srv_n_read_io_threads, | ||
373 | 2305 | srv_n_write_io_threads, | ||
374 | 2306 | SRV_MAX_N_PENDING_SYNC_IOS); | ||
375 | 2307 | |||
376 | 2308 | fil_init(srv_file_per_table ? 50000 : 5000, | ||
377 | 2309 | srv_max_n_open_files); | ||
378 | 2310 | #endif | ||
379 | 2311 | |||
380 | 2312 | fsp_init(); | ||
381 | 2313 | |||
382 | 2314 | for (i = 0; i < srv_n_file_io_threads; i++) { | ||
383 | 2315 | thread_nr[i] = i; | ||
384 | 2316 | |||
385 | 2317 | os_thread_create(io_handler_thread, thread_nr + i, | ||
386 | 2318 | thread_ids + i); | ||
387 | 2319 | } | ||
388 | 2320 | |||
389 | 2321 | os_thread_sleep(200000); /*0.2 sec*/ | ||
390 | 2322 | |||
391 | 2323 | err = open_or_create_data_files(&create_new_db, | ||
392 | 2324 | #ifdef XTRADB_BASED | ||
393 | 2325 | &create_new_doublewrite_file, | ||
394 | 2326 | #endif | ||
395 | 2327 | &min_flushed_lsn, &max_flushed_lsn, | ||
396 | 2328 | &sum_of_new_sizes); | ||
397 | 2329 | if (err != DB_SUCCESS) { | ||
398 | 2330 | msg("xtrabackup: Could not open or create data files.\n" | ||
399 | 2331 | "xtrabackup: If you tried to add new data files, and it " | ||
400 | 2332 | "failed here,\n" | ||
401 | 2333 | "xtrabackup: you should now edit innodb_data_file_path in " | ||
402 | 2334 | "my.cnf back\n" | ||
403 | 2335 | "xtrabackup: to what it was, and remove the new ibdata " | ||
404 | 2336 | "files InnoDB created\n" | ||
405 | 2337 | "xtrabackup: in this failed attempt. InnoDB only wrote " | ||
406 | 2338 | "those files full of\n" | ||
407 | 2339 | "xtrabackup: zeros, but did not yet use them in any way. " | ||
408 | 2340 | "But be careful: do not\n" | ||
409 | 2341 | "xtrabackup: remove old data files which contain your " | ||
410 | 2342 | "precious data!\n"); | ||
411 | 2343 | return(err); | ||
412 | 2344 | } | ||
413 | 2345 | |||
414 | 2346 | /* create_new_db must not be TRUE.. */ | ||
415 | 2347 | if (create_new_db) { | ||
416 | 2348 | msg("xtrabackup: could not find data files at the " | ||
417 | 2349 | "specified datadir\n"); | ||
418 | 2350 | return(DB_ERROR); | ||
419 | 2351 | } | ||
420 | 2352 | |||
421 | 2353 | return(fil_load_single_table_tablespaces()); | ||
422 | 2354 | } | ||
423 | 2355 | |||
424 | 2356 | /************************************************************************ | ||
425 | 2357 | Destroy the tablespace memory cache. */ | ||
426 | 2358 | void | ||
427 | 2359 | xb_data_files_close(void) | ||
428 | 2360 | /*====================*/ | ||
429 | 2361 | { | ||
430 | 2362 | ulint i; | ||
431 | 2363 | |||
432 | 2364 | /* Shutdown the aio threads. This has been copied from | ||
433 | 2365 | innobase_shutdown_for_mysql(). */ | ||
434 | 2366 | |||
435 | 2367 | srv_shutdown_state = SRV_SHUTDOWN_EXIT_THREADS; | ||
436 | 2368 | |||
437 | 2369 | for (i = 0; i < 1000; i++) { | ||
438 | 2370 | os_aio_wake_all_threads_at_shutdown(); | ||
439 | 2371 | |||
440 | 2372 | os_mutex_enter(os_sync_mutex); | ||
441 | 2373 | |||
442 | 2374 | if (os_thread_count == 0) { | ||
443 | 2375 | |||
444 | 2376 | os_mutex_exit(os_sync_mutex); | ||
445 | 2377 | |||
446 | 2378 | os_thread_sleep(10000); | ||
447 | 2379 | |||
448 | 2380 | break; | ||
449 | 2381 | } | ||
450 | 2382 | |||
451 | 2383 | os_mutex_exit(os_sync_mutex); | ||
452 | 2384 | |||
453 | 2385 | os_thread_sleep(10000); | ||
454 | 2386 | } | ||
455 | 2387 | |||
456 | 2388 | if (i == 1000) { | ||
457 | 2389 | msg("xtrabackup: Warning: %lu threads created by InnoDB" | ||
458 | 2390 | " had not exited at shutdown!\n", | ||
459 | 2391 | (ulong) os_thread_count); | ||
460 | 2392 | } | ||
461 | 2393 | |||
462 | 2394 | #ifdef INNODB_VERSION_SHORT | ||
463 | 2395 | os_aio_free(); | ||
464 | 2396 | #endif | ||
465 | 2397 | fil_close_all_files(); | ||
466 | 2398 | #ifndef INNODB_VERSION_SHORT | ||
467 | 2399 | fil_free_all_spaces(); | ||
468 | 2400 | #endif | ||
469 | 2401 | fil_system = NULL; | ||
470 | 2402 | |||
471 | 2403 | srv_shutdown_state = SRV_SHUTDOWN_NONE; | ||
472 | 2404 | } | ||
473 | 2405 | |||
474 | 2268 | static void | 2406 | static void |
475 | 2269 | xtrabackup_backup_func(void) | 2407 | xtrabackup_backup_func(void) |
476 | 2270 | { | 2408 | { |
477 | @@ -2418,85 +2556,25 @@ | |||
478 | 2418 | srv_general_init(); | 2556 | srv_general_init(); |
479 | 2419 | 2557 | ||
480 | 2420 | { | 2558 | { |
481 | 2421 | ibool create_new_db; | ||
482 | 2422 | #ifdef XTRADB_BASED | ||
483 | 2423 | ibool create_new_doublewrite_file; | ||
484 | 2424 | #endif | ||
485 | 2425 | ibool log_file_created; | 2559 | ibool log_file_created; |
486 | 2426 | ibool log_created = FALSE; | 2560 | ibool log_created = FALSE; |
487 | 2427 | ibool log_opened = FALSE; | 2561 | ibool log_opened = FALSE; |
488 | 2428 | LSN64 min_flushed_lsn; | ||
489 | 2429 | LSN64 max_flushed_lsn; | ||
490 | 2430 | ulint sum_of_new_sizes; | ||
491 | 2431 | ulint err; | 2562 | ulint err; |
492 | 2432 | ulint i; | 2563 | ulint i; |
493 | 2433 | 2564 | ||
520 | 2434 | 2565 | err = xb_data_files_init(); | |
521 | 2435 | 2566 | if (err != DB_SUCCESS) { | |
522 | 2436 | 2567 | msg("xtrabackup: error: xb_data_files_init() failed with" | |
523 | 2437 | #define SRV_N_PENDING_IOS_PER_THREAD OS_AIO_N_PENDING_IOS_PER_THREAD | 2568 | "error code %lu\n", err); |
524 | 2438 | #define SRV_MAX_N_PENDING_SYNC_IOS 100 | 2569 | exit(EXIT_FAILURE); |
525 | 2439 | 2570 | } | |
526 | 2440 | #ifndef INNODB_VERSION_SHORT | 2571 | |
501 | 2441 | os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD | ||
502 | 2442 | * srv_n_file_io_threads, | ||
503 | 2443 | srv_n_file_io_threads, | ||
504 | 2444 | SRV_MAX_N_PENDING_SYNC_IOS); | ||
505 | 2445 | |||
506 | 2446 | fil_init(srv_max_n_open_files); | ||
507 | 2447 | #else | ||
508 | 2448 | srv_n_file_io_threads = 2 + srv_n_read_io_threads + srv_n_write_io_threads; | ||
509 | 2449 | |||
510 | 2450 | os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD, | ||
511 | 2451 | srv_n_read_io_threads, | ||
512 | 2452 | srv_n_write_io_threads, | ||
513 | 2453 | SRV_MAX_N_PENDING_SYNC_IOS); | ||
514 | 2454 | |||
515 | 2455 | fil_init(srv_file_per_table ? 50000 : 5000, | ||
516 | 2456 | srv_max_n_open_files); | ||
517 | 2457 | #endif | ||
518 | 2458 | |||
519 | 2459 | fsp_init(); | ||
527 | 2460 | log_init(); | 2572 | log_init(); |
528 | 2461 | 2573 | ||
529 | 2462 | lock_sys_create(srv_lock_table_size); | 2574 | lock_sys_create(srv_lock_table_size); |
530 | 2463 | 2575 | ||
531 | 2464 | for (i = 0; i < srv_n_file_io_threads; i++) { | ||
532 | 2465 | thread_nr[i] = i; | ||
533 | 2466 | |||
534 | 2467 | os_thread_create(io_handler_thread, thread_nr + i, thread_ids + i); | ||
535 | 2468 | } | ||
536 | 2469 | |||
537 | 2470 | os_thread_sleep(200000); /*0.2 sec*/ | ||
538 | 2471 | |||
539 | 2472 | err = open_or_create_data_files(&create_new_db, | ||
540 | 2473 | #ifdef XTRADB_BASED | ||
541 | 2474 | &create_new_doublewrite_file, | ||
542 | 2475 | #endif | ||
543 | 2476 | &min_flushed_lsn, &max_flushed_lsn, | ||
544 | 2477 | &sum_of_new_sizes); | ||
545 | 2478 | if (err != DB_SUCCESS) { | ||
546 | 2479 | msg( | ||
547 | 2480 | "xtrabackup: Could not open or create data files.\n" | ||
548 | 2481 | "xtrabackup: If you tried to add new data files, and it failed here,\n" | ||
549 | 2482 | "xtrabackup: you should now edit innodb_data_file_path in my.cnf back\n" | ||
550 | 2483 | "xtrabackup: to what it was, and remove the new ibdata files InnoDB created\n" | ||
551 | 2484 | "xtrabackup: in this failed attempt. InnoDB only wrote those files full of\n" | ||
552 | 2485 | "xtrabackup: zeros, but did not yet use them in any way. But be careful: do not\n" | ||
553 | 2486 | "xtrabackup: remove old data files which contain your precious data!\n"); | ||
554 | 2487 | |||
555 | 2488 | //return((int) err); | ||
556 | 2489 | exit(EXIT_FAILURE); | ||
557 | 2490 | } | ||
558 | 2491 | |||
559 | 2492 | /* create_new_db must not be TRUE.. */ | ||
560 | 2493 | if (create_new_db) { | ||
561 | 2494 | msg("xtrabackup: Something wrong with source files...\n"); | ||
562 | 2495 | exit(EXIT_FAILURE); | ||
563 | 2496 | } | ||
564 | 2497 | |||
565 | 2498 | for (i = 0; i < srv_n_log_files; i++) { | 2576 | for (i = 0; i < srv_n_log_files; i++) { |
567 | 2499 | err = open_or_create_log_file(create_new_db, &log_file_created, | 2577 | err = open_or_create_log_file(FALSE, &log_file_created, |
568 | 2500 | log_opened, 0, i); | 2578 | log_opened, 0, i); |
569 | 2501 | if (err != DB_SUCCESS) { | 2579 | if (err != DB_SUCCESS) { |
570 | 2502 | 2580 | ||
571 | @@ -2509,8 +2587,7 @@ | |||
572 | 2509 | } else { | 2587 | } else { |
573 | 2510 | log_opened = TRUE; | 2588 | log_opened = TRUE; |
574 | 2511 | } | 2589 | } |
577 | 2512 | if ((log_opened && create_new_db) | 2590 | if ((log_opened && log_created)) { |
576 | 2513 | || (log_opened && log_created)) { | ||
578 | 2514 | msg( | 2591 | msg( |
579 | 2515 | "xtrabackup: Error: all log files must be created at the same time.\n" | 2592 | "xtrabackup: Error: all log files must be created at the same time.\n" |
580 | 2516 | "xtrabackup: All log files must be created also in database creation.\n" | 2593 | "xtrabackup: All log files must be created also in database creation.\n" |
581 | @@ -2830,6 +2907,8 @@ | |||
582 | 2830 | msg("xtrabackup: Transaction log of lsn (%llu) to (%llu) was copied.\n", | 2907 | msg("xtrabackup: Transaction log of lsn (%llu) to (%llu) was copied.\n", |
583 | 2831 | checkpoint_lsn_start, log_copy_scanned_lsn); | 2908 | checkpoint_lsn_start, log_copy_scanned_lsn); |
584 | 2832 | #endif | 2909 | #endif |
585 | 2910 | |||
586 | 2911 | xb_data_files_close(); | ||
587 | 2833 | } | 2912 | } |
588 | 2834 | 2913 | ||
589 | 2835 | /* ================= stats ================= */ | 2914 | /* ================= stats ================= */ |
590 | @@ -3717,6 +3796,155 @@ | |||
591 | 3717 | return TRUE; | 3796 | return TRUE; |
592 | 3718 | } | 3797 | } |
593 | 3719 | 3798 | ||
594 | 3799 | |||
595 | 3800 | /*********************************************************************** | ||
596 | 3801 | Searches for matching tablespace file for given .delta file and space_id | ||
597 | 3802 | in given directory. When matching tablespace found, renames it to match the | ||
598 | 3803 | name of .delta file. If there was a tablespace with matching name and | ||
599 | 3804 | mismatching ID, renames it to xtrabackup_tmp_#ID.ibd. If there was no | ||
600 | 3805 | matching file, creates the new one. | ||
601 | 3806 | @return file handle of matched or created file */ | ||
602 | 3807 | static | ||
603 | 3808 | os_file_t | ||
604 | 3809 | xb_delta_open_matching_space( | ||
605 | 3810 | const char* dbname, /* in: path to destination database dir */ | ||
606 | 3811 | const char* name, /* in: name of delta file (without .delta) */ | ||
607 | 3812 | ulint space_id, /* in: space id of delta file */ | ||
608 | 3813 | ulint zip_size, /* in: zip_size of tablespace */ | ||
609 | 3814 | char* real_name, /* out: full path of destination file */ | ||
610 | 3815 | size_t real_name_len, /* out: buffer size for real_name */ | ||
611 | 3816 | ibool* success) /* out: indicates error. TRUE = success */ | ||
612 | 3817 | { | ||
613 | 3818 | char dest_dir[FN_REFLEN]; | ||
614 | 3819 | char dest_space_name[FN_REFLEN]; | ||
615 | 3820 | ibool ok; | ||
616 | 3821 | fil_space_t* fil_space; | ||
617 | 3822 | os_file_t file = 0; | ||
618 | 3823 | |||
619 | 3824 | ut_a(dbname || space_id == 0); | ||
620 | 3825 | |||
621 | 3826 | *success = FALSE; | ||
622 | 3827 | |||
623 | 3828 | if (dbname) { | ||
624 | 3829 | snprintf(dest_dir, FN_REFLEN, "%s/%s", | ||
625 | 3830 | xtrabackup_target_dir, dbname); | ||
626 | 3831 | srv_normalize_path_for_win(dest_dir); | ||
627 | 3832 | |||
628 | 3833 | snprintf(dest_space_name, FN_REFLEN, "./%s/%s", | ||
629 | 3834 | dbname, name); | ||
630 | 3835 | } else { | ||
631 | 3836 | snprintf(dest_dir, FN_REFLEN, "%s", xtrabackup_target_dir); | ||
632 | 3837 | srv_normalize_path_for_win(dest_dir); | ||
633 | 3838 | |||
634 | 3839 | snprintf(dest_space_name, FN_REFLEN, "./%s", name); | ||
635 | 3840 | } | ||
636 | 3841 | |||
637 | 3842 | snprintf(real_name, real_name_len, | ||
638 | 3843 | "%s/%s", | ||
639 | 3844 | xtrabackup_target_dir, dest_space_name); | ||
640 | 3845 | srv_normalize_path_for_win(real_name); | ||
641 | 3846 | |||
642 | 3847 | /* Create the database directory if it doesn't exist yet */ | ||
643 | 3848 | if (!os_file_create_directory(dest_dir, FALSE)) { | ||
644 | 3849 | msg("xtrabackup: error: cannot create dir %s\n", dest_dir); | ||
645 | 3850 | return file; | ||
646 | 3851 | } | ||
647 | 3852 | |||
648 | 3853 | mutex_enter(&fil_system->mutex); | ||
649 | 3854 | fil_space = xb_space_get_by_name(dest_space_name); | ||
650 | 3855 | mutex_exit(&fil_system->mutex); | ||
651 | 3856 | |||
652 | 3857 | if (fil_space != NULL) { | ||
653 | 3858 | if (fil_space->id == space_id) { | ||
654 | 3859 | /* we found matching space */ | ||
655 | 3860 | goto found; | ||
656 | 3861 | } else { | ||
657 | 3862 | |||
658 | 3863 | char tmpname[FN_REFLEN]; | ||
659 | 3864 | |||
660 | 3865 | snprintf(tmpname, FN_REFLEN, "./%s/xtrabackup_tmp_#%lu", | ||
661 | 3866 | dbname, fil_space->id); | ||
662 | 3867 | |||
663 | 3868 | msg("xtrabackup: Renaming %s to %s.ibd\n", | ||
664 | 3869 | fil_space->name, tmpname); | ||
665 | 3870 | |||
666 | 3871 | if (!fil_rename_tablespace(NULL, | ||
667 | 3872 | fil_space->id, tmpname)) | ||
668 | 3873 | { | ||
669 | 3874 | msg("xtrabackup: Cannot rename %s to %s\n", | ||
670 | 3875 | fil_space->name, tmpname); | ||
671 | 3876 | goto exit; | ||
672 | 3877 | } | ||
673 | 3878 | } | ||
674 | 3879 | } | ||
675 | 3880 | |||
676 | 3881 | mutex_enter(&fil_system->mutex); | ||
677 | 3882 | fil_space = xb_space_get_by_id(space_id); | ||
678 | 3883 | mutex_exit(&fil_system->mutex); | ||
679 | 3884 | if (fil_space != NULL) { | ||
680 | 3885 | char tmpname[FN_REFLEN]; | ||
681 | 3886 | |||
682 | 3887 | strncpy(tmpname, dest_space_name, FN_REFLEN); | ||
683 | 3888 | tmpname[strlen(tmpname) - 4] = 0; | ||
684 | 3889 | |||
685 | 3890 | msg("xtrabackup: Renaming %s to %s\n", | ||
686 | 3891 | fil_space->name, dest_space_name); | ||
687 | 3892 | |||
688 | 3893 | if (!fil_rename_tablespace(NULL, | ||
689 | 3894 | fil_space->id, tmpname)) | ||
690 | 3895 | { | ||
691 | 3896 | msg("xtrabackup: Cannot rename %s to %s\n", | ||
692 | 3897 | fil_space->name, dest_space_name); | ||
693 | 3898 | goto exit; | ||
694 | 3899 | } | ||
695 | 3900 | |||
696 | 3901 | goto found; | ||
697 | 3902 | } | ||
698 | 3903 | |||
699 | 3904 | /* no matching space found. create the new one */ | ||
700 | 3905 | |||
701 | 3906 | #ifdef INNODB_VERSION_SHORT | ||
702 | 3907 | if (!fil_space_create(dest_space_name, space_id, | ||
703 | 3908 | zip_size, FIL_TABLESPACE)) { | ||
704 | 3909 | #else | ||
705 | 3910 | if (!fil_space_create(dest_space_name, space_id, | ||
706 | 3911 | FIL_TABLESPACE)) { | ||
707 | 3912 | #endif | ||
708 | 3913 | msg("xtrabackup: Cannot create tablespace %s\n", | ||
709 | 3914 | dest_space_name); | ||
710 | 3915 | goto exit; | ||
711 | 3916 | } | ||
712 | 3917 | |||
713 | 3918 | file = xb_file_create_no_error_handling(real_name, OS_FILE_CREATE, | ||
714 | 3919 | OS_FILE_READ_WRITE, | ||
715 | 3920 | &ok); | ||
716 | 3921 | |||
717 | 3922 | if (ok) { | ||
718 | 3923 | *success = TRUE; | ||
719 | 3924 | } else { | ||
720 | 3925 | msg("xtrabackup: Cannot open file %s\n", real_name); | ||
721 | 3926 | } | ||
722 | 3927 | |||
723 | 3928 | goto exit; | ||
724 | 3929 | |||
725 | 3930 | found: | ||
726 | 3931 | /* open the file and return it's handle */ | ||
727 | 3932 | |||
728 | 3933 | file = xb_file_create_no_error_handling(real_name, OS_FILE_OPEN, | ||
729 | 3934 | OS_FILE_READ_WRITE, | ||
730 | 3935 | &ok); | ||
731 | 3936 | |||
732 | 3937 | if (ok) { | ||
733 | 3938 | *success = TRUE; | ||
734 | 3939 | } else { | ||
735 | 3940 | msg("xtrabackup: Cannot open file %s\n", real_name); | ||
736 | 3941 | } | ||
737 | 3942 | |||
738 | 3943 | exit: | ||
739 | 3944 | |||
740 | 3945 | return file; | ||
741 | 3946 | } | ||
742 | 3947 | |||
743 | 3720 | /************************************************************************ | 3948 | /************************************************************************ |
744 | 3721 | Applies a given .delta file to the corresponding data file. | 3949 | Applies a given .delta file to the corresponding data file. |
745 | 3722 | @return TRUE on success */ | 3950 | @return TRUE on success */ |
746 | @@ -3734,6 +3962,7 @@ | |||
747 | 3734 | char src_path[FN_REFLEN]; | 3962 | char src_path[FN_REFLEN]; |
748 | 3735 | char dst_path[FN_REFLEN]; | 3963 | char dst_path[FN_REFLEN]; |
749 | 3736 | char meta_path[FN_REFLEN]; | 3964 | char meta_path[FN_REFLEN]; |
750 | 3965 | char space_name[FN_REFLEN]; | ||
751 | 3737 | ibool success; | 3966 | ibool success; |
752 | 3738 | 3967 | ||
753 | 3739 | ibool last_buffer = FALSE; | 3968 | ibool last_buffer = FALSE; |
754 | @@ -3761,6 +3990,9 @@ | |||
755 | 3761 | } | 3990 | } |
756 | 3762 | dst_path[strlen(dst_path) - 6] = '\0'; | 3991 | dst_path[strlen(dst_path) - 6] = '\0'; |
757 | 3763 | 3992 | ||
758 | 3993 | strncpy(space_name, filename, FN_REFLEN); | ||
759 | 3994 | space_name[strlen(space_name) - 6] = 0; | ||
760 | 3995 | |||
761 | 3764 | if (!get_meta_path(src_path, meta_path)) { | 3996 | if (!get_meta_path(src_path, meta_path)) { |
762 | 3765 | goto error; | 3997 | goto error; |
763 | 3766 | } | 3998 | } |
764 | @@ -3798,36 +4030,11 @@ | |||
765 | 3798 | 4030 | ||
766 | 3799 | xb_file_set_nocache(src_file, src_path, "OPEN"); | 4031 | xb_file_set_nocache(src_file, src_path, "OPEN"); |
767 | 3800 | 4032 | ||
772 | 3801 | dst_file = xb_file_create_no_error_handling(dst_path, OS_FILE_OPEN, | 4033 | dst_file = xb_delta_open_matching_space( |
773 | 3802 | OS_FILE_READ_WRITE, | 4034 | dbname, space_name, info.space_id, |
774 | 3803 | &success); | 4035 | info.page_size == UNIV_PAGE_SIZE ? 0 : info.page_size, |
775 | 3804 | again: | 4036 | dst_path, sizeof(dst_path), &success); |
776 | 3805 | if (!success) { | 4037 | if (!success) { |
777 | 3806 | ulint errcode = os_file_get_last_error(TRUE); | ||
778 | 3807 | |||
779 | 3808 | if (errcode == OS_FILE_NOT_FOUND) { | ||
780 | 3809 | msg("xtrabackup: target data file %s " | ||
781 | 3810 | "is not found, creating a new one\n", dst_path); | ||
782 | 3811 | /* Create the database directory if it doesn't exist yet | ||
783 | 3812 | */ | ||
784 | 3813 | if (dbname) { | ||
785 | 3814 | char dst_dir[FN_REFLEN]; | ||
786 | 3815 | |||
787 | 3816 | snprintf(dst_dir, sizeof(dst_dir), "%s/%s", | ||
788 | 3817 | xtrabackup_real_target_dir, dbname); | ||
789 | 3818 | srv_normalize_path_for_win(dst_dir); | ||
790 | 3819 | |||
791 | 3820 | if (!os_file_create_directory(dst_dir, FALSE)) | ||
792 | 3821 | goto error; | ||
793 | 3822 | } | ||
794 | 3823 | dst_file = | ||
795 | 3824 | xb_file_create_no_error_handling(dst_path, | ||
796 | 3825 | OS_FILE_CREATE, | ||
797 | 3826 | OS_FILE_READ_WRITE, | ||
798 | 3827 | &success); | ||
799 | 3828 | goto again; | ||
800 | 3829 | } | ||
801 | 3830 | |||
802 | 3831 | msg("xtrabackup: error: cannot open %s\n", dst_path); | 4038 | msg("xtrabackup: error: cannot open %s\n", dst_path); |
803 | 3832 | goto error; | 4039 | goto error; |
804 | 3833 | } | 4040 | } |
805 | @@ -3842,7 +4049,7 @@ | |||
806 | 3842 | incremental_buffer = ut_align(incremental_buffer_base, | 4049 | incremental_buffer = ut_align(incremental_buffer_base, |
807 | 3843 | UNIV_PAGE_SIZE_MAX); | 4050 | UNIV_PAGE_SIZE_MAX); |
808 | 3844 | 4051 | ||
810 | 3845 | msg("Applying %s ...\n", src_path); | 4052 | msg("Applying %s to %s...\n", src_path, dst_path); |
811 | 3846 | 4053 | ||
812 | 3847 | while (!last_buffer) { | 4054 | while (!last_buffer) { |
813 | 3848 | ulint cluster_header; | 4055 | ulint cluster_header; |
814 | @@ -4150,6 +4357,8 @@ | |||
815 | 4150 | static void | 4357 | static void |
816 | 4151 | xtrabackup_prepare_func(void) | 4358 | xtrabackup_prepare_func(void) |
817 | 4152 | { | 4359 | { |
818 | 4360 | ulint err; | ||
819 | 4361 | |||
820 | 4153 | /* cd to target-dir */ | 4362 | /* cd to target-dir */ |
821 | 4154 | 4363 | ||
822 | 4155 | if (my_setwd(xtrabackup_real_target_dir,MYF(MY_WME))) | 4364 | if (my_setwd(xtrabackup_real_target_dir,MYF(MY_WME))) |
823 | @@ -4220,12 +4429,29 @@ | |||
824 | 4220 | if(xtrabackup_init_temp_log()) | 4429 | if(xtrabackup_init_temp_log()) |
825 | 4221 | goto error; | 4430 | goto error; |
826 | 4222 | 4431 | ||
828 | 4223 | if(xtrabackup_incremental && !xtrabackup_apply_deltas(TRUE)) | 4432 | if(innodb_init_param()) |
829 | 4224 | goto error; | 4433 | goto error; |
830 | 4225 | 4434 | ||
831 | 4435 | mem_init(srv_mem_pool_size); | ||
832 | 4436 | if (xtrabackup_incremental) { | ||
833 | 4437 | err = xb_data_files_init(); | ||
834 | 4438 | if (err != DB_SUCCESS) { | ||
835 | 4439 | msg("xtrabackup: error: xb_data_files_init() failed with" | ||
836 | 4440 | "error code %lu\n", err); | ||
837 | 4441 | goto error; | ||
838 | 4442 | } | ||
839 | 4443 | |||
840 | 4444 | if(!xtrabackup_apply_deltas(TRUE)) { | ||
841 | 4445 | xb_data_files_close(); | ||
842 | 4446 | goto error; | ||
843 | 4447 | } | ||
844 | 4448 | |||
845 | 4449 | xb_data_files_close(); | ||
846 | 4450 | } | ||
847 | 4226 | sync_close(); | 4451 | sync_close(); |
848 | 4227 | sync_initialized = FALSE; | 4452 | sync_initialized = FALSE; |
849 | 4228 | os_sync_free(); | 4453 | os_sync_free(); |
850 | 4454 | mem_close(); | ||
851 | 4229 | os_sync_mutex = NULL; | 4455 | os_sync_mutex = NULL; |
852 | 4230 | ut_free_all_mem(); | 4456 | ut_free_all_mem(); |
853 | 4231 | 4457 | ||
854 | 4232 | 4458 | ||
855 | === modified file 'src/xtrabackup.h' | |||
856 | --- src/xtrabackup.h 2012-05-28 16:49:14 +0000 | |||
857 | +++ src/xtrabackup.h 2012-07-11 09:06:21 +0000 | |||
858 | @@ -23,6 +23,7 @@ | |||
859 | 23 | 23 | ||
860 | 24 | typedef struct { | 24 | typedef struct { |
861 | 25 | ulint page_size; | 25 | ulint page_size; |
862 | 26 | ulint space_id; | ||
863 | 26 | } xb_delta_info_t; | 27 | } xb_delta_info_t; |
864 | 27 | 28 | ||
865 | 28 | typedef enum { | 29 | typedef enum { |
866 | 29 | 30 | ||
867 | === added file 'test/t/bug932623.sh' | |||
868 | --- test/t/bug932623.sh 1970-01-01 00:00:00 +0000 | |||
869 | +++ test/t/bug932623.sh 2012-07-11 09:06:21 +0000 | |||
870 | @@ -0,0 +1,85 @@ | |||
871 | 1 | ######################################################################## | ||
872 | 2 | # Bug #932623: RENAME TABLE causes incremental prepare to fail | ||
873 | 3 | ######################################################################## | ||
874 | 4 | |||
875 | 5 | . inc/common.sh | ||
876 | 6 | |||
877 | 7 | start_server --innodb_file_per_table | ||
878 | 8 | |||
879 | 9 | run_cmd $MYSQL $MYSQL_ARGS test <<EOF | ||
880 | 10 | CREATE TABLE t1_old(a INT) ENGINE=InnoDB; | ||
881 | 11 | INSERT INTO t1_old VALUES (1), (2), (3); | ||
882 | 12 | |||
883 | 13 | CREATE TABLE t1(a INT) ENGINE=InnoDB; | ||
884 | 14 | INSERT INTO t1 VALUES (4), (5), (6); | ||
885 | 15 | EOF | ||
886 | 16 | |||
887 | 17 | # Full backup | ||
888 | 18 | # backup root directory | ||
889 | 19 | vlog "Starting backup" | ||
890 | 20 | innobackupex --no-timestamp $topdir/full | ||
891 | 21 | |||
892 | 22 | vlog "Rotating the table" | ||
893 | 23 | |||
894 | 24 | run_cmd $MYSQL $MYSQL_ARGS test <<EOF | ||
895 | 25 | CREATE TABLE t1_new(a int) ENGINE=InnoDB; | ||
896 | 26 | INSERT INTO t1_new VALUES (7), (8), (9); | ||
897 | 27 | |||
898 | 28 | CREATE DATABASE db2; | ||
899 | 29 | RENAME TABLE t1_old TO db2.t1; | ||
900 | 30 | |||
901 | 31 | RENAME TABLE t1 TO t1_old; | ||
902 | 32 | RENAME TABLE t1_new TO t1; | ||
903 | 33 | |||
904 | 34 | INSERT INTO t1_old VALUES (10), (11), (12); | ||
905 | 35 | INSERT INTO t1 VALUES (13), (14), (15); | ||
906 | 36 | |||
907 | 37 | EOF | ||
908 | 38 | |||
909 | 39 | vlog "Creating incremental backup" | ||
910 | 40 | |||
911 | 41 | innobackupex --incremental --no-timestamp \ | ||
912 | 42 | --incremental-basedir=$topdir/full $topdir/inc | ||
913 | 43 | |||
914 | 44 | vlog "Preparing backup" | ||
915 | 45 | |||
916 | 46 | innobackupex --apply-log --redo-only $topdir/full | ||
917 | 47 | vlog "Log applied to full backup" | ||
918 | 48 | |||
919 | 49 | innobackupex --apply-log --redo-only --incremental-dir=$topdir/inc \ | ||
920 | 50 | $topdir/full | ||
921 | 51 | vlog "Delta applied to full backup" | ||
922 | 52 | |||
923 | 53 | innobackupex --apply-log $topdir/full | ||
924 | 54 | vlog "Data prepared for restore" | ||
925 | 55 | |||
926 | 56 | checksum_t1_a=`checksum_table test t1` | ||
927 | 57 | checksum_t1_old_a=`checksum_table test t1_old` | ||
928 | 58 | checksum_t1_db2_a=`checksum_table db2 t1` | ||
929 | 59 | |||
930 | 60 | # Destroying mysql data | ||
931 | 61 | stop_server | ||
932 | 62 | rm -rf $mysql_datadir/* | ||
933 | 63 | vlog "Data destroyed" | ||
934 | 64 | |||
935 | 65 | # Restore backup | ||
936 | 66 | vlog "Copying files" | ||
937 | 67 | |||
938 | 68 | innobackupex --copy-back $topdir/full | ||
939 | 69 | vlog "Data restored" | ||
940 | 70 | |||
941 | 71 | start_server --innodb_file_per_table | ||
942 | 72 | |||
943 | 73 | vlog "Checking checksums" | ||
944 | 74 | checksum_t1_b=`checksum_table test t1` | ||
945 | 75 | checksum_t1_old_b=`checksum_table test t1_old` | ||
946 | 76 | checksum_t1_db2_b=`checksum_table db2 t1` | ||
947 | 77 | |||
948 | 78 | if [ "$checksum_t1_a" != "$checksum_t1_b" -o "$checksum_t1_old_a" != "$checksum_t1_old_b" \ | ||
949 | 79 | -o "$checksum_t1_db2_a" != "$checksum_t1_db2_b" ] | ||
950 | 80 | then | ||
951 | 81 | vlog "Checksums do not match" | ||
952 | 82 | exit -1 | ||
953 | 83 | fi | ||
954 | 84 | |||
955 | 85 | vlog "Checksums are OK" |
This branch introduces many messages like this one:
2012-07-31 13:58:32: xb_incremental.sh: ===> /home/laurynas/ percona/ src/xb21-bug932623/test/. ./src/xtrabacku p --no-defaults --datadir= /home/laurynas/ percona/ src/xb21-bug932623/test/var1/data --backup --target- dir=/home/ laurynas/ percona/ src/xb21-bug932623/test/var1/ data/full percona/ src/xb21-bug932623/test/. ./src/xtrabacku p version 2.0.0 for Percona Server 5.1.59 unknown-linux-gnu (x86_64) (revision id: undefined) percona/ src/xb21-bug932623/test/var1/data data_home_ dir = ./ data_file_ path = ibdata1: 10M:autoextend log_group_ home_dir = ./ log_files_ in_group = 2 log_file_ size = 5242880 sample/ test.ibd' ,
/home/laurynas/
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /home/laurynas/
xtrabackup: Target instance is assumed as followings.
xtrabackup: innodb_
xtrabackup: innodb_
xtrabackup: innodb_
xtrabackup: innodb_
xtrabackup: innodb_
120731 13:58:32 InnoDB: Warning: allocated tablespace 10, old maximum was 9
120731 13:58:32 InnoDB: Warning: trying to init to the tablespace memory cache
InnoDB: a tablespace 10 of name './incremental_
InnoDB: but a tablespace 10 of the same name
InnoDB: already exists in the tablespace memory cache!
InnoDB: We assume that InnoDB did a crash recovery, and you had
InnoDB: an .ibd file for which the table did not exist in the
InnoDB: InnoDB internal data dictionary in the ibdata files.
InnoDB: We assume that you later removed the .ibd and .frm files,
InnoDB: and are now trying to recreate the table. We now remove the
InnoDB: conflicting tablespace object from the memory cache and try
InnoDB: the init again.
Since Sergei is on vacation and I depend on this code, let's keep this "Approved" and merge and I will fix as a follow-up.