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