~drizzle-trunk/drizzle/development

0.1.85 by kinoyasu
new option --stats to gather index stats
1
diff -ru a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c
2
--- a/innobase/btr/btr0btr.c	2008-12-19 02:19:35.000000000 +0900
3
+++ b/innobase/btr/btr0btr.c	2009-08-25 20:58:44.000000000 +0900
4
@@ -518,7 +518,7 @@
5
 
6
 /****************************************************************
7
 Returns the child page of a node pointer and x-latches it. */
8
-static
9
+//static
10
 page_t*
11
 btr_node_ptr_get_child(
12
 /*===================*/
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
13
diff -ru a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
0.1.12 by kinoyasu
suppress some errors at InnoDB
14
--- a/innobase/buf/buf0buf.c	2008-12-19 02:19:35.000000000 +0900
0.1.90 by kinoyasu
suppress ibuf operations for --stats
15
+++ b/innobase/buf/buf0buf.c	2009-09-08 14:21:49.000000000 +0900
0.1.12 by kinoyasu
suppress some errors at InnoDB
16
@@ -314,7 +314,7 @@
17
 		return(TRUE);
18
 	}
19
 
20
-#ifndef UNIV_HOTBACKUP
21
+#ifdef UNDEFINED
22
 	if (recv_lsn_checks_on && log_peek_lsn(&current_lsn)) {
23
 		if (ut_dulint_cmp(current_lsn,
24
 				  mach_read_from_8(read_buf + FIL_PAGE_LSN))
0.1.90 by kinoyasu
suppress ibuf operations for --stats
25
@@ -1969,7 +1969,7 @@
26
 						block->space, block->offset);
27
 		}
28
 
29
-		if (!recv_no_ibuf_operations) {
30
+		if (!recv_no_ibuf_operations && !srv_fake_write) {
31
 			ibuf_merge_or_delete_for_page(block->frame,
32
 					block->space, block->offset, TRUE);
33
 		}
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
34
diff -ru a/innobase/buf/buf0flu.c b/innobase/buf/buf0flu.c
35
--- a/innobase/buf/buf0flu.c	2008-12-19 02:19:35.000000000 +0900
0.13.2 by kinoyasu
variable innodb_fast_recovery is added but default is enabled
36
+++ b/innobase/buf/buf0flu.c	2009-08-04 18:29:14.000000000 +0900
37
@@ -85,6 +85,22 @@
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
38
 	prev_b = NULL;
39
 	b = UT_LIST_GET_FIRST(buf_pool->flush_list);
40
 
0.13.2 by kinoyasu
variable innodb_fast_recovery is added but default is enabled
41
+	if (srv_fast_recovery) {
42
+	/* speed hack */
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
43
+	if (b == NULL || (ut_dulint_cmp(b->oldest_modification,
44
+					block->oldest_modification) < 0)) {
45
+		UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, block);
46
+	} else {
47
+		b = UT_LIST_GET_LAST(buf_pool->flush_list);
48
+		if (ut_dulint_cmp(b->oldest_modification,
49
+					block->oldest_modification) < 0) {
50
+			/* align oldest_modification not to sort */
51
+			block->oldest_modification = b->oldest_modification;
52
+		}
53
+		UT_LIST_ADD_LAST(flush_list, buf_pool->flush_list, block);
54
+	}
0.13.2 by kinoyasu
variable innodb_fast_recovery is added but default is enabled
55
+	} else {
56
+	/* normal */
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
57
 	while (b && (ut_dulint_cmp(b->oldest_modification,
58
 					block->oldest_modification) > 0)) {
59
 		prev_b = b;
0.13.2 by kinoyasu
variable innodb_fast_recovery is added but default is enabled
60
@@ -97,6 +113,7 @@
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
61
 		UT_LIST_INSERT_AFTER(flush_list, buf_pool->flush_list, prev_b,
62
 								block);
63
 	}
0.13.2 by kinoyasu
variable innodb_fast_recovery is added but default is enabled
64
+	}
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
65
 
66
 	ut_ad(buf_flush_validate_low());
67
 }
0.1.30 by kinoyasu
fix bug 342540
68
diff -ru a/innobase/buf/buf0rea.c b/innobase/buf/buf0rea.c
69
--- a/innobase/buf/buf0rea.c	2008-12-19 02:19:35.000000000 +0900
0.1.85 by kinoyasu
new option --stats to gather index stats
70
+++ b/innobase/buf/buf0rea.c	2009-08-24 15:51:17.000000000 +0900
0.1.30 by kinoyasu
fix bug 342540
71
@@ -125,6 +125,45 @@
72
 	block = buf_page_init_for_read(err, mode, space, tablespace_version,
73
 								offset);
74
 	if (block == NULL) {
75
+		if (recv_recovery_is_on() && *err == DB_TABLESPACE_DELETED) {
76
+			/* hashed log recs must be treated here */
77
+			recv_addr_t*    recv_addr;
78
+
79
+			mutex_enter(&(recv_sys->mutex));
80
+
81
+			if (recv_sys->apply_log_recs == FALSE) {
82
+				mutex_exit(&(recv_sys->mutex));
83
+				goto not_to_recover;
84
+			}
85
+
86
+			/* recv_get_fil_addr_struct() */
87
+			recv_addr = HASH_GET_FIRST(recv_sys->addr_hash,
88
+					hash_calc_hash(ut_fold_ulint_pair(space, offset),
89
+						recv_sys->addr_hash));
90
+			while (recv_addr) {
91
+				if ((recv_addr->space == space)
92
+					&& (recv_addr->page_no == offset)) {
93
+					break;
94
+				}
95
+				recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
96
+			}
97
+
98
+			if ((recv_addr == NULL)
99
+			    || (recv_addr->state == RECV_BEING_PROCESSED)
100
+			    || (recv_addr->state == RECV_PROCESSED)) {
101
+				mutex_exit(&(recv_sys->mutex));
102
+				goto not_to_recover;
103
+			}
104
+
105
+			fprintf(stderr, " (space:%lu is deleted)", space);
106
+			recv_addr->state = RECV_PROCESSED;
107
+
108
+			ut_a(recv_sys->n_addrs);
109
+			recv_sys->n_addrs--;
110
+
111
+			mutex_exit(&(recv_sys->mutex));
112
+		}
113
+not_to_recover:
114
 		
115
 		return(0);
116
 	}
0.1.41 by kinoyasu
some performance tuning
117
@@ -684,11 +723,11 @@
118
 		while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) {
119
 
120
 			os_aio_simulated_wake_handler_threads();
121
-			os_thread_sleep(500000);
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
122
+			os_thread_sleep(10000);
0.1.41 by kinoyasu
some performance tuning
123
 
124
 			count++;
125
 
126
-			if (count > 100) {
0.13.1 by kinoyasu
speed hack of buf_flush_insert_sorted_into_flush_list
127
+			if (count > 5000) {
0.1.41 by kinoyasu
some performance tuning
128
 				fprintf(stderr,
129
 "InnoDB: Error: InnoDB has waited for 50 seconds for pending\n"
130
 "InnoDB: reads to the buffer pool to be finished.\n"
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
131
diff -ru a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
132
--- a/innobase/fil/fil0fil.c	2008-12-19 02:19:35.000000000 +0900
0.1.89 by kinoyasu
fix bug 386535, bug 402884, probability to crash --prepare
133
+++ b/innobase/fil/fil0fil.c	2009-09-04 18:00:34.000000000 +0900
134
@@ -1890,10 +1890,10 @@
135
 
136
 			ut_a(space_id != 0);
137
 
138
-			ut_a(DB_SUCCESS == 
139
+
140
 				fil_create_new_single_table_tablespace(
141
 						&space_id, name, FALSE,
142
-						FIL_IBD_FILE_INITIAL_SIZE));
143
+						FIL_IBD_FILE_INITIAL_SIZE);
144
 		}
145
 	}
146
 
0.1.5 by kinoyasu
add innobackup support patch, fix some bugs
147
@@ -2027,7 +2027,7 @@
148
 	}
149
 
150
 	if (success) {
151
-#ifndef UNIV_HOTBACKUP
152
+#ifdef UNDEFINED
153
 		/* Write a log record about the deletion of the .ibd
154
 		file, so that ibbackup can replay it in the
155
 		--apply-log phase. We use a dummy mtr and the familiar
156
@@ -2300,7 +2300,7 @@
157
 
158
 	mutex_exit(&(system->mutex));
159
 
160
-#ifndef UNIV_HOTBACKUP	
161
+#ifdef UNDEFINED	
162
 	if (success) {
163
 		mtr_t		mtr;
164
 
165
@@ -2471,7 +2471,7 @@
166
 
167
 	fil_node_create(path, size, *space_id, FALSE);
168
 
169
-#ifndef UNIV_HOTBACKUP	
170
+#ifdef UNDEFINED	
171
 	{
172
 	mtr_t		mtr;
173
 
0.1.12 by kinoyasu
suppress some errors at InnoDB
174
@@ -2890,7 +2890,7 @@
175
 	cannot be ok. */
176
 
177
 	size = (((ib_longlong)size_high) << 32) + (ib_longlong)size_low;
178
-#ifndef UNIV_HOTBACKUP
179
+#ifdef UNDEFINED
180
 	if (size < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
181
 	        fprintf(stderr,
182
 "InnoDB: Error: the size of single-table tablespace file %s\n"
0.1.34 by kinoyasu
more user-friendly incremental backup
183
@@ -3009,7 +3009,7 @@
184
 A fault-tolerant function that tries to read the next file name in the
185
 directory. We retry 100 times if os_file_readdir_next_file() returns -1. The
186
 idea is to read as much good data as we can and jump over bad data. */
187
-static
188
+//static
189
 int
190
 fil_file_readdir_next_file(
191
 /*=======================*/
0.1.35 by kinoyasu
fix somebugs: bug 339013, bug 352742
192
@@ -3949,6 +3949,16 @@
0.1.27 by kinoyasu
fix bug 347856: fix patches for InnoDB
193
 
194
 	ut_ad((mode != OS_AIO_IBUF) || (space->purpose == FIL_TABLESPACE));
195
 
0.1.35 by kinoyasu
fix somebugs: bug 339013, bug 352742
196
+	if (space->size <= block_offset) {
0.1.27 by kinoyasu
fix bug 347856: fix patches for InnoDB
197
+		ulint	actual_size;
198
+
199
+		mutex_exit(&(system->mutex));
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
200
+		fil_extend_space_to_desired_size(&actual_size, space->id,
201
+						 ((block_offset + 1) / 64 + 1) * 64);
0.1.27 by kinoyasu
fix bug 347856: fix patches for InnoDB
202
+		mutex_enter(&(system->mutex));
203
+		/* should retry? but it may safe for xtrabackup for now. */
204
+	}
205
+
206
 	node = UT_LIST_GET_FIRST(space->chain);
207
 
208
 	for (;;) {
0.1.90 by kinoyasu
suppress ibuf operations for --stats
209
diff -ru a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c
210
--- a/innobase/ibuf/ibuf0ibuf.c	2008-12-19 02:19:35.000000000 +0900
0.1.91 by kinoyasu
suppress master_thread ibuf operations for --stats
211
+++ b/innobase/ibuf/ibuf0ibuf.c	2009-09-08 15:29:50.000000000 +0900
0.1.90 by kinoyasu
suppress ibuf operations for --stats
212
@@ -971,7 +971,7 @@
213
 	mtr_t	mtr;
214
 	ibool	ret;
215
 
216
-	if (recv_no_ibuf_operations) {
217
+	if (recv_no_ibuf_operations || srv_fake_write) {
218
 		/* Recovery is running: no ibuf operations should be
219
 		performed */
220
 
0.1.91 by kinoyasu
suppress master_thread ibuf operations for --stats
221
@@ -2229,6 +2229,9 @@
222
 	ulint	n_bytes;
223
 	ulint	n_pag2;
224
 	
225
+	if (srv_fake_write)
226
+		return(0);
227
+
228
 	while (sum_pages < n_pages) {
229
 		n_bytes = ibuf_contract_ext(&n_pag2, sync);
230
 		
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
231
diff -ru a/innobase/include/mem0mem.h b/innobase/include/mem0mem.h
232
--- a/innobase/include/mem0mem.h	2008-12-19 02:19:36.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
233
+++ b/innobase/include/mem0mem.h	2009-07-03 13:25:13.000000000 +0900
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
234
@@ -352,6 +352,7 @@
235
 			allocated buffer frame, which can be appended as a
236
 			free block to the heap, if we need more space;
237
 			otherwise, this is NULL */
238
+	ulint	sum_len;	/* sum of all blocks' len belong to the base node */
239
 #ifdef MEM_PERIODIC_CHECK	
240
 	UT_LIST_NODE_T(mem_block_t) mem_block_list;
241
 			/* List of all mem blocks allocated; protected
242
diff -ru a/innobase/include/mem0mem.ic b/innobase/include/mem0mem.ic
243
--- a/innobase/include/mem0mem.ic	2008-12-19 02:19:36.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
244
+++ b/innobase/include/mem0mem.ic	2009-07-03 13:25:13.000000000 +0900
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
245
@@ -415,6 +415,7 @@
246
 
247
 	/* Add the created block itself as the first block in the list */
248
 	UT_LIST_ADD_FIRST(list, block->base, block);
249
+	block->sum_len = block->len;
250
 
251
 #ifdef UNIV_MEM_DEBUG
252
 
253
@@ -546,6 +547,7 @@
254
 
255
 	ut_ad(mem_heap_check(heap));
256
 	
257
+/*
258
 	block = heap;
259
 
260
 	while (block != NULL) { 
261
@@ -553,6 +555,8 @@
262
 		size += mem_block_get_len(block);
263
 		block = UT_LIST_GET_NEXT(list, block);
264
 	}
265
+*/
266
+	size = heap->sum_len;
267
 
268
 	if (heap->free_block) {
269
 		size += UNIV_PAGE_SIZE;
0.1.73 by kinoyasu
fix bug 394781, bug 394374
270
diff -ru a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h
271
--- a/innobase/include/srv0srv.h	2008-12-19 02:19:36.000000000 +0900
0.1.88 by kinoyasu
fix fatal bug at --backup when added --stats
272
+++ b/innobase/include/srv0srv.h	2009-09-03 15:08:25.000000000 +0900
0.13.2 by kinoyasu
variable innodb_fast_recovery is added but default is enabled
273
@@ -57,6 +57,8 @@
274
 extern ibool	srv_file_per_table;
275
 extern ibool    srv_locks_unsafe_for_binlog;
276
 
277
+extern ibool	srv_fast_recovery;
278
+
279
 extern ulint	srv_n_data_files;
280
 extern char**	srv_data_file_names;
281
 extern ulint*	srv_data_file_sizes;
0.1.88 by kinoyasu
fix fatal bug at --backup when added --stats
282
@@ -131,6 +133,9 @@
0.1.73 by kinoyasu
fix bug 394781, bug 394374
283
 extern ulong	srv_max_purge_lag;
284
 extern ibool	srv_use_awe;
285
 extern ibool	srv_use_adaptive_hash_indexes;
286
+
287
+extern ibool	srv_read_only;
0.1.88 by kinoyasu
fix fatal bug at --backup when added --stats
288
+extern ibool	srv_fake_write;
0.1.73 by kinoyasu
fix bug 394781, bug 394374
289
 /*-------------------------------------------*/
290
 
291
 extern ulint	srv_n_rows_inserted;
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
292
diff -ru a/innobase/include/srv0start.h b/innobase/include/srv0start.h
293
--- a/innobase/include/srv0start.h	2008-12-19 02:19:36.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
294
+++ b/innobase/include/srv0start.h	2009-07-03 13:25:13.000000000 +0900
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
295
@@ -80,6 +80,7 @@
296
 				/* out: DB_SUCCESS or error code */
297
 extern	dulint	srv_shutdown_lsn;
298
 extern	dulint	srv_start_lsn;
299
+extern	dulint	srv_oldest_lsn;
300
 
301
 #ifdef __NETWARE__
302
 void set_panic_flag_for_netware(void);
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
303
diff -ru a/innobase/include/ut0byte.ic b/innobase/include/ut0byte.ic
304
--- a/innobase/include/ut0byte.ic	2008-12-19 02:19:36.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
305
+++ b/innobase/include/ut0byte.ic	2009-07-03 13:25:13.000000000 +0900
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
306
@@ -152,6 +152,14 @@
307
 	dulint	a,	/* in: dulint */
308
 	ulint	b)	/* in: ulint */
309
 {
310
+	if (sizeof(ulint) != 4) {
311
+		ulint	b_h;
312
+
313
+		b_h = b >> 32;
314
+		b &= 0xFFFFFFFFUL;
315
+		a.high += b_h;
316
+	}
317
+
318
 	if (0xFFFFFFFFUL - b >= a.low) {
319
 		a.low += b;
320
 
321
@@ -175,6 +183,14 @@
322
 	dulint	a,	/* in: dulint */
323
 	ulint	b)	/* in: ulint, b <= a */
324
 {
325
+	if (sizeof(ulint) != 4) {
326
+		ulint	b_h;
327
+
328
+		b_h = b >> 32;
329
+		b &= 0xFFFFFFFFUL;
330
+		a.high -= b_h;
331
+	}
332
+
333
 	if (a.low >= b) {
334
 		a.low -= b;
335
 
336
@@ -218,6 +234,10 @@
337
 	diff += 1 + a.low;
338
 
339
 	ut_ad(diff > a.low);
340
+
341
+	if (sizeof(ulint) != 4) {
342
+		diff += (a.high - b.high - 1) << 32;
343
+	}
344
 	
345
 	return(diff);
346
 } 
347
diff -ru a/innobase/log/log0log.c b/innobase/log/log0log.c
348
--- a/innobase/log/log0log.c	2008-12-19 02:19:36.000000000 +0900
0.1.90 by kinoyasu
suppress ibuf operations for --stats
349
+++ b/innobase/log/log0log.c	2009-09-08 14:22:59.000000000 +0900
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
350
@@ -548,7 +548,9 @@
351
 
352
 	offset = (gr_lsn_size_offset + difference) % group_size;
353
 
354
+	if (sizeof(ulint) == 4) {
355
 	ut_a(offset < (((ib_longlong) 1) << 32)); /* offset must be < 4 GB */
356
+	}
357
 
358
 	/* fprintf(stderr,
359
 		"Offset is %lu gr_lsn_offset is %lu difference is %lu\n",
0.1.90 by kinoyasu
suppress ibuf operations for --stats
360
@@ -1315,7 +1317,7 @@
361
 	ulint		loop_count;
362
 	ulint		unlock;
363
 
364
-	if (recv_no_ibuf_operations) {
365
+	if (recv_no_ibuf_operations || srv_fake_write) {
366
 		/* Recovery is running and no operations on the log files are
367
 		allowed yet (the variable name .._no_ibuf_.. is misleading) */
368
 
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
369
diff -ru a/innobase/log/log0recv.c b/innobase/log/log0recv.c
370
--- a/innobase/log/log0recv.c	2008-12-19 02:19:36.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
371
+++ b/innobase/log/log0recv.c	2009-07-03 13:25:13.000000000 +0900
0.1.41 by kinoyasu
some performance tuning
372
@@ -35,19 +35,19 @@
0.1.5 by kinoyasu
add innobackup support patch, fix some bugs
373
 #include "fil0fil.h"
374
 #include "sync0sync.h"
375
 
376
-#ifdef UNIV_HOTBACKUP
377
+//#ifdef UNIV_HOTBACKUP
378
 /* This is set to FALSE if the backup was originally taken with the
379
 ibbackup --include regexp option: then we do not want to create tables in
380
 directories which were not included */
381
 ibool	recv_replay_file_ops	= TRUE;
382
-#endif /* UNIV_HOTBACKUP */
383
+//#endif /* UNIV_HOTBACKUP */
384
 
385
 /* Log records are stored in the hash table in chunks at most of this size;
386
 this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
0.1.41 by kinoyasu
some performance tuning
387
 #define RECV_DATA_BLOCK_SIZE	(MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
388
 
389
 /* Read-ahead area in applying log records to file pages */
390
-#define RECV_READ_AHEAD_AREA	32
391
+#define RECV_READ_AHEAD_AREA	128
392
 
393
 recv_sys_t*	recv_sys = NULL;
394
 ibool		recv_recovery_on = FALSE;
395
@@ -101,7 +101,7 @@
396
 use these free frames to read in pages when we start applying the
397
 log records to the database. */
398
 
399
-ulint  recv_n_pool_free_frames         = 256;
400
+ulint  recv_n_pool_free_frames         = 1024;
401
 
402
 /* The maximum lsn we see for a page during the recovery process. If this
403
 is bigger than the lsn we are able to scan up to, that is an indication that
0.2.1 by Vadim Tkachenko
add patch to fix MySQL source code
404
@@ -450,7 +450,7 @@
405
 
406
 /***************************************************************************
407
 Checks the consistency of the checkpoint info */
408
-static
409
+//static
410
 ibool
411
 recv_check_cp_is_consistent(
412
 /*========================*/
413
@@ -479,7 +479,7 @@
414
 
415
 /************************************************************
416
 Looks for the maximum consistent checkpoint from the log groups. */
417
-static
418
+//static
419
 ulint
420
 recv_find_max_checkpoint(
421
 /*=====================*/
422
@@ -644,7 +644,7 @@
423
 Checks the 4-byte checksum to the trailer checksum field of a log block.
424
 We also accept a log block in the old format < InnoDB-3.23.52 where the
425
 checksum field contains the log block number. */
426
-static
427
+//static
428
 ibool
429
 log_block_checksum_is_ok_or_old_format(
430
 /*===================================*/
0.1.39 by kinoyasu
maybe last fix bug 352742
431
@@ -1135,6 +1135,7 @@
432
 	recv_addr = recv_get_fil_addr_struct(space, page_no);
433
 
434
 	if ((recv_addr == NULL)
435
+	    || (recv_addr->state == RECV_BEING_READ && !just_read_in)
436
 	    || (recv_addr->state == RECV_BEING_PROCESSED)
437
 	    || (recv_addr->state == RECV_PROCESSED)) {
438
 
439
@@ -2076,7 +2077,7 @@
0.1.5 by kinoyasu
add innobackup support patch, fix some bugs
440
 		} else if (store_to_hash && (type == MLOG_FILE_CREATE
441
 					     || type == MLOG_FILE_RENAME
442
 					     || type == MLOG_FILE_DELETE)) {
443
-#ifdef UNIV_HOTBACKUP
444
+//#ifdef UNIV_HOTBACKUP
445
 			if (recv_replay_file_ops) {
446
 
447
 				/* In ibbackup --apply-log, replay an .ibd file
0.1.39 by kinoyasu
maybe last fix bug 352742
448
@@ -2093,7 +2094,7 @@
0.1.5 by kinoyasu
add innobackup support patch, fix some bugs
449
 					ut_a(0);
450
 				}
451
 			}
452
-#endif
453
+//#endif
454
 			/* In normal mysqld crash recovery we do not try to
455
 			replay file operations */
456
 		} else if (store_to_hash) {
0.1.39 by kinoyasu
maybe last fix bug 352742
457
@@ -2514,9 +2515,12 @@
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
458
 		if (finished || (recv_scan_print_counter % 80 == 0)) {
459
 
460
 			fprintf(stderr, 
461
-"InnoDB: Doing recovery: scanned up to log sequence number %lu %lu\n",
462
+"InnoDB: Doing recovery: scanned up to log sequence number %lu %lu (%lu %)\n",
463
 				(ulong) ut_dulint_get_high(*group_scanned_lsn),
464
-				(ulong) ut_dulint_get_low(*group_scanned_lsn));
465
+				(ulong) ut_dulint_get_low(*group_scanned_lsn),
466
+				(ulong) ut_dulint_minus(*group_scanned_lsn, srv_oldest_lsn)
0.1.40 by kinoyasu
align progress % of log apply; fix version
467
+				/ (8 * log_group_get_capacity(UT_LIST_GET_FIRST(log_sys->log_groups))/900)
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
468
+			);
469
 		}
470
 	}
471
 
0.1.54 by kinoyasu
disable applying doublewrite buffer. because it may be older than the original pages
472
@@ -2626,12 +2630,14 @@
473
 
474
 	if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
475
 
476
+#ifdef UNDEFINED
477
 		fprintf(stderr,
478
 			"InnoDB: Restoring possible"
479
 			" half-written data pages from"
480
 			" the doublewrite\n"
481
 			"InnoDB: buffer...\n");
482
-		trx_sys_doublewrite_init_or_restore_pages(TRUE);
483
+#endif
484
+		trx_sys_doublewrite_init_or_restore_pages(FALSE);
485
 	}
486
 	
487
 }
0.1.73 by kinoyasu
fix bug 394781, bug 394374
488
@@ -2760,6 +2766,7 @@
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
489
 		recv_sys->recovered_lsn = checkpoint_lsn;
490
 
491
 		srv_start_lsn = checkpoint_lsn;
492
+		srv_oldest_lsn = checkpoint_lsn;
493
 	}
494
 
495
 	contiguous_lsn = ut_dulint_align_down(recv_sys->scanned_lsn,
496
diff -ru a/innobase/mem/mem0mem.c b/innobase/mem/mem0mem.c
497
--- a/innobase/mem/mem0mem.c	2008-12-19 02:19:36.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
498
+++ b/innobase/mem/mem0mem.c	2009-07-03 13:25:13.000000000 +0900
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
499
@@ -266,6 +266,7 @@
500
 	/* Add the new block as the last block */
501
 
502
 	UT_LIST_INSERT_AFTER(list, heap->base, block, new_block);
503
+	heap->sum_len += new_block->len;
504
 
505
 	return(new_block);
506
 }
507
@@ -288,6 +289,7 @@
508
 	}
509
 
510
 	UT_LIST_REMOVE(list, heap->base, block);
511
+	heap->sum_len -= block->len;
512
 		
513
 #ifdef MEM_PERIODIC_CHECK	
514
 	mem_pool_mutex_enter();
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
515
diff -ru a/innobase/os/os0file.c b/innobase/os/os0file.c
516
--- a/innobase/os/os0file.c	2008-12-19 02:19:36.000000000 +0900
0.1.96 by kinoyasu
Windows conscious change more
517
+++ b/innobase/os/os0file.c	2009-09-18 17:29:36.000000000 +0900
0.2.1 by Vadim Tkachenko
add patch to fix MySQL source code
518
@@ -435,7 +435,7 @@
519
 }
520
 
521
 #undef USE_FILE_LOCK
522
-#define USE_FILE_LOCK
523
+//#define USE_FILE_LOCK
524
 #if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__NETWARE__)
525
 /* InnoDB Hot Backup does not lock the data files.
526
  * On Windows, mandatory locking is used.
0.1.96 by kinoyasu
Windows conscious change more
527
@@ -1239,8 +1239,9 @@
528
 		attributes = 0;
529
 		ut_error;
0.1.94 by kinoyasu
Windows conscious experimental change
530
 	}
0.1.96 by kinoyasu
Windows conscious change more
531
-
532
+	share_mode |= FILE_SHARE_WRITE; /* Why? */
0.1.94 by kinoyasu
Windows conscious experimental change
533
 	file = CreateFile((LPCTSTR) name,
534
+			srv_read_only ? GENERIC_READ :
535
 			GENERIC_READ | GENERIC_WRITE, /* read and write
536
 							access */
537
 			share_mode,     /* File can be read also by other
538
@@ -1262,7 +1263,7 @@
539
 	if (file == INVALID_HANDLE_VALUE) {
540
 		*success = FALSE;
541
 
542
-		retry = os_file_handle_error(name,
543
+		retry = os_file_handle_error_no_exit(name,
544
 				create_mode == OS_FILE_CREATE ?
545
 				"create" : "open");
546
 		if (retry) {
547
@@ -1287,7 +1288,11 @@
0.1.73 by kinoyasu
fix bug 394781, bug 394374
548
 	if (create_mode == OS_FILE_OPEN || create_mode == OS_FILE_OPEN_RAW
549
 			|| create_mode == OS_FILE_OPEN_RETRY) {
550
 		mode_str = "OPEN";
551
-		create_flag = O_RDWR;
552
+		if (srv_read_only) {
553
+			create_flag = O_RDONLY;
554
+		} else {
555
+			create_flag = O_RDWR;
556
+		}
557
 	} else if (create_mode == OS_FILE_CREATE) {
558
 		mode_str = "CREATE";
559
 		create_flag = O_RDWR | O_CREAT | O_EXCL;
0.1.94 by kinoyasu
Windows conscious experimental change
560
@@ -1335,7 +1340,7 @@
0.1.89 by kinoyasu
fix bug 386535, bug 402884, probability to crash --prepare
561
 	if (file == -1) {
562
 		*success = FALSE;
563
 
564
-		retry = os_file_handle_error(name,
565
+		retry = os_file_handle_error_no_exit(name,
566
 				create_mode == OS_FILE_CREATE ?
567
 				"create" : "open");
568
 		if (retry) {
0.1.94 by kinoyasu
Windows conscious experimental change
569
@@ -2364,6 +2369,9 @@
570
 
571
 	ut_a((offset & 0xFFFFFFFF) == offset);
572
 
573
+	if (srv_fake_write)
574
+		return(TRUE);
575
+
576
 	os_n_file_writes++;
577
 
578
 	ut_ad(file);
579
@@ -2472,6 +2480,9 @@
0.1.85 by kinoyasu
new option --stats to gather index stats
580
 	return(FALSE);
581
 #else
582
 	ssize_t	ret;
583
+
0.1.88 by kinoyasu
fix fatal bug at --backup when added --stats
584
+	if (srv_fake_write)
0.1.85 by kinoyasu
new option --stats to gather index stats
585
+		return(TRUE);
586
 	
587
 	ret = os_file_pwrite(file, buf, n, offset, offset_high);
588
         
0.1.94 by kinoyasu
Windows conscious experimental change
589
@@ -3148,6 +3159,13 @@
0.1.41 by kinoyasu
some performance tuning
590
 	struct aiocb*	control;
591
 #endif
592
 	ulint		i;
593
+	ulint		prim_segment;
594
+	ulint		n;
595
+
596
+	n = array->n_slots / array->n_segments;
597
+	/* 64 blocks' striping ( aligning max(BUF_READ_AHEAD_AREA) ) */
598
+	prim_segment = ( offset >> (UNIV_PAGE_SIZE_SHIFT + 6) ) % (array->n_segments);
599
+
600
 loop:
601
 	os_mutex_enter(array->mutex);
602
 
0.1.94 by kinoyasu
Windows conscious experimental change
603
@@ -3166,6 +3184,16 @@
0.1.41 by kinoyasu
some performance tuning
604
 		goto loop;
605
 	}
606
 
607
+	for (i = prim_segment * n; i < array->n_slots; i++) {
608
+		slot = os_aio_array_get_nth_slot(array, i);
609
+
610
+		if (slot->reserved == FALSE) {
611
+			break;
612
+		}
613
+	}
614
+
615
+	if (slot->reserved == TRUE){
616
+		/* Not found after the intended segment. So we should search before. */
617
 	for (i = 0;; i++) {
618
 		slot = os_aio_array_get_nth_slot(array, i);
619
 
0.1.94 by kinoyasu
Windows conscious experimental change
620
@@ -3173,6 +3201,7 @@
0.1.41 by kinoyasu
some performance tuning
621
 			break;
622
 		}
623
 	}
624
+	}
625
 
626
 	array->n_reserved++;
627
 
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
628
diff -ru a/innobase/os/os0thread.c b/innobase/os/os0thread.c
0.1.24 by kinoyasu
Add patch to use usleep() (bug 342540)
629
--- a/innobase/os/os0thread.c	2008-12-19 02:19:36.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
630
+++ b/innobase/os/os0thread.c	2009-07-03 13:25:13.000000000 +0900
0.1.24 by kinoyasu
Add patch to use usleep() (bug 342540)
631
@@ -266,12 +266,17 @@
632
 #elif defined(__NETWARE__)
633
 	delay(tm / 1000);
634
 #else
635
+	/* select() simetimes hang up from xtrabackup */
636
+	/* change to use usleep() for now */
637
+	usleep(tm);
638
+/*
639
 	struct timeval	t;
640
 
641
 	t.tv_sec = tm / 1000000;
642
 	t.tv_usec = tm % 1000000;
643
 	
644
 	select(0, NULL, NULL, NULL, &t);
645
+*/
646
 #endif
647
 }
648
 
0.1.73 by kinoyasu
fix bug 394781, bug 394374
649
diff -ru a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c
650
--- a/innobase/srv/srv0srv.c	2008-12-19 02:19:37.000000000 +0900
0.1.88 by kinoyasu
fix fatal bug at --backup when added --stats
651
+++ b/innobase/srv/srv0srv.c	2009-09-03 15:09:01.000000000 +0900
0.13.2 by kinoyasu
variable innodb_fast_recovery is added but default is enabled
652
@@ -86,6 +86,8 @@
653
                                                 i.e. do not use next-key locking
654
                                                 except on duplicate key checking and
655
                                                 foreign key checking */
656
+ibool	srv_fast_recovery = TRUE;
657
+
658
 ulint	srv_n_data_files = 0;
659
 char**	srv_data_file_names = NULL;
660
 ulint*	srv_data_file_sizes = NULL;	/* size in database pages */ 
0.1.88 by kinoyasu
fix fatal bug at --backup when added --stats
661
@@ -322,6 +324,8 @@
0.1.73 by kinoyasu
fix bug 394781, bug 394374
662
 ibool	srv_use_awe			= FALSE;
663
 ibool	srv_use_adaptive_hash_indexes 	= TRUE;
664
 
665
+ibool	srv_read_only	= FALSE;
0.1.88 by kinoyasu
fix fatal bug at --backup when added --stats
666
+ibool	srv_fake_write	= FALSE;
0.1.73 by kinoyasu
fix bug 394781, bug 394374
667
 /*-------------------------------------------*/
668
 ulong	srv_n_spin_wait_rounds	= 20;
669
 ulong	srv_n_free_tickets_to_enter = 500;
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
670
diff -ru a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c
671
--- a/innobase/srv/srv0start.c	2008-12-19 02:19:37.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
672
+++ b/innobase/srv/srv0start.c	2009-07-03 13:25:13.000000000 +0900
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
673
@@ -61,6 +61,8 @@
674
 /* Log sequence number at shutdown */
675
 dulint		srv_shutdown_lsn;
676
 
677
+dulint		srv_oldest_lsn;
678
+
679
 #ifdef HAVE_DARWIN_THREADS
680
 # include <sys/utsname.h>
681
 ibool		srv_have_fullfsync = FALSE;
682
@@ -547,7 +549,7 @@
0.2.1 by Vadim Tkachenko
add patch to fix MySQL source code
683
 #ifndef UNIV_HOTBACKUP
684
 /*************************************************************************
685
 Creates or opens the log files and closes them. */
686
-static
687
+//static
688
 ulint
689
 open_or_create_log_file(
690
 /*====================*/
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
691
@@ -693,7 +695,7 @@
0.2.1 by Vadim Tkachenko
add patch to fix MySQL source code
692
 
693
 /*************************************************************************
694
 Creates or opens database data files and closes them. */
695
-static
696
+//static
697
 ulint
698
 open_or_create_data_files(
699
 /*======================*/
0.1.41 by kinoyasu
some performance tuning
700
@@ -1213,12 +1215,12 @@
701
 
702
 	if (!os_aio_use_native_aio) {
703
  		/* In simulated aio we currently have use only for 4 threads */
704
-		srv_n_file_io_threads = 4;
705
+		/*srv_n_file_io_threads = 4;*/
706
 
707
 		os_aio_init(8 * SRV_N_PENDING_IOS_PER_THREAD
708
 						* srv_n_file_io_threads,
709
 					srv_n_file_io_threads,
710
-					SRV_MAX_N_PENDING_SYNC_IOS);
711
+					SRV_MAX_N_PENDING_SYNC_IOS * 8);
712
 	} else {
713
 		os_aio_init(SRV_N_PENDING_IOS_PER_THREAD
714
 						* srv_n_file_io_threads,
0.1.29 by kinoyasu
add progress % of log applying, fix file extension, mem_heap_get_size
715
@@ -1275,7 +1277,7 @@
0.1.28 by kinoyasu
allow over 4GB xtrabackup_logfile at 64-bit architecture
716
 	}
717
 #endif /* UNIV_LOG_ARCHIVE */
718
 
719
-	if (srv_n_log_files * srv_log_file_size >= 262144) {
720
+	if (sizeof(ulint) == 4 && srv_n_log_files * srv_log_file_size >= 262144) {
721
 		fprintf(stderr,
722
 		"InnoDB: Error: combined size of log files must be < 4 GB\n");
723
 
0.1.64 by kinoyasu
to extend tablespace size, if needed after --prepare
724
@@ -1609,7 +1611,18 @@
0.1.50 by kinoyasu
remove unnecessary error check for data file size
725
 
726
 	if (srv_auto_extend_last_data_file
727
 		&& sum_of_data_file_sizes < tablespace_size_in_header) {
0.1.64 by kinoyasu
to extend tablespace size, if needed after --prepare
728
+		/* extend table space size aligning with header */
729
+		ulint	actual_size;
730
+		fil_extend_space_to_desired_size(&actual_size, 0, tablespace_size_in_header);
731
+		if (actual_size < tablespace_size_in_header) {
732
+			fprintf(stderr,
733
+"InnoDB: Warning: To extend tablespace size aligning with header seems to be failed.\n"
734
+"InnoDB: The acutual size %lu must be larger than %lu.\n",
735
+				(ulong) actual_size,
736
+				(ulong) tablespace_size_in_header);
737
+		}
738
 
739
+#ifdef UNDEFINED
740
 		fprintf(stderr,
741
 "InnoDB: Error: tablespace size stored in header is %lu pages, but\n"
742
 "InnoDB: the sum of data file sizes is only %lu pages\n",
743
@@ -1627,6 +1640,7 @@
744
 
0.1.50 by kinoyasu
remove unnecessary error check for data file size
745
 			return(DB_ERROR);
746
 		}
0.1.64 by kinoyasu
to extend tablespace size, if needed after --prepare
747
+#endif
0.1.50 by kinoyasu
remove unnecessary error check for data file size
748
 	}
749
 
750
 	/* Check that os_fast_mutexes work as expected */
0.1.93 by kinoyasu
suppress purge when --stats
751
diff -ru a/innobase/trx/trx0purge.c b/innobase/trx/trx0purge.c
752
--- a/innobase/trx/trx0purge.c	2008-12-19 02:19:37.000000000 +0900
753
+++ b/innobase/trx/trx0purge.c	2009-09-10 15:34:51.000000000 +0900
754
@@ -1043,6 +1043,9 @@
755
 /*	que_thr_t*	thr2; */
756
 	ulint		old_pages_handled;
757
 
758
+	if (srv_fake_write)
759
+		return(0);
760
+
761
 	mutex_enter(&(purge_sys->mutex));
762
 
763
 	if (purge_sys->trx->n_active_thrs > 0) {
0.1.65 by kinoyasu
rollback XA PREPAREd transaction automatically at --prepare
764
diff -ru a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c
765
--- a/innobase/trx/trx0trx.c	2008-12-19 02:19:37.000000000 +0900
0.1.73 by kinoyasu
fix bug 394781, bug 394374
766
+++ b/innobase/trx/trx0trx.c	2009-07-03 13:25:13.000000000 +0900
0.1.65 by kinoyasu
rollback XA PREPAREd transaction automatically at --prepare
767
@@ -486,8 +486,8 @@
768
 					ut_dulint_get_low(trx->id));
769
 
770
 					if (srv_force_recovery == 0) {
771
-
772
-						trx->conc_state = TRX_PREPARED;
773
+						/* xtrabackup should rollback it */
774
+						trx->conc_state = TRX_ACTIVE;
775
 					} else {
776
  						fprintf(stderr,
777
 "InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n");
778
@@ -555,8 +555,8 @@
779
 					    ut_dulint_get_low(trx->id));
780
 
781
 					    if (srv_force_recovery == 0) {
782
-
783
-						trx->conc_state = TRX_PREPARED;
784
+						/* xtrabackup should rollback it */
785
+						trx->conc_state = TRX_ACTIVE;
786
 					    } else {
787
  						fprintf(stderr,
788
 "InnoDB: Since innodb_force_recovery > 0, we will rollback it anyway.\n");