~percona-dev/percona-xtrabackup/lp528752_test

202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1
--- a/storage/innobase/btr/btr0btr.c	2010-12-03 09:58:26.000000000 -0800
2
+++ b/storage/innobase/btr/btr0btr.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
3
@@ -120,7 +120,7 @@
4
 /**************************************************************//**
5
 Gets the root node of a tree and x-latches it.
6
 @return	root page, x-latched */
7
-static
8
+//static
9
 buf_block_t*
10
 btr_root_block_get(
11
 /*===============*/
12
@@ -566,7 +566,7 @@
13
 /************************************************************//**
14
 Returns the child page of a node pointer and x-latches it.
15
 @return	child page, x-latched */
16
-static
17
+//static
18
 buf_block_t*
19
 btr_node_ptr_get_child(
20
 /*===================*/
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
21
--- a/storage/innobase/buf/buf0buf.c	2010-12-03 09:58:26.000000000 -0800
22
+++ b/storage/innobase/buf/buf0buf.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
23
@@ -517,7 +517,7 @@
24
 		return(TRUE);
25
 	}
26
 
27
-#ifndef UNIV_HOTBACKUP
28
+#ifdef UNDEFINED
29
 	if (recv_lsn_checks_on) {
30
 		ib_uint64_t	current_lsn;
31
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
32
@@ -4055,7 +4055,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
33
 			recv_recover_page(TRUE, (buf_block_t*) bpage);
34
 		}
35
 
36
-		if (uncompressed && !recv_no_ibuf_operations) {
37
+		if (uncompressed && !recv_no_ibuf_operations && !srv_fake_write) {
38
 			ibuf_merge_or_delete_for_page(
39
 				(buf_block_t*) bpage, bpage->space,
40
 				bpage->offset, buf_page_get_zip_size(bpage),
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
41
--- a/storage/innobase/buf/buf0rea.c	2010-12-03 09:58:26.000000000 -0800
42
+++ b/storage/innobase/buf/buf0rea.c	2010-12-15 13:29:50.000000000 -0800
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
43
@@ -122,6 +122,45 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
44
 	bpage = buf_page_init_for_read(err, mode, space, zip_size, unzip,
45
 				       tablespace_version, offset);
46
 	if (bpage == NULL) {
47
+		if (recv_recovery_is_on() && *err == DB_TABLESPACE_DELETED) {
48
+			/* hashed log recs must be treated here */
49
+			recv_addr_t*    recv_addr;
50
+
51
+			mutex_enter(&(recv_sys->mutex));
52
+
53
+			if (recv_sys->apply_log_recs == FALSE) {
54
+				mutex_exit(&(recv_sys->mutex));
55
+				goto not_to_recover;
56
+			}
57
+
58
+			/* recv_get_fil_addr_struct() */
59
+			recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
60
+					hash_calc_hash(ut_fold_ulint_pair(space, offset),
61
+						recv_sys->addr_hash));
62
+			while (recv_addr) {
63
+				if ((recv_addr->space == space)
64
+					&& (recv_addr->page_no == offset)) {
65
+					break;
66
+				}
67
+				recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
68
+			}
69
+
70
+			if ((recv_addr == NULL)
71
+			    || (recv_addr->state == RECV_BEING_PROCESSED)
72
+			    || (recv_addr->state == RECV_PROCESSED)) {
73
+				mutex_exit(&(recv_sys->mutex));
74
+				goto not_to_recover;
75
+			}
76
+
77
+			fprintf(stderr, " (cannot find space: %lu)", space);
78
+			recv_addr->state = RECV_PROCESSED;
79
+
80
+			ut_a(recv_sys->n_addrs);
81
+			recv_sys->n_addrs--;
82
+
83
+			mutex_exit(&(recv_sys->mutex));
84
+		}
85
+not_to_recover:
86
 
87
 		return(0);
88
 	}
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
89
@@ -604,6 +643,50 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
90
 		/* It is a single table tablespace and the .ibd file is
91
 		missing: do nothing */
92
 
93
+		/* the log records should be treated here same reason
94
+		for http://bugs.mysql.com/bug.php?id=43948 */
95
+
96
+		if (recv_recovery_is_on()) {
97
+			recv_addr_t*    recv_addr;
98
+
99
+			mutex_enter(&(recv_sys->mutex));
100
+
101
+			if (recv_sys->apply_log_recs == FALSE) {
102
+				mutex_exit(&(recv_sys->mutex));
103
+				goto not_to_recover;
104
+			}
105
+
106
+			for (i = 0; i < n_stored; i++) {
107
+				/* recv_get_fil_addr_struct() */
108
+				recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
109
+						hash_calc_hash(ut_fold_ulint_pair(space, page_nos[i]),
110
+							recv_sys->addr_hash));
111
+				while (recv_addr) {
112
+					if ((recv_addr->space == space)
113
+						&& (recv_addr->page_no == page_nos[i])) {
114
+						break;
115
+					}
116
+					recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
117
+				}
118
+
119
+				if ((recv_addr == NULL)
120
+				    || (recv_addr->state == RECV_BEING_PROCESSED)
121
+				    || (recv_addr->state == RECV_PROCESSED)) {
122
+					continue;
123
+				}
124
+
125
+				recv_addr->state = RECV_PROCESSED;
126
+
127
+				ut_a(recv_sys->n_addrs);
128
+				recv_sys->n_addrs--;
129
+			}
130
+
131
+			mutex_exit(&(recv_sys->mutex));
132
+
133
+			fprintf(stderr, " (cannot find space: %lu)", space);
134
+		}
135
+not_to_recover:
136
+
137
 		return;
138
 	}
139
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
140
--- a/storage/innobase/fil/fil0fil.c	2010-12-03 09:58:26.000000000 -0800
141
+++ b/storage/innobase/fil/fil0fil.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
142
@@ -40,6 +40,8 @@
143
 #include "dict0dict.h"
144
 #include "page0page.h"
145
 #include "page0zip.h"
146
+#include "pars0pars.h"
147
+#include "que0que.h"
148
 #ifndef UNIV_HOTBACKUP
149
 # include "buf0lru.h"
150
 # include "ibuf0ibuf.h"
151
@@ -297,7 +299,7 @@
152
 
153
 /** The tablespace memory cache. This variable is NULL before the module is
154
 initialized. */
155
-static fil_system_t*	fil_system	= NULL;
156
+fil_system_t*	fil_system	= NULL;
157
 
158
 
159
 /********************************************************************//**
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
160
@@ -308,7 +310,7 @@
161
 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
162
 mutex. */
163
 static
164
-void
165
+ulint
166
 fil_node_prepare_for_io(
167
 /*====================*/
168
 	fil_node_t*	node,	/*!< in: file node */
169
@@ -633,7 +635,7 @@
170
 Opens a the file of a node of a tablespace. The caller must own the fil_system
171
 mutex. */
172
 static
173
-void
174
+ulint
175
 fil_node_open_file(
176
 /*===============*/
177
 	fil_node_t*	node,	/*!< in: file node */
178
@@ -668,7 +670,14 @@
179
 			OS_FILE_READ_ONLY, &success);
180
 		if (!success) {
181
 			/* The following call prints an error message */
182
-			os_file_get_last_error(TRUE);
183
+			if (os_file_get_last_error(TRUE) == OS_FILE_NOT_FOUND)
184
+			{
185
+				ut_print_timestamp(stderr);
186
+				fprintf(stderr,
187
+					" InnoDB: Warning: cannot open %s\n",
188
+					node->name);
189
+				return(OS_FILE_NOT_FOUND);
190
+			}
191
 
192
 			ut_print_timestamp(stderr);
193
 
194
@@ -758,8 +767,8 @@
188 by kinoyasu
fix fil_node_open_file() for exact file size after applying .delta
195
 		}
196
 
197
 		if (size_bytes >= 1024 * 1024) {
198
-			/* Truncate the size to whole megabytes. */
199
-			size_bytes = ut_2pow_round(size_bytes, 1024 * 1024);
200
+			/* The size should be exact for after applying .delta */
201
+			//size_bytes = ut_2pow_round(size_bytes, 1024 * 1024);
202
 		}
203
 
204
 		if (!(flags & DICT_TF_ZSSIZE_MASK)) {
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
205
@@ -810,6 +819,8 @@
206
 		/* Put the node to the LRU list */
207
 		UT_LIST_ADD_FIRST(LRU, system->LRU, node);
208
 	}
209
+
210
+	return(0);
211
 }
212
 
213
 /**********************************************************************//**
214
@@ -1435,7 +1446,12 @@
215
 		the file yet; the following calls will open it and update the
216
 		size fields */
217
 
218
-		fil_node_prepare_for_io(node, fil_system, space);
219
+		if (fil_node_prepare_for_io(node, fil_system, space))
220
+		{
221
+			mutex_exit(&fil_system->mutex);
222
+
223
+			return(0);
224
+		}
225
 		fil_node_complete_io(node, fil_system, OS_FILE_READ);
226
 	}
227
 
228
@@ -1487,7 +1503,12 @@
229
 		the file yet; the following calls will open it and update the
230
 		size fields */
231
 
232
-		fil_node_prepare_for_io(node, fil_system, space);
233
+		if (fil_node_prepare_for_io(node, fil_system, space))
234
+		{
235
+			mutex_exit(&fil_system->mutex);
236
+
237
+			return(ULINT_UNDEFINED);
238
+		}
239
 		fil_node_complete_io(node, fil_system, OS_FILE_READ);
240
 	}
241
 
242
@@ -2152,7 +2173,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
243
 			if (fil_create_new_single_table_tablespace(
244
 				    space_id, name, FALSE, flags,
245
 				    FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) {
246
-				ut_error;
247
+				//ut_error;
248
 			}
249
 		}
250
 
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
251
@@ -2315,7 +2336,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
252
 	}
253
 
254
 	if (success) {
255
-#ifndef UNIV_HOTBACKUP
256
+#ifdef UNDEFINED
257
 		/* Write a log record about the deletion of the .ibd
258
 		file, so that ibbackup can replay it in the
259
 		--apply-log phase. We use a dummy mtr and the familiar
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
260
@@ -2616,7 +2637,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
261
 
262
 	mutex_exit(&fil_system->mutex);
263
 
264
-#ifndef UNIV_HOTBACKUP
265
+#ifdef UNDEFINED
266
 	if (success) {
267
 		mtr_t		mtr;
268
 
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
269
@@ -2807,7 +2828,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
270
 
271
 	fil_node_create(path, size, space_id, FALSE);
272
 
273
-#ifndef UNIV_HOTBACKUP
274
+#ifdef UNDEFINED
275
 	{
276
 		mtr_t		mtr;
277
 
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
278
@@ -3062,19 +3083,97 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
279
 		      "InnoDB: open the tablespace file ", stderr);
280
 		ut_print_filename(stderr, filepath);
281
 		fputs("!\n"
282
-		      "InnoDB: Have you moved InnoDB .ibd files around"
283
-		      " without using the\n"
284
-		      "InnoDB: commands DISCARD TABLESPACE and"
285
-		      " IMPORT TABLESPACE?\n"
286
-		      "InnoDB: It is also possible that this is"
287
-		      " a temporary table #sql...,\n"
288
-		      "InnoDB: and MySQL removed the .ibd file for this.\n"
289
-		      "InnoDB: Please refer to\n"
290
-		      "InnoDB: " REFMAN "innodb-troubleshooting-datadict.html\n"
291
-		      "InnoDB: for how to resolve the issue.\n", stderr);
292
+		      "InnoDB: It will be removed from data dictionary.\n"
293
+		      , stderr);
294
 
295
 		mem_free(filepath);
296
 
297
+		/* removing from data dictionary */
298
+		{
299
+			trx_t*		trx;
300
+			pars_info_t*	info = NULL;
301
+
302
+			trx = trx_allocate_for_mysql();
303
+
304
+			trx->op_info = "removing invalid table from data dictionary";
305
+
306
+			info = pars_info_create();
307
+
308
+			pars_info_add_str_literal(info, "table_name", name);
309
+
310
+			que_eval_sql(info,
311
+			   "PROCEDURE DROP_TABLE_PROC () IS\n"
312
+			   "sys_foreign_id CHAR;\n"
313
+			   "table_id CHAR;\n"
314
+			   "index_id CHAR;\n"
315
+			   "foreign_id CHAR;\n"
316
+			   "found INT;\n"
317
+			   "BEGIN\n"
318
+			   "SELECT ID INTO table_id\n"
319
+			   "FROM SYS_TABLES\n"
320
+			   "WHERE NAME = :table_name\n"
321
+			   "LOCK IN SHARE MODE;\n"
322
+			   "IF (SQL % NOTFOUND) THEN\n"
323
+			   "       RETURN;\n"
324
+			   "END IF;\n"
325
+			   "found := 1;\n"
326
+			   "SELECT ID INTO sys_foreign_id\n"
327
+			   "FROM SYS_TABLES\n"
328
+			   "WHERE NAME = 'SYS_FOREIGN'\n"
329
+			   "LOCK IN SHARE MODE;\n"
330
+			   "IF (SQL % NOTFOUND) THEN\n"
331
+			   "       found := 0;\n"
332
+			   "END IF;\n"
333
+			   "IF (:table_name = 'SYS_FOREIGN') THEN\n"
334
+			   "       found := 0;\n"
335
+			   "END IF;\n"
336
+			   "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n"
337
+			   "       found := 0;\n"
338
+			   "END IF;\n"
339
+			   "WHILE found = 1 LOOP\n"
340
+			   "       SELECT ID INTO foreign_id\n"
341
+			   "       FROM SYS_FOREIGN\n"
342
+			   "       WHERE FOR_NAME = :table_name\n"
343
+			   "               AND TO_BINARY(FOR_NAME)\n"
344
+			   "                 = TO_BINARY(:table_name)\n"
345
+			   "               LOCK IN SHARE MODE;\n"
346
+			   "       IF (SQL % NOTFOUND) THEN\n"
347
+			   "               found := 0;\n"
348
+			   "       ELSE\n"
349
+			   "               DELETE FROM SYS_FOREIGN_COLS\n"
350
+			   "               WHERE ID = foreign_id;\n"
351
+			   "               DELETE FROM SYS_FOREIGN\n"
352
+			   "               WHERE ID = foreign_id;\n"
353
+			   "       END IF;\n"
354
+			   "END LOOP;\n"
355
+			   "found := 1;\n"
356
+			   "WHILE found = 1 LOOP\n"
357
+			   "       SELECT ID INTO index_id\n"
358
+			   "       FROM SYS_INDEXES\n"
359
+			   "       WHERE TABLE_ID = table_id\n"
360
+			   "       LOCK IN SHARE MODE;\n"
361
+			   "       IF (SQL % NOTFOUND) THEN\n"
362
+			   "               found := 0;\n"
363
+			   "       ELSE\n"
364
+			   "               DELETE FROM SYS_FIELDS\n"
365
+			   "               WHERE INDEX_ID = index_id;\n"
366
+			   "               DELETE FROM SYS_INDEXES\n"
367
+			   "               WHERE ID = index_id\n"
368
+			   "               AND TABLE_ID = table_id;\n"
369
+			   "       END IF;\n"
370
+			   "END LOOP;\n"
371
+			   "DELETE FROM SYS_COLUMNS\n"
372
+			   "WHERE TABLE_ID = table_id;\n"
373
+			   "DELETE FROM SYS_TABLES\n"
374
+			   "WHERE ID = table_id;\n"
375
+			   "END;\n"
376
+			   , FALSE, trx);
377
+
378
+			trx_commit_for_mysql(trx);
379
+
380
+			trx_free_for_mysql(trx);
381
+		}
382
+
383
 		return(FALSE);
384
 	}
385
 
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
386
@@ -3306,7 +3405,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
387
 	cannot be ok. */
388
 
389
 	size = (((ib_int64_t)size_high) << 32) + (ib_int64_t)size_low;
390
-#ifndef UNIV_HOTBACKUP
391
+#ifdef UNDEFINED
392
 	if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
393
 		fprintf(stderr,
394
 			"InnoDB: Error: the size of single-table tablespace"
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
395
@@ -3447,7 +3546,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
396
 idea is to read as much good data as we can and jump over bad data.
397
 @return 0 if ok, -1 if error even after the retries, 1 if at the end
398
 of the directory */
399
-static
400
+//static
401
 int
402
 fil_file_readdir_next_file(
403
 /*=======================*/
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
404
@@ -3746,15 +3845,97 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
405
 				"InnoDB: in InnoDB data dictionary"
406
 				" has tablespace id %lu,\n"
407
 				"InnoDB: but tablespace with that id"
408
-				" or name does not exist. Have\n"
409
-				"InnoDB: you deleted or moved .ibd files?\n"
410
-				"InnoDB: This may also be a table created with"
411
-				" CREATE TEMPORARY TABLE\n"
412
-				"InnoDB: whose .ibd and .frm files"
413
-				" MySQL automatically removed, but the\n"
414
-				"InnoDB: table still exists in the"
415
-				" InnoDB internal data dictionary.\n",
416
+				" or name does not exist. It will be removed from data dictionary.\n"
417
+				,
418
 				(ulong) id);
419
+			mem_free(path);
420
+			mutex_exit(&fil_system->mutex);
421
+			/* removing from data dictionary */
422
+			{
423
+				trx_t*		trx;
424
+				pars_info_t*	info = NULL;
425
+
426
+				trx = trx_allocate_for_mysql();
427
+
428
+				trx->op_info = "removing invalid table from data dictionary";
429
+
430
+				info = pars_info_create();
431
+
432
+				pars_info_add_str_literal(info, "table_name", name);
433
+
434
+				que_eval_sql(info,
435
+				   "PROCEDURE DROP_TABLE_PROC () IS\n"
436
+				   "sys_foreign_id CHAR;\n"
437
+				   "table_id CHAR;\n"
438
+				   "index_id CHAR;\n"
439
+				   "foreign_id CHAR;\n"
440
+				   "found INT;\n"
441
+				   "BEGIN\n"
442
+				   "SELECT ID INTO table_id\n"
443
+				   "FROM SYS_TABLES\n"
444
+				   "WHERE NAME = :table_name\n"
445
+				   "LOCK IN SHARE MODE;\n"
446
+				   "IF (SQL % NOTFOUND) THEN\n"
447
+				   "       RETURN;\n"
448
+				   "END IF;\n"
449
+				   "found := 1;\n"
450
+				   "SELECT ID INTO sys_foreign_id\n"
451
+				   "FROM SYS_TABLES\n"
452
+				   "WHERE NAME = 'SYS_FOREIGN'\n"
453
+				   "LOCK IN SHARE MODE;\n"
454
+				   "IF (SQL % NOTFOUND) THEN\n"
455
+				   "       found := 0;\n"
456
+				   "END IF;\n"
457
+				   "IF (:table_name = 'SYS_FOREIGN') THEN\n"
458
+				   "       found := 0;\n"
459
+				   "END IF;\n"
460
+				   "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n"
461
+				   "       found := 0;\n"
462
+				   "END IF;\n"
463
+				   "WHILE found = 1 LOOP\n"
464
+				   "       SELECT ID INTO foreign_id\n"
465
+				   "       FROM SYS_FOREIGN\n"
466
+				   "       WHERE FOR_NAME = :table_name\n"
467
+				   "               AND TO_BINARY(FOR_NAME)\n"
468
+				   "                 = TO_BINARY(:table_name)\n"
469
+				   "               LOCK IN SHARE MODE;\n"
470
+				   "       IF (SQL % NOTFOUND) THEN\n"
471
+				   "               found := 0;\n"
472
+				   "       ELSE\n"
473
+				   "               DELETE FROM SYS_FOREIGN_COLS\n"
474
+				   "               WHERE ID = foreign_id;\n"
475
+				   "               DELETE FROM SYS_FOREIGN\n"
476
+				   "               WHERE ID = foreign_id;\n"
477
+				   "       END IF;\n"
478
+				   "END LOOP;\n"
479
+				   "found := 1;\n"
480
+				   "WHILE found = 1 LOOP\n"
481
+				   "       SELECT ID INTO index_id\n"
482
+				   "       FROM SYS_INDEXES\n"
483
+				   "       WHERE TABLE_ID = table_id\n"
484
+				   "       LOCK IN SHARE MODE;\n"
485
+				   "       IF (SQL % NOTFOUND) THEN\n"
486
+				   "               found := 0;\n"
487
+				   "       ELSE\n"
488
+				   "               DELETE FROM SYS_FIELDS\n"
489
+				   "               WHERE INDEX_ID = index_id;\n"
490
+				   "               DELETE FROM SYS_INDEXES\n"
491
+				   "               WHERE ID = index_id\n"
492
+				   "               AND TABLE_ID = table_id;\n"
493
+				   "       END IF;\n"
494
+				   "END LOOP;\n"
495
+				   "DELETE FROM SYS_COLUMNS\n"
496
+				   "WHERE TABLE_ID = table_id;\n"
497
+				   "DELETE FROM SYS_TABLES\n"
498
+				   "WHERE ID = table_id;\n"
499
+				   "END;\n"
500
+				   , FALSE, trx);
501
+
502
+				trx_commit_for_mysql(trx);
503
+
504
+				trx_free_for_mysql(trx);
505
+			}
506
+			return(FALSE);
507
 		} else {
508
 			ut_print_timestamp(stderr);
509
 			fputs("  InnoDB: Error: table ", stderr);
215 by Alexey Kopytov
Fix for LP bug #713799: race condition when trying to open an already
510
@@ -4143,7 +4324,7 @@
511
 off the LRU list if it is in the LRU list. The caller must hold the fil_sys
512
 mutex. */
513
 static
514
-void
515
+ulint
516
 fil_node_prepare_for_io(
517
 /*====================*/
518
 	fil_node_t*	node,	/*!< in: file node */
519
@@ -4163,10 +4344,13 @@
520
 	}
521
 
522
 	if (node->open == FALSE) {
523
+		ulint	err;
524
 		/* File is closed: open it */
525
 		ut_a(node->n_pending == 0);
526
 
527
-		fil_node_open_file(node, system, space);
528
+		err = fil_node_open_file(node, system, space);
529
+		if (err)
530
+			return(err);
531
 	}
532
 
533
 	if (node->n_pending == 0 && space->purpose == FIL_TABLESPACE
534
@@ -4179,6 +4363,8 @@
535
 	}
536
 
537
 	node->n_pending++;
538
+
539
+	return(0);
540
 }
541
 
542
 /********************************************************************//**
543
@@ -4363,6 +4549,16 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
544
 
545
 	ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
546
 
547
+	if (space->size <= block_offset) {
548
+		ulint	actual_size;
549
+
550
+		mutex_exit(&fil_system->mutex);
551
+		fil_extend_space_to_desired_size(&actual_size, space->id,
552
+						 ((block_offset + 1) / 64 + 1) * 64);
553
+		mutex_enter(&fil_system->mutex);
554
+		/* should retry? but it may safe for xtrabackup for now. */
555
+	}
556
+
557
 	node = UT_LIST_GET_FIRST(space->chain);
558
 
559
 	for (;;) {
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
560
--- a/storage/innobase/ibuf/ibuf0ibuf.c	2010-12-03 09:58:26.000000000 -0800
561
+++ b/storage/innobase/ibuf/ibuf0ibuf.c	2010-12-15 13:29:50.000000000 -0800
562
@@ -1125,6 +1125,9 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
563
 
564
 	ut_ad(!recv_no_ibuf_operations);
565
 
566
+	if (srv_fake_write)
567
+		return(FALSE);
568
+
569
 	if (ibuf_fixed_addr_page(space, zip_size, page_no)) {
570
 
571
 		return(TRUE);
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
572
@@ -2613,6 +2616,9 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
573
 	ulint	n_bytes;
574
 	ulint	n_pag2;
575
 
576
+	if (srv_fake_write)
577
+		return(0);
578
+
579
 	while (sum_pages < n_pages) {
580
 		n_bytes = ibuf_contract_ext(&n_pag2, sync);
581
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
582
--- a/storage/innobase/include/srv0srv.h	2010-12-03 09:58:26.000000000 -0800
583
+++ b/storage/innobase/include/srv0srv.h	2010-12-15 13:29:50.000000000 -0800
584
@@ -211,6 +211,10 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
585
 extern ulong	srv_max_purge_lag;
586
 
587
 extern ulong	srv_replication_delay;
588
+
589
+extern ibool	srv_read_only;
590
+extern ibool	srv_fake_write;
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.
591
+extern ibool	srv_apply_log_only;
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
592
 /*-------------------------------------------*/
593
 
594
 extern ulint	srv_n_rows_inserted;
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
595
--- a/storage/innobase/include/srv0start.h	2010-12-03 09:58:26.000000000 -0800
596
+++ b/storage/innobase/include/srv0start.h	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
597
@@ -91,6 +91,8 @@
598
 /** Log sequence number immediately after startup */
599
 extern	ib_uint64_t	srv_start_lsn;
600
 
601
+extern	ib_uint64_t	srv_oldest_lsn;
602
+
603
 #ifdef HAVE_DARWIN_THREADS
604
 /** TRUE if the F_FULLFSYNC option is available */
605
 extern	ibool	srv_have_fullfsync;
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
606
--- a/storage/innobase/log/log0log.c	2010-12-03 09:58:26.000000000 -0800
607
+++ b/storage/innobase/log/log0log.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
608
@@ -576,7 +576,9 @@
609
 
610
 	offset = (gr_lsn_size_offset + difference) % group_size;
611
 
612
+	if (sizeof(ulint) == 4) {
613
 	ut_a(offset < (((ib_int64_t) 1) << 32)); /* offset must be < 4 GB */
614
+	}
615
 
616
 	/* fprintf(stderr,
617
 	"Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
618
@@ -1354,7 +1356,7 @@
619
 #endif /* UNIV_DEBUG */
620
 	ulint		unlock;
621
 
622
-	if (recv_no_ibuf_operations) {
623
+	if (recv_no_ibuf_operations || srv_fake_write) {
624
 		/* Recovery is running and no operations on the log files are
625
 		allowed yet (the variable name .._no_ibuf_.. is misleading) */
626
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
627
@@ -3114,6 +3116,7 @@
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.
628
 	for the 'very fast' shutdown, because the InnoDB layer may have
629
 	committed or prepared transactions and we don't want to lose them. */
630
 
631
+	if (!srv_apply_log_only) {
632
 	if (trx_n_mysql_transactions > 0
633
 	    || UT_LIST_GET_LEN(trx_sys->trx_list) > 0) {
634
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
635
@@ -3121,6 +3124,7 @@
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.
636
 
637
 		goto loop;
638
 	}
639
+	}
640
 
641
 	if (srv_fast_shutdown == 2) {
642
 		/* In this fastest shutdown we do not flush the buffer pool:
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
643
--- a/storage/innobase/log/log0recv.c	2010-12-03 09:58:26.000000000 -0800
644
+++ b/storage/innobase/log/log0recv.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
645
@@ -42,27 +42,27 @@
646
 #include "trx0undo.h"
647
 #include "trx0rec.h"
648
 #include "fil0fil.h"
649
-#ifndef UNIV_HOTBACKUP
650
+//#ifndef UNIV_HOTBACKUP
651
 # include "buf0rea.h"
652
 # include "srv0srv.h"
653
 # include "srv0start.h"
654
 # include "trx0roll.h"
655
 # include "row0merge.h"
656
 # include "sync0sync.h"
657
-#else /* !UNIV_HOTBACKUP */
658
+//#else /* !UNIV_HOTBACKUP */
659
 
660
 /** This is set to FALSE if the backup was originally taken with the
661
 ibbackup --include regexp option: then we do not want to create tables in
662
 directories which were not included */
663
 UNIV_INTERN ibool	recv_replay_file_ops	= TRUE;
664
-#endif /* !UNIV_HOTBACKUP */
665
+//#endif /* !UNIV_HOTBACKUP */
666
 
667
 /** Log records are stored in the hash table in chunks at most of this size;
668
 this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
669
 #define RECV_DATA_BLOCK_SIZE	(MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
670
 
671
 /** Read-ahead area in applying log records to file pages */
672
-#define RECV_READ_AHEAD_AREA	32
673
+#define RECV_READ_AHEAD_AREA	128
674
 
675
 /** The recovery system */
676
 UNIV_INTERN recv_sys_t*	recv_sys = NULL;
677
@@ -259,7 +259,7 @@
678
 {
679
 	recv_lsn_checks_on = FALSE;
680
 
681
-	recv_n_pool_free_frames = 256;
682
+	recv_n_pool_free_frames = 1024;
683
 
684
 	recv_recovery_on = FALSE;
685
 
686
@@ -285,7 +285,7 @@
687
 
688
 	recv_max_parsed_page_no	= 0;
689
 
690
-	recv_n_pool_free_frames	= 256;
691
+	recv_n_pool_free_frames	= 1024;
692
 
693
 	recv_max_page_lsn = 0;
694
 }
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
695
@@ -623,7 +623,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
696
 /***********************************************************************//**
697
 Checks the consistency of the checkpoint info
698
 @return	TRUE if ok */
699
-static
700
+//static
701
 ibool
702
 recv_check_cp_is_consistent(
703
 /*========================*/
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
704
@@ -653,7 +653,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
705
 /********************************************************//**
706
 Looks for the maximum consistent checkpoint from the log groups.
707
 @return	error code or DB_SUCCESS */
708
-static
709
+//static
710
 ulint
711
 recv_find_max_checkpoint(
712
 /*=====================*/
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
713
@@ -828,7 +828,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
714
 InnoDB-3.23.52 where the checksum field contains the log block number.
715
 @return TRUE if ok, or if the log block may be in the format of InnoDB
716
 version predating 3.23.52 */
717
-static
718
+//static
719
 ibool
720
 log_block_checksum_is_ok_or_old_format(
721
 /*===================================*/
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
722
@@ -1496,6 +1496,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
723
 					     buf_block_get_page_no(block));
724
 
725
 	if ((recv_addr == NULL)
726
+	    || (recv_addr->state == RECV_BEING_READ && !just_read_in)
727
 	    || (recv_addr->state == RECV_BEING_PROCESSED)
728
 	    || (recv_addr->state == RECV_PROCESSED)) {
729
 
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
730
@@ -2308,7 +2309,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
731
 			   || type == MLOG_FILE_RENAME
732
 			   || type == MLOG_FILE_DELETE) {
733
 			ut_a(space);
734
-#ifdef UNIV_HOTBACKUP
735
+//#ifdef UNIV_HOTBACKUP
736
 			if (recv_replay_file_ops) {
737
 
738
 				/* In ibbackup --apply-log, replay an .ibd file
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
739
@@ -2331,7 +2332,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
740
 					ut_error;
741
 				}
742
 			}
743
-#endif
744
+//#endif
745
 			/* In normal mysqld crash recovery we do not try to
746
 			replay file operations */
747
 #ifdef UNIV_LOG_LSN_DEBUG
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
748
@@ -2748,8 +2749,11 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
749
 
750
 			fprintf(stderr,
751
 				"InnoDB: Doing recovery: scanned up to"
752
-				" log sequence number %llu\n",
753
-				*group_scanned_lsn);
754
+				" log sequence number %llu (%lu %)\n",
755
+				*group_scanned_lsn,
756
+				(ulong) (*group_scanned_lsn - srv_oldest_lsn)
757
+				/ (8 * log_group_get_capacity(UT_LIST_GET_FIRST(log_sys->log_groups))/900)
758
+			);
759
 		}
760
 	}
761
 
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
762
@@ -2863,12 +2867,14 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
763
 
764
 	if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
765
 
766
+#ifdef UNDEFINED
767
 		fprintf(stderr,
768
 			"InnoDB: Restoring possible"
769
 			" half-written data pages from"
770
 			" the doublewrite\n"
771
 			"InnoDB: buffer...\n");
772
-		trx_sys_doublewrite_init_or_restore_pages(TRUE);
773
+#endif
774
+		trx_sys_doublewrite_init_or_restore_pages(FALSE);
775
 	}
776
 }
777
 
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
778
@@ -3018,6 +3024,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
779
 		recv_sys->recovered_lsn = checkpoint_lsn;
780
 
781
 		srv_start_lsn = checkpoint_lsn;
782
+		srv_oldest_lsn = checkpoint_lsn;
783
 	}
784
 
785
 	contiguous_lsn = ut_uint64_align_down(recv_sys->scanned_lsn,
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
786
@@ -3299,6 +3306,7 @@
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.
787
 	that the data dictionary tables will be free of any locks.
788
 	The data dictionary latch should guarantee that there is at
789
 	most one data dictionary transaction active at a time. */
790
+	if (!srv_apply_log_only)
791
 	trx_rollback_or_clean_recovered(FALSE);
792
 }
793
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
794
--- a/storage/innobase/os/os0file.c	2010-12-03 09:58:26.000000000 -0800
795
+++ b/storage/innobase/os/os0file.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
796
@@ -631,7 +631,7 @@
797
 }
798
 
799
 #undef USE_FILE_LOCK
800
-#define USE_FILE_LOCK
801
+//#define USE_FILE_LOCK
802
 #if defined(UNIV_HOTBACKUP) || defined(__WIN__)
803
 /* InnoDB Hot Backup does not lock the data files.
804
  * On Windows, mandatory locking is used.
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
805
@@ -1431,8 +1431,9 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
806
 		attributes = 0;
807
 		ut_error;
808
 	}
809
-
810
+	share_mode |= FILE_SHARE_WRITE; /* Why? */
811
 	file = CreateFile((LPCTSTR) name,
812
+			  (srv_read_only && create_flag == OPEN_EXISTING) ? GENERIC_READ :
813
 			  GENERIC_READ | GENERIC_WRITE, /* read and write
814
 							access */
815
 			  share_mode,	/* File can be read also by other
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
816
@@ -1491,7 +1492,11 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
817
 	if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW
818
 	    || create_mode == OS_FILE_OPEN_RETRY) {
819
 		mode_str = "OPEN";
820
-		create_flag = O_RDWR;
821
+		if (srv_read_only) {
822
+			create_flag = O_RDONLY;
823
+		} else {
824
+			create_flag = O_RDWR;
825
+		}
826
 	} else if (create_mode == OS_FILE_CREATE) {
827
 		mode_str = "CREATE";
828
 		create_flag = O_RDWR | O_CREAT | O_EXCL;
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
829
@@ -2669,6 +2674,9 @@
830
 	ut_a((offset & 0xFFFFFFFFUL) == offset);
831
 	ut_a((n & 0xFFFFFFFFUL) == n);
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
832
 
833
+	if (srv_fake_write)
834
+		return(TRUE);
835
+
836
 	os_n_file_writes++;
837
 
838
 	ut_ad(file);
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
839
@@ -2793,6 +2801,9 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
840
 #else
841
 	ssize_t	ret;
842
 
843
+	if (srv_fake_write)
844
+		return(TRUE);
845
+
846
 	ret = os_file_pwrite(file, buf, n, offset, offset_high);
847
 
848
 	if ((ulint)ret == n) {
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
849
--- a/storage/innobase/os/os0thread.c	2010-12-03 09:58:26.000000000 -0800
850
+++ b/storage/innobase/os/os0thread.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
851
@@ -266,12 +266,17 @@
852
 #ifdef __WIN__
853
 	Sleep((DWORD) tm / 1000);
854
 #else
855
+	/* select() simetimes hang up from xtrabackup */
856
+	/* change to use usleep() for now */
857
+	usleep(tm);
858
+/*
859
 	struct timeval	t;
860
 
861
 	t.tv_sec = tm / 1000000;
862
 	t.tv_usec = tm % 1000000;
863
 
864
 	select(0, NULL, NULL, NULL, &t);
865
+*/
866
 #endif
867
 }
868
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
869
--- a/storage/innobase/row/row0merge.c	2010-12-03 09:58:26.000000000 -0800
870
+++ b/storage/innobase/row/row0merge.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
871
@@ -459,7 +459,9 @@
872
 	rec = rec_convert_dtuple_to_rec(*buf, index, tuple, n_ext);
873
 	offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
874
 
875
-	innobase_rec_to_mysql(dup->table, rec, index, offsets);
876
+	//innobase_rec_to_mysql(dup->table, rec, index, offsets);
877
+	fprintf(stderr, "InnoDB: Error: row_merge_dup_report() is called.\n");
878
+	ut_error;
879
 
880
 	mem_heap_free(heap);
881
 }
882
@@ -1478,8 +1480,10 @@
883
 		case 0:
884
 			if (UNIV_UNLIKELY
885
 			    (dict_index_is_unique(index) && !null_eq)) {
886
-				innobase_rec_to_mysql(table, mrec0,
887
-						      index, offsets0);
888
+				//innobase_rec_to_mysql(table, mrec0,
889
+				//		      index, offsets0);
890
+				fprintf(stderr, "InnoDB: Error: row_merge_blocks() is called.\n");
891
+				ut_error;
892
 				mem_heap_free(heap);
893
 				return(DB_DUPLICATE_KEY);
894
 			}
895
@@ -2604,7 +2608,9 @@
896
 
897
 	/* Reset the MySQL row buffer that is used when reporting
898
 	duplicate keys. */
899
-	innobase_rec_reset(table);
900
+	//innobase_rec_reset(table);
901
+	fprintf(stderr, "InnoDB: Error: row_merge_build_indexes() is called.\n");
902
+	ut_error;
903
 
904
 	/* Read clustered index of the table and create files for
905
 	secondary index entries for merge sort */
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
906
--- a/storage/innobase/srv/srv0srv.c	2010-12-03 09:58:26.000000000 -0800
907
+++ b/storage/innobase/srv/srv0srv.c	2010-12-15 13:29:50.000000000 -0800
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
908
@@ -394,6 +394,9 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
909
 
910
 UNIV_INTERN ulong	srv_replication_delay		= 0;
911
 
912
+UNIV_INTERN ibool	srv_read_only   = FALSE;
913
+UNIV_INTERN ibool	srv_fake_write  = 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.
914
+UNIV_INTERN ibool	srv_apply_log_only = FALSE;
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
915
 /*-------------------------------------------*/
916
 UNIV_INTERN ulong	srv_n_spin_wait_rounds	= 30;
917
 UNIV_INTERN ulong	srv_n_free_tickets_to_enter = 500;
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
918
@@ -1060,7 +1063,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
919
 	}
920
 
921
 	/* Initialize some INFORMATION SCHEMA internal structures */
922
-	trx_i_s_cache_init(trx_i_s_cache);
923
+	//trx_i_s_cache_init(trx_i_s_cache);
924
 }
925
 
926
 /*********************************************************************//**
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
927
@@ -1071,6 +1074,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
928
 /*==========*/
929
 {
930
 	os_fast_mutex_free(&srv_conc_mutex);
931
+#ifdef UNDEFINED
932
 	mem_free(srv_conc_slots);
933
 	srv_conc_slots = NULL;
934
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
935
@@ -1084,6 +1088,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
936
 	srv_mysql_table = NULL;
937
 
938
 	trx_i_s_cache_free(trx_i_s_cache);
939
+#endif
940
 }
941
 
942
 /*********************************************************************//**
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
943
@@ -1679,7 +1684,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
944
 		}
945
 
946
 		/* Record the lock wait time for this thread */
947
-		thd_set_lock_wait_time(trx->mysql_thd, diff_time);
948
+		//thd_set_lock_wait_time(trx->mysql_thd, diff_time);
949
 	}
950
 
951
 	if (trx->was_chosen_as_deadlock_victim) {
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
952
--- a/storage/innobase/srv/srv0start.c	2010-12-03 09:58:26.000000000 -0800
953
+++ b/storage/innobase/srv/srv0start.c	2010-12-15 13:29:50.000000000 -0800
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
954
@@ -94,6 +94,8 @@
955
 /** Log sequence number at shutdown */
956
 UNIV_INTERN ib_uint64_t	srv_shutdown_lsn;
957
 
958
+UNIV_INTERN ib_uint64_t srv_oldest_lsn;
959
+
960
 #ifdef HAVE_DARWIN_THREADS
961
 # include <sys/utsname.h>
962
 /** TRUE if the F_FULLFSYNC option is available */
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
963
@@ -549,7 +551,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
964
 /*********************************************************************//**
965
 Creates or opens the log files and closes them.
966
 @return	DB_SUCCESS or error code */
967
-static
968
+//static
969
 ulint
970
 open_or_create_log_file(
971
 /*====================*/
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
972
@@ -709,7 +711,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
973
 /*********************************************************************//**
974
 Creates or opens database data files and closes them.
975
 @return	DB_SUCCESS or error code */
976
-static
977
+//static
978
 ulint
979
 open_or_create_data_files(
980
 /*======================*/
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
981
@@ -1379,7 +1381,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
982
 	}
983
 #endif /* UNIV_LOG_ARCHIVE */
984
 
985
-	if (srv_n_log_files * srv_log_file_size >= 262144) {
986
+	if (sizeof(ulint) == 4 && srv_n_log_files * srv_log_file_size >= 262144) {
987
 		fprintf(stderr,
988
 			"InnoDB: Error: combined size of log files"
989
 			" must be < 4 GB\n");
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
990
@@ -1630,6 +1632,10 @@
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.
991
 		are initialized in trx_sys_init_at_db_start(). */
992
 
993
 		recv_recovery_from_checkpoint_finish();
994
+
995
+		if (srv_apply_log_only)
996
+			goto skip_processes;
997
+
998
 		if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
999
 			/* The following call is necessary for the insert
1000
 			buffer to work with multiple tablespaces. We must
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1001
@@ -1801,7 +1807,18 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
1002
 
1003
 	if (srv_auto_extend_last_data_file
1004
 	    && sum_of_data_file_sizes < tablespace_size_in_header) {
1005
+		/* extend table space size aligning with header */
1006
+		ulint	actual_size;
1007
+		fil_extend_space_to_desired_size(&actual_size, 0, tablespace_size_in_header);
1008
+		if (actual_size < tablespace_size_in_header) {
1009
+			fprintf(stderr,
1010
+"InnoDB: Warning: To extend tablespace size aligning with header seems to be failed.\n"
1011
+"InnoDB: The acutual size %lu must be larger than %lu.\n",
1012
+				(ulong) actual_size,
1013
+				(ulong) tablespace_size_in_header);
1014
+		}
1015
 
1016
+#ifdef UNDEFINED
1017
 		fprintf(stderr,
1018
 			"InnoDB: Error: tablespace size stored in header"
1019
 			" is %lu pages, but\n"
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1020
@@ -1826,6 +1843,7 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
1021
 
1022
 			return(DB_ERROR);
1023
 		}
1024
+#endif
1025
 	}
1026
 
1027
 	/* Check that os_fast_mutexes work as expected */
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1028
@@ -1921,6 +1939,7 @@
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.
1029
 		ibuf_update_max_tablespace_id();
1030
 	}
1031
 
1032
+skip_processes:
1033
 	srv_file_per_table = srv_file_per_table_original_value;
1034
 
1035
 	srv_was_started = TRUE;
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1036
--- a/storage/innobase/trx/trx0purge.c	2010-12-03 09:58:26.000000000 -0800
1037
+++ b/storage/innobase/trx/trx0purge.c	2010-12-15 13:29:50.000000000 -0800
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
1038
@@ -1100,6 +1100,9 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
1039
 	/*	que_thr_t*	thr2; */
1040
 	ulint		old_pages_handled;
1041
 
1042
+	if (srv_fake_write)
1043
+		return(0);
1044
+
1045
 	mutex_enter(&(purge_sys->mutex));
1046
 
1047
 	if (purge_sys->trx->n_active_thrs > 0) {
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1048
--- a/storage/innobase/trx/trx0rseg.c	2010-12-03 09:58:26.000000000 -0800
1049
+++ b/storage/innobase/trx/trx0rseg.c	2010-12-15 13:29:50.000000000 -0800
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.
1050
@@ -140,9 +140,11 @@
1051
 
1052
 	mutex_free(&rseg->mutex);
1053
 
1054
+	if (!srv_apply_log_only) {
1055
 	/* There can't be any active transactions. */
1056
 	ut_a(UT_LIST_GET_LEN(rseg->update_undo_list) == 0);
1057
 	ut_a(UT_LIST_GET_LEN(rseg->insert_undo_list) == 0);
1058
+	}
1059
 
1060
 	undo = UT_LIST_GET_FIRST(rseg->update_undo_cached);
1061
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1062
--- a/storage/innobase/trx/trx0sys.c	2010-12-03 09:58:26.000000000 -0800
1063
+++ b/storage/innobase/trx/trx0sys.c	2010-12-15 13:29:50.000000000 -0800
199 by Alexey Kopytov
LP bug#683507: xtrabackup should be updated to use the latest 5.1, 5.5
1064
@@ -1641,10 +1641,12 @@
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.
1065
 		UT_LIST_REMOVE(view_list, trx_sys->view_list, prev_view);
1066
 	}
1067
 
1068
+	if (!srv_apply_log_only) {
1069
 	ut_a(UT_LIST_GET_LEN(trx_sys->trx_list) == 0);
1070
 	ut_a(UT_LIST_GET_LEN(trx_sys->rseg_list) == 0);
1071
 	ut_a(UT_LIST_GET_LEN(trx_sys->view_list) == 0);
1072
 	ut_a(UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0);
1073
+	}
1074
 
1075
 	mem_free(trx_sys);
1076
 
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1077
--- a/storage/innobase/trx/trx0trx.c	2010-12-03 09:58:26.000000000 -0800
1078
+++ b/storage/innobase/trx/trx0trx.c	2010-12-15 13:29:50.000000000 -0800
1079
@@ -469,8 +469,8 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
1080
 						(ullint) trx->id);
1081
 
1082
 					if (srv_force_recovery == 0) {
1083
-
1084
-						trx->conc_state = TRX_PREPARED;
1085
+						/* xtrabackup should rollback it */
1086
+						trx->conc_state = TRX_ACTIVE;
1087
 					} else {
1088
 						fprintf(stderr,
1089
 							"InnoDB: Since"
202.3.1 by Alexey Kopytov
Updated XtraBackup patches and the build script to the latest MySQL 5.1, 5.5 and Percona Server releases.
1090
@@ -544,9 +544,9 @@
177 by kinoyasu
alpha implementation for 5.5.6-rc innodb(plugin)
1091
 							(ullint) trx->id);
1092
 
1093
 						if (srv_force_recovery == 0) {
1094
-
1095
+							/* xtrabackup should rollback it */
1096
 							trx->conc_state
1097
-								= TRX_PREPARED;
1098
+								= TRX_ACTIVE;
1099
 						} else {
1100
 							fprintf(stderr,
1101
 								"InnoDB: Since"