2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
1 |
# name : innodb_expand_import.patch |
2 |
# introduced : 11 or before |
|
3 |
# maintainer : Yasufumi |
|
4 |
# |
|
5 |
#!!! notice !!! |
|
6 |
# Any small change to this file in the main branch |
|
7 |
# should be done or reviewed by the maintainer! |
|
8 |
diff -ruN a/storage/innobase/fil/fil0fil.c b/storage/innobase/fil/fil0fil.c
|
|
9 |
--- a/storage/innobase/fil/fil0fil.c 2010-12-03 15:09:51.274957577 +0900
|
|
10 |
+++ b/storage/innobase/fil/fil0fil.c 2010-12-03 15:52:23.553986552 +0900
|
|
11 |
@@ -40,6 +40,12 @@
|
|
12 |
#include "dict0dict.h" |
|
13 |
#include "page0page.h" |
|
14 |
#include "page0zip.h" |
|
15 |
+#include "trx0trx.h"
|
|
16 |
+#include "trx0sys.h"
|
|
17 |
+#include "pars0pars.h"
|
|
18 |
+#include "row0mysql.h"
|
|
19 |
+#include "row0row.h"
|
|
20 |
+#include "que0que.h"
|
|
21 |
#ifndef UNIV_HOTBACKUP |
|
22 |
# include "buf0lru.h" |
|
23 |
# include "ibuf0ibuf.h" |
|
72
by kinoyasu
port Yasufumi patches to 5.5.9 |
24 |
@@ -3078,7 +3084,7 @@
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
25 |
|
26 |
file = os_file_create_simple_no_error_handling( |
|
27 |
innodb_file_data_key, filepath, OS_FILE_OPEN, |
|
28 |
- OS_FILE_READ_ONLY, &success);
|
|
29 |
+ OS_FILE_READ_WRITE, &success);
|
|
30 |
if (!success) { |
|
31 |
/* The following call prints an error message */ |
|
32 |
os_file_get_last_error(TRUE); |
|
72
by kinoyasu
port Yasufumi patches to 5.5.9 |
33 |
@@ -3125,6 +3131,466 @@
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
34 |
space_id = fsp_header_get_space_id(page); |
35 |
space_flags = fsp_header_get_flags(page); |
|
36 |
||
63
by Yasufumi Kinoshita
innodb_expand_import always treats as expand_import, even if the space_id is equal; optimize innodb_dict_size_limit as issue 13634 |
37 |
+ if (srv_expand_import) {
|
38 |
+
|
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
39 |
+ ibool file_is_corrupt = FALSE;
|
40 |
+ byte* buf3;
|
|
41 |
+ byte* descr_page;
|
|
42 |
+ ibool descr_is_corrupt = FALSE;
|
|
43 |
+ index_id_t old_id[31];
|
|
44 |
+ index_id_t new_id[31];
|
|
45 |
+ ulint root_page[31];
|
|
46 |
+ ulint n_index;
|
|
47 |
+ os_file_t info_file = -1;
|
|
48 |
+ char* info_file_path;
|
|
49 |
+ ulint i;
|
|
50 |
+ int len;
|
|
51 |
+ ib_uint64_t current_lsn;
|
|
52 |
+ ulint size_low, size_high, size, free_limit;
|
|
53 |
+ ib_int64_t size_bytes, free_limit_bytes;
|
|
54 |
+ dict_table_t* table;
|
|
55 |
+ dict_index_t* index;
|
|
56 |
+ fil_system_t* system;
|
|
57 |
+ fil_node_t* node = NULL;
|
|
58 |
+ fil_space_t* space;
|
|
59 |
+
|
|
60 |
+ buf3 = ut_malloc(2 * UNIV_PAGE_SIZE);
|
|
61 |
+ descr_page = ut_align(buf3, UNIV_PAGE_SIZE);
|
|
62 |
+
|
|
63 |
+ current_lsn = log_get_lsn();
|
|
64 |
+
|
|
65 |
+ /* check the header page's consistency */
|
|
66 |
+ if (buf_page_is_corrupted(page,
|
|
67 |
+ dict_table_flags_to_zip_size(space_flags))) {
|
|
68 |
+ fprintf(stderr, "InnoDB: page 0 of %s seems corrupt.\n", filepath);
|
|
69 |
+ file_is_corrupt = TRUE;
|
|
70 |
+ descr_is_corrupt = TRUE;
|
|
71 |
+ }
|
|
72 |
+
|
|
73 |
+ /* store as first descr page */
|
|
74 |
+ memcpy(descr_page, page, UNIV_PAGE_SIZE);
|
|
75 |
+
|
|
76 |
+ /* get free limit (page number) of the table space */
|
|
77 |
+/* these should be same to the definition in fsp0fsp.c */
|
|
78 |
+#define FSP_HEADER_OFFSET FIL_PAGE_DATA
|
|
79 |
+#define FSP_FREE_LIMIT 12
|
|
80 |
+ free_limit = mach_read_from_4(FSP_HEADER_OFFSET + FSP_FREE_LIMIT + page);
|
|
81 |
+ free_limit_bytes = (ib_int64_t)free_limit * (ib_int64_t)UNIV_PAGE_SIZE;
|
|
82 |
+
|
|
83 |
+ /* overwrite fsp header */
|
|
84 |
+ fsp_header_init_fields(page, id, flags);
|
|
85 |
+ mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, id);
|
|
86 |
+ space_id = id;
|
|
87 |
+ space_flags = flags;
|
|
88 |
+ if (mach_read_from_8(page + FIL_PAGE_FILE_FLUSH_LSN) > current_lsn)
|
|
89 |
+ mach_write_to_8(page + FIL_PAGE_FILE_FLUSH_LSN, current_lsn);
|
|
90 |
+ mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
|
|
91 |
+ srv_use_checksums
|
|
92 |
+ ? buf_calc_page_new_checksum(page)
|
|
93 |
+ : BUF_NO_CHECKSUM_MAGIC);
|
|
94 |
+ mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
|
|
95 |
+ srv_use_checksums
|
|
96 |
+ ? buf_calc_page_old_checksum(page)
|
|
97 |
+ : BUF_NO_CHECKSUM_MAGIC);
|
|
98 |
+ success = os_file_write(filepath, file, page, 0, 0, UNIV_PAGE_SIZE);
|
|
99 |
+
|
|
100 |
+ /* get file size */
|
|
101 |
+ os_file_get_size(file, &size_low, &size_high);
|
|
102 |
+ size_bytes = (((ib_int64_t)size_high) << 32)
|
|
103 |
+ + (ib_int64_t)size_low;
|
|
104 |
+
|
|
105 |
+ if (size_bytes < free_limit_bytes) {
|
|
106 |
+ free_limit_bytes = size_bytes;
|
|
107 |
+ if (size_bytes >= FSP_EXTENT_SIZE * UNIV_PAGE_SIZE) {
|
|
108 |
+ fprintf(stderr, "InnoDB: free limit of %s is larger than its real size.\n", filepath);
|
|
109 |
+ file_is_corrupt = TRUE;
|
|
110 |
+ }
|
|
111 |
+ }
|
|
112 |
+
|
|
113 |
+ /* get cruster index information */
|
|
114 |
+ table = dict_table_get_low(name);
|
|
115 |
+ index = dict_table_get_first_index(table);
|
|
116 |
+ ut_a(index->page==3);
|
|
117 |
+
|
|
118 |
+ /* read metadata from .exp file */
|
|
119 |
+ n_index = 0;
|
|
120 |
+ memset(old_id, 0, sizeof(old_id));
|
|
121 |
+ memset(new_id, 0, sizeof(new_id));
|
|
122 |
+ memset(root_page, 0, sizeof(root_page));
|
|
123 |
+
|
|
124 |
+ info_file_path = fil_make_ibd_name(name, FALSE);
|
|
125 |
+ len = strlen(info_file_path);
|
|
126 |
+ info_file_path[len - 3] = 'e';
|
|
127 |
+ info_file_path[len - 2] = 'x';
|
|
128 |
+ info_file_path[len - 1] = 'p';
|
|
129 |
+
|
|
130 |
+ info_file = os_file_create_simple_no_error_handling(innodb_file_data_key,
|
|
131 |
+ info_file_path, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success);
|
|
132 |
+ if (!success) {
|
|
58.1.1
by Fred Linhoss
Reworded text strings in patch file print statements. |
133 |
+ fprintf(stderr, "InnoDB: Cannot open the file: %s\n", info_file_path);
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
134 |
+ file_is_corrupt = TRUE;
|
135 |
+ goto skip_info;
|
|
136 |
+ }
|
|
137 |
+ success = os_file_read(info_file, page, 0, 0, UNIV_PAGE_SIZE);
|
|
138 |
+ if (!success) {
|
|
60.1.1
by Fred Linhoss
Reworded text strings in patch file print statements |
139 |
+ fprintf(stderr, "InnoDB: Cannot read the file: %s\n", info_file_path);
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
140 |
+ file_is_corrupt = TRUE;
|
141 |
+ goto skip_info;
|
|
142 |
+ }
|
|
143 |
+ if (mach_read_from_4(page) != 0x78706f72UL
|
|
144 |
+ || mach_read_from_4(page + 4) != 0x74696e66UL) {
|
|
58.1.1
by Fred Linhoss
Reworded text strings in patch file print statements. |
145 |
+ fprintf(stderr, "InnoDB: %s seems to be an incorrect .exp file.\n", info_file_path);
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
146 |
+ file_is_corrupt = TRUE;
|
147 |
+ goto skip_info;
|
|
148 |
+ }
|
|
149 |
+
|
|
58.1.1
by Fred Linhoss
Reworded text strings in patch file print statements. |
150 |
+ fprintf(stderr, "InnoDB: Import: The extended import of %s is being started.\n", name);
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
151 |
+
|
152 |
+ n_index = mach_read_from_4(page + 8);
|
|
58.1.1
by Fred Linhoss
Reworded text strings in patch file print statements. |
153 |
+ fprintf(stderr, "InnoDB: Import: %lu indexes have been detected.\n", (ulong)n_index);
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
154 |
+ for (i = 0; i < n_index; i++) {
|
155 |
+ new_id[i] =
|
|
156 |
+ dict_table_get_index_on_name(table,
|
|
157 |
+ (char*)(page + (i + 1) * 512 + 12))->id;
|
|
158 |
+ old_id[i] = mach_read_from_8(page + (i + 1) * 512);
|
|
159 |
+ root_page[i] = mach_read_from_4(page + (i + 1) * 512 + 8);
|
|
160 |
+ }
|
|
161 |
+
|
|
162 |
+skip_info:
|
|
163 |
+ if (info_file != -1)
|
|
164 |
+ os_file_close(info_file);
|
|
165 |
+
|
|
166 |
+ /*
|
|
167 |
+ if (size_bytes >= 1024 * 1024) {
|
|
168 |
+ size_bytes = ut_2pow_round(size_bytes, 1024 * 1024);
|
|
169 |
+ }
|
|
170 |
+ */
|
|
171 |
+ if (!(flags & DICT_TF_ZSSIZE_MASK)) {
|
|
172 |
+ mem_heap_t* heap = NULL;
|
|
173 |
+ ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
|
174 |
+ ulint* offsets = offsets_;
|
|
175 |
+ ib_int64_t offset;
|
|
176 |
+
|
|
177 |
+ size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
|
|
178 |
+ /* over write space id of all pages */
|
|
179 |
+ rec_offs_init(offsets_);
|
|
180 |
+
|
|
181 |
+ fprintf(stderr, "InnoDB: Progress in %%:");
|
|
182 |
+
|
|
183 |
+ for (offset = 0; offset < free_limit_bytes; offset += UNIV_PAGE_SIZE) {
|
|
184 |
+ ulint checksum_field;
|
|
185 |
+ ulint old_checksum_field;
|
|
186 |
+ ibool page_is_corrupt;
|
|
187 |
+
|
|
188 |
+ success = os_file_read(file, page,
|
|
189 |
+ (ulint)(offset & 0xFFFFFFFFUL),
|
|
190 |
+ (ulint)(offset >> 32), UNIV_PAGE_SIZE);
|
|
191 |
+
|
|
192 |
+ page_is_corrupt = FALSE;
|
|
193 |
+
|
|
194 |
+ /* check consistency */
|
|
195 |
+ if (memcmp(page + FIL_PAGE_LSN + 4,
|
|
196 |
+ page + UNIV_PAGE_SIZE
|
|
197 |
+ - FIL_PAGE_END_LSN_OLD_CHKSUM + 4, 4)) {
|
|
198 |
+
|
|
199 |
+ page_is_corrupt = TRUE;
|
|
200 |
+ }
|
|
201 |
+
|
|
202 |
+ if (mach_read_from_4(page + FIL_PAGE_OFFSET)
|
|
203 |
+ != offset / UNIV_PAGE_SIZE) {
|
|
204 |
+
|
|
205 |
+ page_is_corrupt = TRUE;
|
|
206 |
+ }
|
|
207 |
+
|
|
208 |
+ checksum_field = mach_read_from_4(page
|
|
209 |
+ + FIL_PAGE_SPACE_OR_CHKSUM);
|
|
210 |
+
|
|
211 |
+ old_checksum_field = mach_read_from_4(
|
|
212 |
+ page + UNIV_PAGE_SIZE
|
|
213 |
+ - FIL_PAGE_END_LSN_OLD_CHKSUM);
|
|
214 |
+
|
|
215 |
+ if (old_checksum_field != mach_read_from_4(page
|
|
216 |
+ + FIL_PAGE_LSN)
|
|
217 |
+ && old_checksum_field != BUF_NO_CHECKSUM_MAGIC
|
|
218 |
+ && old_checksum_field
|
|
219 |
+ != buf_calc_page_old_checksum(page)) {
|
|
220 |
+
|
|
221 |
+ page_is_corrupt = TRUE;
|
|
222 |
+ }
|
|
223 |
+
|
|
224 |
+ if (checksum_field != 0
|
|
225 |
+ && checksum_field != BUF_NO_CHECKSUM_MAGIC
|
|
226 |
+ && checksum_field
|
|
227 |
+ != buf_calc_page_new_checksum(page)) {
|
|
228 |
+
|
|
229 |
+ page_is_corrupt = TRUE;
|
|
230 |
+ }
|
|
231 |
+
|
|
232 |
+ /* if it is free page, inconsistency is acceptable */
|
|
233 |
+ if (!offset) {
|
|
234 |
+ /* header page*/
|
|
235 |
+ /* it should be overwritten already */
|
|
236 |
+ ut_a(!page_is_corrupt);
|
|
237 |
+
|
|
238 |
+ } else if (!((offset / UNIV_PAGE_SIZE) % UNIV_PAGE_SIZE)) {
|
|
239 |
+ /* descr page (not header) */
|
|
240 |
+ if (page_is_corrupt) {
|
|
241 |
+ file_is_corrupt = TRUE;
|
|
242 |
+ descr_is_corrupt = TRUE;
|
|
243 |
+ } else {
|
|
87
by kinoyasu
fix bug727704. -- bug716575 is not for 5.5.x. I dont remember when I fixed already |
244 |
+ ut_ad(fil_page_get_type(page) == FIL_PAGE_TYPE_XDES);
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
245 |
+ descr_is_corrupt = FALSE;
|
246 |
+ }
|
|
247 |
+
|
|
248 |
+ /* store as descr page */
|
|
249 |
+ memcpy(descr_page, page, UNIV_PAGE_SIZE);
|
|
250 |
+
|
|
251 |
+ } else if (descr_is_corrupt) {
|
|
252 |
+ /* unknown state of the page */
|
|
253 |
+ if (page_is_corrupt) {
|
|
254 |
+ file_is_corrupt = TRUE;
|
|
255 |
+ }
|
|
256 |
+
|
|
257 |
+ } else {
|
|
258 |
+ /* check free page or not */
|
|
259 |
+ /* These definitions should be same to fsp0fsp.c */
|
|
260 |
+#define FSP_HEADER_SIZE (32 + 5 * FLST_BASE_NODE_SIZE)
|
|
261 |
+
|
|
262 |
+#define XDES_BITMAP (FLST_NODE_SIZE + 12)
|
|
263 |
+#define XDES_BITS_PER_PAGE 2
|
|
264 |
+#define XDES_FREE_BIT 0
|
|
265 |
+#define XDES_SIZE \
|
|
266 |
+ (XDES_BITMAP + UT_BITS_IN_BYTES(FSP_EXTENT_SIZE * XDES_BITS_PER_PAGE))
|
|
267 |
+#define XDES_ARR_OFFSET (FSP_HEADER_OFFSET + FSP_HEADER_SIZE)
|
|
268 |
+
|
|
269 |
+ /*descr = descr_page + XDES_ARR_OFFSET + XDES_SIZE * xdes_calc_descriptor_index(zip_size, offset)*/
|
|
270 |
+ /*xdes_get_bit(descr, XDES_FREE_BIT, page % FSP_EXTENT_SIZE, mtr)*/
|
|
271 |
+ byte* descr;
|
|
272 |
+ ulint index;
|
|
273 |
+ ulint byte_index;
|
|
274 |
+ ulint bit_index;
|
|
275 |
+
|
|
276 |
+ descr = descr_page + XDES_ARR_OFFSET
|
|
277 |
+ + XDES_SIZE * (ut_2pow_remainder((offset / UNIV_PAGE_SIZE), UNIV_PAGE_SIZE) / FSP_EXTENT_SIZE);
|
|
278 |
+
|
|
279 |
+ index = XDES_FREE_BIT + XDES_BITS_PER_PAGE * ((offset / UNIV_PAGE_SIZE) % FSP_EXTENT_SIZE);
|
|
280 |
+ byte_index = index / 8;
|
|
281 |
+ bit_index = index % 8;
|
|
282 |
+
|
|
283 |
+ if (ut_bit_get_nth(mach_read_from_1(descr + XDES_BITMAP + byte_index), bit_index)) {
|
|
284 |
+ /* free page */
|
|
285 |
+ if (page_is_corrupt) {
|
|
286 |
+ goto skip_write;
|
|
287 |
+ }
|
|
288 |
+ } else {
|
|
289 |
+ /* not free */
|
|
290 |
+ if (page_is_corrupt) {
|
|
291 |
+ file_is_corrupt = TRUE;
|
|
292 |
+ }
|
|
293 |
+ }
|
|
294 |
+ }
|
|
295 |
+
|
|
296 |
+ if (page_is_corrupt) {
|
|
297 |
+ fprintf(stderr, " [errp:%lld]", offset / UNIV_PAGE_SIZE);
|
|
298 |
+
|
|
299 |
+ /* cannot treat corrupt page */
|
|
300 |
+ goto skip_write;
|
|
301 |
+ }
|
|
302 |
+
|
|
303 |
+ if (mach_read_from_4(page + FIL_PAGE_OFFSET) || !offset) {
|
|
304 |
+ mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, id);
|
|
305 |
+
|
|
306 |
+ for (i = 0; i < n_index; i++) {
|
|
307 |
+ if (offset / UNIV_PAGE_SIZE == root_page[i]) {
|
|
308 |
+ /* this is index root page */
|
|
309 |
+ mach_write_to_4(page + FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
|
|
310 |
+ + FSEG_HDR_SPACE, id);
|
|
311 |
+ mach_write_to_4(page + FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
|
|
312 |
+ + FSEG_HDR_SPACE, id);
|
|
313 |
+ break;
|
|
314 |
+ }
|
|
315 |
+ }
|
|
316 |
+
|
|
317 |
+ if (fil_page_get_type(page) == FIL_PAGE_INDEX) {
|
|
318 |
+ index_id_t tmp = mach_read_from_8(page + (PAGE_HEADER + PAGE_INDEX_ID));
|
|
319 |
+
|
|
320 |
+ if (mach_read_from_2(page + PAGE_HEADER + PAGE_LEVEL) == 0
|
|
321 |
+ && old_id[0] == tmp) {
|
|
322 |
+ /* leaf page of cluster index, reset trx_id of records */
|
|
323 |
+ rec_t* rec;
|
|
324 |
+ rec_t* supremum;
|
|
325 |
+ ulint n_recs;
|
|
326 |
+
|
|
327 |
+ supremum = page_get_supremum_rec(page);
|
|
328 |
+ rec = page_rec_get_next(page_get_infimum_rec(page));
|
|
329 |
+ n_recs = page_get_n_recs(page);
|
|
330 |
+
|
|
331 |
+ while (rec && rec != supremum && n_recs > 0) {
|
|
332 |
+ ulint n_fields;
|
|
333 |
+ ulint i;
|
|
334 |
+ ulint offset = index->trx_id_offset;
|
|
335 |
+ offsets = rec_get_offsets(rec, index, offsets,
|
|
336 |
+ ULINT_UNDEFINED, &heap);
|
|
337 |
+ n_fields = rec_offs_n_fields(offsets);
|
|
338 |
+ if (!offset) {
|
|
339 |
+ offset = row_get_trx_id_offset(rec, index, offsets);
|
|
340 |
+ }
|
|
341 |
+ trx_write_trx_id(rec + offset, 1);
|
|
342 |
+
|
|
343 |
+ for (i = 0; i < n_fields; i++) {
|
|
344 |
+ if (rec_offs_nth_extern(offsets, i)) {
|
|
345 |
+ ulint local_len;
|
|
346 |
+ byte* data;
|
|
347 |
+
|
|
348 |
+ data = rec_get_nth_field(rec, offsets, i, &local_len);
|
|
349 |
+
|
|
350 |
+ local_len -= BTR_EXTERN_FIELD_REF_SIZE;
|
|
351 |
+
|
|
352 |
+ mach_write_to_4(data + local_len + BTR_EXTERN_SPACE_ID, id);
|
|
353 |
+ }
|
|
354 |
+ }
|
|
355 |
+
|
|
356 |
+ rec = page_rec_get_next(rec);
|
|
357 |
+ n_recs--;
|
|
358 |
+ }
|
|
359 |
+ }
|
|
360 |
+
|
|
361 |
+ for (i = 0; i < n_index; i++) {
|
|
362 |
+ if (old_id[i] == tmp) {
|
|
363 |
+ mach_write_to_8(page + (PAGE_HEADER + PAGE_INDEX_ID), new_id[i]);
|
|
364 |
+ break;
|
|
365 |
+ }
|
|
366 |
+ }
|
|
367 |
+ }
|
|
368 |
+
|
|
369 |
+ if (mach_read_from_8(page + FIL_PAGE_LSN) > current_lsn) {
|
|
370 |
+ mach_write_to_8(page + FIL_PAGE_LSN, current_lsn);
|
|
371 |
+ mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
|
|
372 |
+ current_lsn);
|
|
373 |
+ }
|
|
374 |
+
|
|
375 |
+ mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
|
|
376 |
+ srv_use_checksums
|
|
377 |
+ ? buf_calc_page_new_checksum(page)
|
|
378 |
+ : BUF_NO_CHECKSUM_MAGIC);
|
|
379 |
+ mach_write_to_4(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM,
|
|
380 |
+ srv_use_checksums
|
|
381 |
+ ? buf_calc_page_old_checksum(page)
|
|
382 |
+ : BUF_NO_CHECKSUM_MAGIC);
|
|
383 |
+
|
|
384 |
+ success = os_file_write(filepath, file, page,
|
|
385 |
+ (ulint)(offset & 0xFFFFFFFFUL),
|
|
386 |
+ (ulint)(offset >> 32), UNIV_PAGE_SIZE);
|
|
387 |
+ }
|
|
388 |
+
|
|
389 |
+skip_write:
|
|
390 |
+ if (free_limit_bytes
|
|
391 |
+ && ((ib_int64_t)((offset + UNIV_PAGE_SIZE) * 100) / free_limit_bytes)
|
|
392 |
+ != ((offset * 100) / free_limit_bytes)) {
|
|
393 |
+ fprintf(stderr, " %lu",
|
|
394 |
+ (ulong)((ib_int64_t)((offset + UNIV_PAGE_SIZE) * 100) / free_limit_bytes));
|
|
395 |
+ }
|
|
396 |
+ }
|
|
397 |
+
|
|
398 |
+ fprintf(stderr, " done.\n");
|
|
399 |
+
|
|
400 |
+ /* update SYS_INDEXES set root page */
|
|
401 |
+ index = dict_table_get_first_index(table);
|
|
402 |
+ while (index) {
|
|
403 |
+ for (i = 0; i < n_index; i++) {
|
|
404 |
+ if (new_id[i] == index->id) {
|
|
405 |
+ break;
|
|
406 |
+ }
|
|
407 |
+ }
|
|
408 |
+
|
|
409 |
+ if (i != n_index
|
|
410 |
+ && root_page[i] != index->page) {
|
|
411 |
+ /* must update */
|
|
412 |
+ ulint error;
|
|
413 |
+ trx_t* trx;
|
|
414 |
+ pars_info_t* info = NULL;
|
|
415 |
+
|
|
416 |
+ trx = trx_allocate_for_mysql();
|
|
417 |
+ trx->op_info = "extended import";
|
|
418 |
+
|
|
419 |
+ info = pars_info_create();
|
|
420 |
+
|
|
421 |
+ pars_info_add_ull_literal(info, "indexid", new_id[i]);
|
|
422 |
+ pars_info_add_int4_literal(info, "new_page", (lint) root_page[i]);
|
|
423 |
+
|
|
424 |
+ error = que_eval_sql(info,
|
|
425 |
+ "PROCEDURE UPDATE_INDEX_PAGE () IS\n"
|
|
426 |
+ "BEGIN\n"
|
|
427 |
+ "UPDATE SYS_INDEXES"
|
|
428 |
+ " SET PAGE_NO = :new_page"
|
|
429 |
+ " WHERE ID = :indexid;\n"
|
|
430 |
+ "COMMIT WORK;\n"
|
|
431 |
+ "END;\n",
|
|
432 |
+ FALSE, trx);
|
|
433 |
+
|
|
434 |
+ if (error != DB_SUCCESS) {
|
|
435 |
+ fprintf(stderr, "InnoDB: failed to update SYS_INDEXES\n");
|
|
436 |
+ }
|
|
437 |
+
|
|
438 |
+ trx_commit_for_mysql(trx);
|
|
439 |
+
|
|
440 |
+ trx_free_for_mysql(trx);
|
|
441 |
+
|
|
442 |
+ index->page = root_page[i];
|
|
443 |
+ }
|
|
444 |
+
|
|
445 |
+ index = dict_table_get_next_index(index);
|
|
446 |
+ }
|
|
447 |
+ if (UNIV_LIKELY_NULL(heap)) {
|
|
448 |
+ mem_heap_free(heap);
|
|
449 |
+ }
|
|
450 |
+ } else {
|
|
451 |
+ /* zip page? */
|
|
452 |
+ size = (ulint)
|
|
453 |
+ (size_bytes
|
|
454 |
+ / dict_table_flags_to_zip_size(flags));
|
|
58.1.1
by Fred Linhoss
Reworded text strings in patch file print statements. |
455 |
+ fprintf(stderr, "InnoDB: Import: The table %s seems to be in a newer format."
|
456 |
+ " It may not be possible to process it.\n", name);
|
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
457 |
+ }
|
458 |
+ /* .exp file should be removed */
|
|
459 |
+ success = os_file_delete(info_file_path);
|
|
460 |
+ if (!success) {
|
|
461 |
+ success = os_file_delete_if_exists(info_file_path);
|
|
462 |
+ }
|
|
463 |
+ mem_free(info_file_path);
|
|
464 |
+
|
|
465 |
+ system = fil_system;
|
|
466 |
+ mutex_enter(&(system->mutex));
|
|
467 |
+ space = fil_space_get_by_id(id);
|
|
468 |
+ if (space)
|
|
469 |
+ node = UT_LIST_GET_FIRST(space->chain);
|
|
470 |
+ if (node && node->size < size) {
|
|
471 |
+ space->size += (size - node->size);
|
|
472 |
+ node->size = size;
|
|
473 |
+ }
|
|
474 |
+ mutex_exit(&(system->mutex));
|
|
475 |
+
|
|
476 |
+ ut_free(buf3);
|
|
477 |
+
|
|
478 |
+ if (file_is_corrupt) {
|
|
479 |
+ ut_print_timestamp(stderr);
|
|
480 |
+ fputs(" InnoDB: Error: file ",
|
|
481 |
+ stderr);
|
|
482 |
+ ut_print_filename(stderr, filepath);
|
|
483 |
+ fprintf(stderr, " seems to be corrupt.\n"
|
|
60.1.1
by Fred Linhoss
Reworded text strings in patch file print statements |
484 |
+ "InnoDB: An attempt to convert and salvage all corrupt pages was not made.\n"
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
485 |
+ "InnoDB: ##### CAUTION #####\n"
|
60.1.1
by Fred Linhoss
Reworded text strings in patch file print statements |
486 |
+ "InnoDB: ## The .ibd file may cause InnoDB to crash, even though its re-import seems to have succeeded.\n"
|
487 |
+ "InnoDB: ## If you don't know how to salvage data from a .ibd, you should not use the file.\n"
|
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
488 |
+ "InnoDB: ###################\n");
|
489 |
+ success = FALSE;
|
|
490 |
+
|
|
491 |
+ ut_free(buf2);
|
|
492 |
+
|
|
493 |
+ goto func_exit;
|
|
494 |
+ }
|
|
495 |
+ }
|
|
496 |
+
|
|
497 |
ut_free(buf2); |
|
498 |
||
499 |
if (UNIV_UNLIKELY(space_id != id |
|
500 |
diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
|
|
501 |
--- a/storage/innobase/handler/ha_innodb.cc 2010-12-03 15:49:59.195023983 +0900
|
|
502 |
+++ b/storage/innobase/handler/ha_innodb.cc 2010-12-03 15:52:23.555957062 +0900
|
|
88.2.2
by Yasufumi Kinoshita
Yasufumi patches are ported to 5.5.10; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
503 |
@@ -7356,6 +7356,14 @@
|
18
by kinoyasu
expand_import_fix4autoinc; try to fix bug688866 by removing optimism; other fixes for innodb_adaptive_hash_index_partitions |
504 |
err = row_discard_tablespace_for_mysql(dict_table->name, trx); |
505 |
} else { |
|
506 |
err = row_import_tablespace_for_mysql(dict_table->name, trx); |
|
507 |
+
|
|
508 |
+ /* in expanded import mode re-initialize auto_increment again */
|
|
509 |
+ if ((err == DB_SUCCESS) && srv_expand_import &&
|
|
510 |
+ (table->found_next_number_field != NULL)) {
|
|
511 |
+ dict_table_autoinc_lock(dict_table);
|
|
512 |
+ innobase_initialize_autoinc();
|
|
513 |
+ dict_table_autoinc_unlock(dict_table);
|
|
514 |
+ }
|
|
515 |
} |
|
516 |
||
517 |
err = convert_error_code_to_mysql(err, dict_table->flags, NULL); |
|
88.2.2
by Yasufumi Kinoshita
Yasufumi patches are ported to 5.5.10; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
518 |
@@ -11618,6 +11626,11 @@
|
74
by kinoyasu
innodb_enable_unsafe_group_commit variable was removed, because innodb_support_xa=OFF is enough for the purpose of current InnoDB implementation. |
519 |
"Choose method of innodb_adaptive_flushing. (native, [estimate], keep_average)", |
520 |
NULL, innodb_adaptive_flushing_method_update, 1, &adaptive_flushing_method_typelib); |
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
521 |
|
88
by Yasufumi Kinoshita
fix bug721611 (rename variables) |
522 |
+static MYSQL_SYSVAR_ULONG(import_table_from_xtrabackup, srv_expand_import,
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
523 |
+ PLUGIN_VAR_RQCMDARG,
|
524 |
+ "Enable/Disable converting automatically *.ibd files when import tablespace.",
|
|
525 |
+ NULL, NULL, 0, 0, 1, 0);
|
|
526 |
+
|
|
527 |
static MYSQL_SYSVAR_ULONG(extra_rsegments, srv_extra_rsegments, |
|
528 |
PLUGIN_VAR_RQCMDARG, |
|
529 |
"Number of extra user rollback segments which are used in a round-robin fashion.", |
|
88.2.2
by Yasufumi Kinoshita
Yasufumi patches are ported to 5.5.10; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
530 |
@@ -11695,6 +11708,7 @@
|
74
by kinoyasu
innodb_enable_unsafe_group_commit variable was removed, because innodb_support_xa=OFF is enough for the purpose of current InnoDB implementation. |
531 |
MYSQL_SYSVAR(flush_neighbor_pages), |
59
by kinoyasu
fix bug635399 and bug689450: change about innodb_adaptive_checkpoint and innodb_flush_log_at_trx_commit_session |
532 |
MYSQL_SYSVAR(read_ahead), |
533 |
MYSQL_SYSVAR(adaptive_flushing_method), |
|
88
by Yasufumi Kinoshita
fix bug721611 (rename variables) |
534 |
+ MYSQL_SYSVAR(import_table_from_xtrabackup),
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
535 |
MYSQL_SYSVAR(extra_rsegments), |
536 |
MYSQL_SYSVAR(dict_size_limit), |
|
537 |
MYSQL_SYSVAR(use_sys_malloc), |
|
538 |
diff -ruN a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
|
|
539 |
--- a/storage/innobase/include/srv0srv.h 2010-12-03 15:48:03.077954270 +0900
|
|
540 |
+++ b/storage/innobase/include/srv0srv.h 2010-12-03 15:52:23.561986996 +0900
|
|
88.2.2
by Yasufumi Kinoshita
Yasufumi patches are ported to 5.5.10; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
541 |
@@ -232,6 +232,8 @@
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
542 |
extern ulint srv_read_ahead; |
59
by kinoyasu
fix bug635399 and bug689450: change about innodb_adaptive_checkpoint and innodb_flush_log_at_trx_commit_session |
543 |
extern ulint srv_adaptive_flushing_method; |
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
544 |
|
545 |
+extern ulint srv_expand_import;
|
|
546 |
+
|
|
547 |
extern ulint srv_extra_rsegments; |
|
548 |
extern ulint srv_dict_size_limit; |
|
549 |
/*-------------------------------------------*/ |
|
550 |
diff -ruN a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c
|
|
551 |
--- a/storage/innobase/srv/srv0srv.c 2010-12-03 15:49:59.230956118 +0900
|
|
552 |
+++ b/storage/innobase/srv/srv0srv.c 2010-12-03 15:52:23.562954411 +0900
|
|
88.2.2
by Yasufumi Kinoshita
Yasufumi patches are ported to 5.5.10; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
553 |
@@ -420,6 +420,8 @@
|
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
554 |
UNIV_INTERN ulint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */ |
59
by kinoyasu
fix bug635399 and bug689450: change about innodb_adaptive_checkpoint and innodb_flush_log_at_trx_commit_session |
555 |
UNIV_INTERN ulint srv_adaptive_flushing_method = 0; /* 0: native 1: estimate 2: keep_average */ |
2
by kinoyasu
ported part of Yasufumi patches until innodb_extend_slow.patch |
556 |
|
557 |
+UNIV_INTERN ulint srv_expand_import = 0; /* 0:disable 1:enable */
|
|
558 |
+
|
|
559 |
UNIV_INTERN ulint srv_extra_rsegments = 127; /* extra rseg for users */ |
|
560 |
UNIV_INTERN ulint srv_dict_size_limit = 0; |
|
561 |
/*-------------------------------------------*/ |