~vlad-lesin/percona-server/5.5-slow_log_stored_procs

« back to all changes in this revision

Viewing changes to patches/innodb_pass_corrupt_table.patch

  • Committer: Laurynas Biveinis
  • Date: 2012-03-19 11:27:36 UTC
  • mfrom: (222.2.4 staging-5.5)
  • Revision ID: laurynas.biveinis@percona.com-20120319112736-pphh9lnfkc8dbhku
AutomergeĀ lp:~laurynas-biveinis/percona-server/staging-5.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
# should be done or reviewed by the maintainer!
8
8
--- a/storage/innobase/btr/btr0btr.c
9
9
+++ b/storage/innobase/btr/btr0btr.c
10
 
@@ -692,6 +692,12 @@
 
10
@@ -713,6 +713,12 @@
11
11
 
12
12
        block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH,
13
13
                              index, mtr);
17
17
+       }
18
18
+       ut_a(block);
19
19
+
20
 
        ut_a((ibool)!!page_is_comp(buf_block_get_frame(block))
21
 
             == dict_table_is_comp(index->table));
 
20
        btr_assert_not_corrupted(block, index);
22
21
 #ifdef UNIV_BTR_DEBUG
23
 
@@ -978,6 +984,12 @@
 
22
        if (!dict_index_is_ibuf(index)) {
 
23
@@ -998,6 +1004,12 @@
24
24
 
25
25
        root = btr_root_get(index, &mtr);
26
26
 
33
33
        if (flag == BTR_N_LEAF_PAGES) {
34
34
                seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF;
35
35
 
36
 
@@ -1437,6 +1449,13 @@
 
36
@@ -1457,6 +1469,13 @@
37
37
 
38
38
        root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH,
39
39
                            NULL, &mtr);
47
47
 #ifdef UNIV_BTR_DEBUG
48
48
        ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_LEAF
49
49
                                    + root, space));
50
 
@@ -1460,6 +1479,12 @@
 
50
@@ -1480,6 +1499,12 @@
51
51
 
52
52
        root = btr_page_get(space, zip_size, root_page_no, RW_X_LATCH,
53
53
                            NULL, &mtr);
60
60
 #ifdef UNIV_BTR_DEBUG
61
61
        ut_a(btr_root_fseg_validate(FIL_PAGE_DATA + PAGE_BTR_SEG_TOP
62
62
                                    + root, space));
63
 
@@ -1493,6 +1518,11 @@
 
63
@@ -1513,6 +1538,11 @@
64
64
        block = btr_block_get(space, zip_size, root_page_no, RW_X_LATCH,
65
65
                              NULL, mtr);
66
66
 
146
146
 #ifdef UNIV_BTR_DEBUG
147
147
                ut_a(page_is_comp(get_block->frame) == page_is_comp(page));
148
148
 #endif /* UNIV_BTR_DEBUG */
149
 
@@ -590,6 +620,19 @@
 
149
@@ -595,6 +625,19 @@
150
150
                file, line, mtr);
151
151
 
152
152
        if (block == NULL) {
166
166
                /* This must be a search to perform an insert/delete
167
167
                mark/ delete; try using the insert/delete buffer */
168
168
 
169
 
@@ -664,6 +707,16 @@
 
169
@@ -669,6 +712,16 @@
170
170
        block->check_index_page_at_flush = TRUE;
171
171
        page = buf_block_get_frame(block);
172
172
 
183
183
        if (rw_latch != RW_NO_LATCH) {
184
184
 #ifdef UNIV_ZIP_DEBUG
185
185
                const page_zip_des_t*   page_zip
186
 
@@ -857,6 +910,17 @@
 
186
@@ -862,6 +915,17 @@
187
187
                                         RW_NO_LATCH, NULL, BUF_GET,
188
188
                                         file, line, mtr);
189
189
                page = buf_block_get_frame(block);
201
201
                ut_ad(index->id == btr_page_get_index_id(page));
202
202
 
203
203
                block->check_index_page_at_flush = TRUE;
204
 
@@ -977,6 +1041,14 @@
 
204
@@ -982,6 +1046,14 @@
205
205
                                         RW_NO_LATCH, NULL, BUF_GET,
206
206
                                         file, line, mtr);
207
207
                page = buf_block_get_frame(block);
216
216
                ut_ad(index->id == btr_page_get_index_id(page));
217
217
 
218
218
                if (height == ULINT_UNDEFINED) {
219
 
@@ -1190,6 +1262,12 @@
 
219
@@ -1195,6 +1267,12 @@
220
220
        *big_rec = NULL;
221
221
 
222
222
        block = btr_cur_get_block(cursor);
229
229
        page = buf_block_get_frame(block);
230
230
        index = cursor->index;
231
231
        zip_size = buf_block_get_zip_size(block);
232
 
@@ -2922,6 +3000,11 @@
 
232
@@ -2927,6 +3005,11 @@
233
233
 
234
234
        block = btr_cur_get_block(cursor);
235
235
 
241
241
        ut_ad(page_is_leaf(buf_block_get_frame(block)));
242
242
 
243
243
        rec = btr_cur_get_rec(cursor);
244
 
@@ -3630,6 +3713,11 @@
 
244
@@ -3635,6 +3718,11 @@
245
245
 
246
246
                page = btr_cur_get_page(&cursor);
247
247
 
264
264
 /**************************************************************//**
265
265
 Allocates memory for a persistent cursor object and initializes the cursor.
266
266
 @return        own: persistent cursor */
267
 
@@ -102,6 +102,12 @@
 
267
@@ -114,6 +114,12 @@
268
268
        ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
269
269
 
270
270
        block = btr_pcur_get_block(cursor);
277
277
        index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
278
278
 
279
279
        page_cursor = btr_pcur_get_page_cur(cursor);
280
 
@@ -397,6 +403,15 @@
 
280
@@ -409,6 +415,15 @@
281
281
                                   cursor->latch_mode,
282
282
                                   btr_pcur_get_btr_cur(cursor)->index, mtr);
283
283
        next_page = buf_block_get_frame(next_block);
326
326
 
327
327
 /* prototypes for new functions added to ha_innodb.cc */
328
328
 trx_t* innobase_get_trx();
329
 
@@ -1151,6 +1152,11 @@
 
329
@@ -1150,6 +1151,11 @@
330
330
                        ready = buf_flush_ready_for_replace(&block->page);
331
331
                        mutex_exit(&block->mutex);
332
332
 
338
338
                        if (!ready) {
339
339
 
340
340
                                return(block);
341
 
@@ -1947,6 +1953,13 @@
 
341
@@ -1946,6 +1952,13 @@
342
342
                return(NULL);
343
343
        }
344
344
 
352
352
        block_mutex = buf_page_get_mutex_enter(bpage);
353
353
 
354
354
        rw_lock_s_unlock(&buf_pool->page_hash_latch);
355
 
@@ -2526,6 +2539,13 @@
 
355
@@ -2525,6 +2538,13 @@
356
356
                return(NULL);
357
357
        }
358
358
 
366
366
        switch (buf_block_get_state(block)) {
367
367
                buf_page_t*     bpage;
368
368
                ibool           success;
369
 
@@ -3200,6 +3220,7 @@
 
369
@@ -3199,6 +3219,7 @@
370
370
        bpage->newest_modification = 0;
371
371
        bpage->oldest_modification = 0;
372
372
        HASH_INVALIDATE(bpage, hash);
374
374
 #if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG
375
375
        bpage->file_page_was_freed = FALSE;
376
376
 #endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */
377
 
@@ -3838,6 +3859,7 @@
 
377
@@ -3837,6 +3858,7 @@
378
378
                                (ulong) bpage->offset);
379
379
                }
380
380
 
382
382
                /* From version 3.23.38 up we store the page checksum
383
383
                to the 4 first bytes of the page end lsn field */
384
384
 
385
 
@@ -3879,6 +3901,23 @@
 
385
@@ -3878,6 +3900,23 @@
386
386
                              REFMAN "forcing-innodb-recovery.html\n"
387
387
                              "InnoDB: about forcing recovery.\n", stderr);
388
388
 
406
406
                        if (srv_force_recovery < SRV_FORCE_IGNORE_CORRUPT) {
407
407
                                /* If page space id is larger than TRX_SYS_SPACE
408
408
                                (0), we will attempt to mark the corresponding
409
 
@@ -3895,6 +3934,7 @@
 
409
@@ -3894,6 +3933,7 @@
410
410
                                }
411
411
                        }
412
412
                }
414
414
 
415
415
                if (recv_recovery_is_on()) {
416
416
                        /* Pages must be uncompressed for crash recovery. */
417
 
@@ -3904,8 +3944,11 @@
 
417
@@ -3903,8 +3943,11 @@
418
418
 
419
419
                if (uncompressed && !recv_no_ibuf_operations) {
420
420
                        ibuf_merge_or_delete_for_page(
787
787
        if (descr != NULL) {
788
788
--- a/storage/innobase/handler/ha_innodb.cc
789
789
+++ b/storage/innobase/handler/ha_innodb.cc
790
 
@@ -4011,6 +4011,12 @@
 
790
@@ -4024,6 +4024,12 @@
791
791
                DBUG_RETURN(1);
792
792
        }
793
793
 
797
797
+               DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
798
798
+       }
799
799
+
800
 
        /* Create buffers for packing the fields of a record. Why
801
 
        table->reclength did not work here? Obviously, because char
802
 
        fields when packed actually became 1 byte longer, when we also
803
 
@@ -4038,6 +4044,19 @@
 
800
        /* Will be allocated if it is needed in ::update_row() */
 
801
        upd_buf = NULL;
 
802
        upd_buf_size = 0;
 
803
@@ -4043,6 +4049,17 @@
804
804
        /* Get pointer to a table object in InnoDB dictionary cache */
805
805
        ib_table = dict_table_get(norm_name, TRUE);
806
 
        
 
806
 
807
807
+       if (srv_pass_corrupt_table <= 1 && ib_table && ib_table->is_corrupt) {
808
808
+               free_share(share);
809
 
+               my_free(upd_buff);
 
809
+               my_free(upd_buf);
 
810
+               upd_buf = NULL;
 
811
+               upd_buf_size = 0;
810
812
+
811
813
+               DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
812
814
+       }
813
815
+
814
816
+       share->ib_table = ib_table;
815
817
+
816
 
+
817
 
+
818
 
+
819
 
+
820
818
        if (NULL == ib_table) {
821
819
                if (is_part && retries < 10) {
822
 
                        ++retries;
823
 
@@ -5187,6 +5206,10 @@
 
820
                        /* MySQL partition engine hard codes the file name
 
821
@@ -5263,6 +5280,10 @@
824
822
 
825
823
        ha_statistic_increment(&SSV::ha_write_count);
826
824
 
831
829
        if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
832
830
                table->timestamp_field->set_time();
833
831
 
834
 
@@ -5403,6 +5426,10 @@
 
832
@@ -5479,6 +5500,10 @@
835
833
 func_exit:
836
834
        innobase_active_small();
837
835
 
842
840
        DBUG_RETURN(error_result);
843
841
 }
844
842
 
845
 
@@ -5580,6 +5607,10 @@
 
843
@@ -5673,6 +5698,10 @@
846
844
 
847
845
        ha_statistic_increment(&SSV::ha_update_count);
848
846
 
853
851
        if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
854
852
                table->timestamp_field->set_time();
855
853
 
856
 
@@ -5668,6 +5699,10 @@
 
854
@@ -5760,6 +5789,10 @@
857
855
 
858
856
        innobase_active_small();
859
857
 
864
862
        DBUG_RETURN(error);
865
863
 }
866
864
 
867
 
@@ -5689,6 +5724,10 @@
 
865
@@ -5781,6 +5814,10 @@
868
866
 
869
867
        ha_statistic_increment(&SSV::ha_delete_count);
870
868
 
875
873
        if (!prebuilt->upd_node) {
876
874
                row_get_prebuilt_update_vector(prebuilt);
877
875
        }
878
 
@@ -5715,6 +5754,10 @@
 
876
@@ -5807,6 +5844,10 @@
879
877
 
880
878
        innobase_active_small();
881
879
 
886
884
        DBUG_RETURN(error);
887
885
 }
888
886
 
889
 
@@ -5954,6 +5997,10 @@
 
887
@@ -6046,6 +6087,10 @@
890
888
 
891
889
        ha_statistic_increment(&SSV::ha_read_key_count);
892
890
 
897
895
        index = prebuilt->index;
898
896
 
899
897
        if (UNIV_UNLIKELY(index == NULL) || dict_index_is_corrupted(index)) {
900
 
@@ -6022,6 +6069,10 @@
 
898
@@ -6113,6 +6158,10 @@
901
899
                ret = DB_UNSUPPORTED;
902
900
        }
903
901
 
908
906
        switch (ret) {
909
907
        case DB_SUCCESS:
910
908
                error = 0;
911
 
@@ -6136,6 +6187,10 @@
 
909
@@ -6227,6 +6276,10 @@
912
910
 {
913
911
        DBUG_ENTER("change_active_index");
914
912
 
919
917
        ut_ad(user_thd == ha_thd());
920
918
        ut_a(prebuilt->trx == thd_to_trx(user_thd));
921
919
 
922
 
@@ -6249,6 +6304,10 @@
 
920
@@ -6340,6 +6393,10 @@
923
921
 
924
922
        DBUG_ENTER("general_fetch");
925
923
 
930
928
        ut_a(prebuilt->trx == thd_to_trx(user_thd));
931
929
 
932
930
        innodb_srv_conc_enter_innodb(prebuilt->trx);
933
 
@@ -6258,6 +6317,10 @@
 
931
@@ -6349,6 +6406,10 @@
934
932
 
935
933
        innodb_srv_conc_exit_innodb(prebuilt->trx);
936
934
 
941
939
        switch (ret) {
942
940
        case DB_SUCCESS:
943
941
                error = 0;
944
 
@@ -7524,10 +7587,18 @@
 
942
@@ -7615,10 +7676,18 @@
945
943
 
946
944
        update_thd(ha_thd());
947
945
 
960
958
        error = convert_error_code_to_mysql(error, prebuilt->table->flags,
961
959
                                            NULL);
962
960
 
963
 
@@ -8039,6 +8110,16 @@
 
961
@@ -8124,6 +8193,16 @@
964
962
        return(ranges + (double) rows / (double) total_rows * time_for_scan);
965
963
 }
966
964
 
977
975
 /*********************************************************************//**
978
976
 Calculates the key number used inside MySQL for an Innobase index. We will
979
977
 first check the "index translation table" for a match of the index to get
980
 
@@ -8216,7 +8297,7 @@
 
978
@@ -8301,7 +8380,7 @@
981
979
        ib_table = prebuilt->table;
982
980
 
983
981
        if (flag & HA_STATUS_TIME) {
986
984
                        /* In sql_show we call with this flag: update
987
985
                        then statistics so that they are up-to-date */
988
986
 
989
 
@@ -8516,10 +8597,18 @@
 
987
@@ -8601,10 +8680,18 @@
990
988
        THD*            thd,            /*!< in: connection thread handle */
991
989
        HA_CHECK_OPT*   check_opt)      /*!< in: currently ignored */
992
990
 {
1005
1003
        return(0);
1006
1004
 }
1007
1005
 
1008
 
@@ -8755,6 +8844,10 @@
 
1006
@@ -8840,6 +8927,10 @@
1009
1007
                my_error(ER_QUERY_INTERRUPTED, MYF(0));
1010
1008
        }
1011
1009
 
1016
1014
        DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT);
1017
1015
 }
1018
1016
 
1019
 
@@ -9525,6 +9618,10 @@
 
1017
@@ -9610,6 +9701,10 @@
1020
1018
 
1021
1019
        update_thd(thd);
1022
1020
 
1027
1025
        if (prebuilt->table->ibd_file_missing && !thd_tablespace_op(thd)) {
1028
1026
                ut_print_timestamp(stderr);
1029
1027
                fprintf(stderr,
1030
 
@@ -11989,6 +12086,26 @@
 
1028
@@ -12073,6 +12168,26 @@
1031
1029
   "dump file (if present). Disabled by default.",
1032
1030
   NULL, NULL, FALSE);
1033
1031
 
1054
1052
 static struct st_mysql_sys_var* innobase_system_variables[]= {
1055
1053
   MYSQL_SYSVAR(additional_mem_pool_size),
1056
1054
   MYSQL_SYSVAR(autoextend_increment),
1057
 
@@ -12082,6 +12199,7 @@
 
1055
@@ -12166,6 +12281,7 @@
1058
1056
 #ifdef UNIV_DEBUG
1059
 
   MYSQL_SYSVAR(flush_checkpoint_debug),
1060
 
 #endif
 
1057
   MYSQL_SYSVAR(trx_rseg_n_slots_debug),
 
1058
 #endif /* UNIV_DEBUG */
1061
1059
+  MYSQL_SYSVAR(corrupt_table_action),
1062
1060
   NULL
1063
1061
 };
1072
1070
 } INNOBASE_SHARE;
1073
1071
 
1074
1072
 
1075
 
@@ -135,6 +136,7 @@
 
1073
@@ -136,6 +137,7 @@
1076
1074
        int close(void);
1077
1075
        double scan_time();
1078
1076
        double read_time(uint index, uint ranges, ha_rows rows);
1308
1306
 
1309
1307
--- a/storage/innobase/row/row0sel.c
1310
1308
+++ b/storage/innobase/row/row0sel.c
1311
 
@@ -3912,6 +3912,13 @@
 
1309
@@ -3919,6 +3919,13 @@
1312
1310
        /* PHASE 4: Look for matching records in a loop */
1313
1311
 
1314
1312
        rec = btr_pcur_get_rec(pcur);
1322
1320
        ut_ad(!!page_rec_is_comp(rec) == comp);
1323
1321
 #ifdef UNIV_SEARCH_DEBUG
1324
1322
        /*
1325
 
@@ -3989,7 +3996,13 @@
 
1323
@@ -3996,7 +4003,13 @@
1326
1324
        if (UNIV_UNLIKELY(next_offs >= UNIV_PAGE_SIZE - PAGE_DIR)) {
1327
1325
 
1328
1326
 wrong_offs:
1337
1335
                        ut_print_timestamp(stderr);
1338
1336
                        buf_page_print(page_align(rec), 0);
1339
1337
                        fprintf(stderr,
1340
 
@@ -4040,7 +4053,8 @@
 
1338
@@ -4047,7 +4060,8 @@
1341
1339
 
1342
1340
        offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
1343
1341