diff options
author | Marko Mäkelä <marko.makela@oracle.com> | 2012-02-02 12:31:57 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@oracle.com> | 2012-02-02 12:31:57 +0200 |
commit | 39100cd98440e3060e2ba2b6ec21b171728bd0eb (patch) | |
tree | e70e0ca4f683e74f2e0fa4c72e35c8d785465717 | |
parent | 99ce9430141f7c834840234935e4557d9311eef4 (diff) | |
download | mariadb-git-39100cd98440e3060e2ba2b6ec21b171728bd0eb.tar.gz |
Bug #13651627 Move ut_ad(0) from the beginning to the end of buf_page_print(),
print page dump
buf_page_print(): Remove the ut_ad(0) from the beginning. Add two flags
(enum buf_page_print_flags) that can be bitwise-ORed together:
BUF_PAGE_PRINT_NO_CRASH:
Do not crash debug builds at the end of buf_page_print().
BUF_PAGE_PRINT_NO_FULL:
Do not print the full page dump. This can be useful when adding
diagnostic printout to flushing or to the doublewrite buffer.
trx_sys_doublewrite_init_or_restore_page(): Replace exit(1) with ut_error,
so that we can get a core dump if this extraordinary condition happens.
rb:924 approved by Sunny Bains
-rw-r--r-- | storage/innobase/btr/btr0btr.c | 87 | ||||
-rw-r--r-- | storage/innobase/btr/btr0sea.c | 8 | ||||
-rw-r--r-- | storage/innobase/buf/buf0buf.c | 28 | ||||
-rw-r--r-- | storage/innobase/buf/buf0flu.c | 3 | ||||
-rw-r--r-- | storage/innobase/ibuf/ibuf0ibuf.c | 10 | ||||
-rw-r--r-- | storage/innobase/include/btr0btr.ic | 2 | ||||
-rw-r--r-- | storage/innobase/include/buf0buf.h | 15 | ||||
-rw-r--r-- | storage/innobase/include/page0page.ic | 2 | ||||
-rw-r--r-- | storage/innobase/lock/lock0lock.c | 2 | ||||
-rw-r--r-- | storage/innobase/page/page0cur.c | 2 | ||||
-rw-r--r-- | storage/innobase/page/page0page.c | 14 | ||||
-rw-r--r-- | storage/innobase/row/row0sel.c | 5 | ||||
-rw-r--r-- | storage/innobase/trx/trx0sys.c | 10 |
13 files changed, 125 insertions, 63 deletions
diff --git a/storage/innobase/btr/btr0btr.c b/storage/innobase/btr/btr0btr.c index 88371208230..85893fe3282 100644 --- a/storage/innobase/btr/btr0btr.c +++ b/storage/innobase/btr/btr0btr.c @@ -56,11 +56,12 @@ btr_corruption_report( (unsigned) buf_block_get_space(block), (unsigned) buf_block_get_page_no(block), index->name, index->table_name); - buf_page_print(buf_block_get_frame(block), 0); if (block->page.zip.data) { buf_page_print(block->page.zip.data, - buf_block_get_zip_size(block)); + buf_block_get_zip_size(block), + BUF_PAGE_PRINT_NO_CRASH); } + buf_page_print(buf_block_get_frame(block), 0, 0); } #ifdef UNIV_BLOB_DEBUG @@ -1215,9 +1216,11 @@ btr_page_get_father_node_ptr_func( != page_no)) { rec_t* print_rec; fputs("InnoDB: Dump of the child page:\n", stderr); - buf_page_print(page_align(user_rec), 0); + buf_page_print(page_align(user_rec), 0, + BUF_PAGE_PRINT_NO_CRASH); fputs("InnoDB: Dump of the parent page:\n", stderr); - buf_page_print(page_align(node_ptr), 0); + buf_page_print(page_align(node_ptr), 0, + BUF_PAGE_PRINT_NO_CRASH); fputs("InnoDB: Corruption of an index tree: table ", stderr); ut_print_name(stderr, NULL, TRUE, index->table_name); @@ -1654,8 +1657,8 @@ btr_page_reorganize_low( if (UNIV_UNLIKELY(data_size1 != data_size2) || UNIV_UNLIKELY(max_ins_size1 != max_ins_size2)) { - buf_page_print(page, 0); - buf_page_print(temp_page, 0); + buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH); + buf_page_print(temp_page, 0, BUF_PAGE_PRINT_NO_CRASH); fprintf(stderr, "InnoDB: Error: page old data size %lu" " new data size %lu\n" @@ -1666,6 +1669,7 @@ btr_page_reorganize_low( (unsigned long) data_size1, (unsigned long) data_size2, (unsigned long) max_ins_size1, (unsigned long) max_ins_size2); + ut_ad(0); } else { success = TRUE; } @@ -3867,7 +3871,7 @@ btr_index_rec_validate( (ulong) rec_get_n_fields_old(rec), (ulong) n); if (dump_on_error) { - buf_page_print(page, 0); + buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH); fputs("InnoDB: corrupt record ", stderr); rec_print_old(stderr, rec); @@ -3905,7 +3909,8 @@ btr_index_rec_validate( (ulong) i, (ulong) len, (ulong) fixed_size); if (dump_on_error) { - buf_page_print(page, 0); + buf_page_print(page, 0, + BUF_PAGE_PRINT_NO_CRASH); fputs("InnoDB: corrupt record ", stderr); rec_print_new(stderr, rec, offsets); @@ -4115,8 +4120,8 @@ loop: btr_validate_report2(index, level, block, right_block); fputs("InnoDB: broken FIL_PAGE_NEXT" " or FIL_PAGE_PREV links\n", stderr); - buf_page_print(page, 0); - buf_page_print(right_page, 0); + buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH); + buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH); ret = FALSE; } @@ -4125,8 +4130,8 @@ loop: != page_is_comp(page))) { btr_validate_report2(index, level, block, right_block); fputs("InnoDB: 'compact' flag mismatch\n", stderr); - buf_page_print(page, 0); - buf_page_print(right_page, 0); + buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH); + buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH); ret = FALSE; @@ -4149,8 +4154,8 @@ loop: fputs("InnoDB: records in wrong order" " on adjacent pages\n", stderr); - buf_page_print(page, 0); - buf_page_print(right_page, 0); + buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH); + buf_page_print(right_page, 0, BUF_PAGE_PRINT_NO_CRASH); fputs("InnoDB: record ", stderr); rec = page_rec_get_prev(page_get_supremum_rec(page)); @@ -4199,8 +4204,8 @@ loop: fputs("InnoDB: node pointer to the page is wrong\n", stderr); - buf_page_print(father_page, 0); - buf_page_print(page, 0); + buf_page_print(father_page, 0, BUF_PAGE_PRINT_NO_CRASH); + buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH); fputs("InnoDB: node ptr ", stderr); rec_print(stderr, node_ptr, index); @@ -4232,8 +4237,10 @@ loop: btr_validate_report1(index, level, block); - buf_page_print(father_page, 0); - buf_page_print(page, 0); + buf_page_print(father_page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print(page, 0, + BUF_PAGE_PRINT_NO_CRASH); fputs("InnoDB: Error: node ptrs differ" " on levels > 0\n" @@ -4278,9 +4285,15 @@ loop: btr_validate_report1(index, level, block); - buf_page_print(father_page, 0); - buf_page_print(page, 0); - buf_page_print(right_page, 0); + buf_page_print( + father_page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + right_page, 0, + BUF_PAGE_PRINT_NO_CRASH); } } else { page_t* right_father_page @@ -4298,10 +4311,18 @@ loop: btr_validate_report1(index, level, block); - buf_page_print(father_page, 0); - buf_page_print(right_father_page, 0); - buf_page_print(page, 0); - buf_page_print(right_page, 0); + buf_page_print( + father_page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + right_father_page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + right_page, 0, + BUF_PAGE_PRINT_NO_CRASH); } if (page_get_page_no(right_father_page) @@ -4315,10 +4336,18 @@ loop: btr_validate_report1(index, level, block); - buf_page_print(father_page, 0); - buf_page_print(right_father_page, 0); - buf_page_print(page, 0); - buf_page_print(right_page, 0); + buf_page_print( + father_page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + right_father_page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print( + right_page, 0, + BUF_PAGE_PRINT_NO_CRASH); } } } diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index ddc94064da9..e80d38ed0ee 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -1176,7 +1176,7 @@ cleanup: index->name, (ulong) block->n_pointers); rw_lock_x_unlock(&btr_search_latch); - btr_search_validate(); + ut_ad(btr_search_validate()); } else { rw_lock_x_unlock(&btr_search_latch); } @@ -1908,7 +1908,9 @@ btr_search_validate(void) (ulong) block->curr_left_side); if (n_page_dumps < 20) { - buf_page_print(page, 0); + buf_page_print( + page, 0, + BUF_PAGE_PRINT_NO_CRASH); n_page_dumps++; } } diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index 0721929abd3..7b13caf6216 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -605,8 +605,12 @@ void buf_page_print( /*===========*/ const byte* read_buf, /*!< in: a database page */ - ulint zip_size) /*!< in: compressed page size, or - 0 for uncompressed pages */ + ulint zip_size, /*!< in: compressed page size, or + 0 for uncompressed pages */ + ulint flags) /*!< in: 0 or + BUF_PAGE_PRINT_NO_CRASH or + BUF_PAGE_PRINT_NO_FULL */ + { #ifndef UNIV_HOTBACKUP dict_index_t* index; @@ -615,17 +619,18 @@ buf_page_print( ulint old_checksum; ulint size = zip_size; - ut_ad(0); - if (!size) { size = UNIV_PAGE_SIZE; } - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", - (ulong) size); - ut_print_buf(stderr, read_buf, size); - fputs("\nInnoDB: End of page dump\n", stderr); + if (!(flags & BUF_PAGE_PRINT_NO_FULL)) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Page dump in ascii and hex (%lu bytes):\n", + (ulong) size); + ut_print_buf(stderr, read_buf, size); + fputs("\nInnoDB: End of page dump\n", stderr); + } if (zip_size) { /* Print compressed page. */ @@ -797,6 +802,8 @@ buf_page_print( stderr); break; } + + ut_ad(flags & BUF_PAGE_PRINT_NO_CRASH); } #ifndef UNIV_HOTBACKUP @@ -3557,7 +3564,8 @@ corrupt: "InnoDB: You may have to recover" " from a backup.\n", (ulong) bpage->offset); - buf_page_print(frame, buf_page_get_zip_size(bpage)); + buf_page_print(frame, buf_page_get_zip_size(bpage), + BUF_PAGE_PRINT_NO_CRASH); fprintf(stderr, "InnoDB: Database page corruption on disk" " or a failed\n" diff --git a/storage/innobase/buf/buf0flu.c b/storage/innobase/buf/buf0flu.c index 06b3ec393c1..6e8e8fdda5a 100644 --- a/storage/innobase/buf/buf0flu.c +++ b/storage/innobase/buf/buf0flu.c @@ -757,7 +757,8 @@ buf_flush_buffered_writes(void) if (UNIV_UNLIKELY (!page_simple_validate_new(block->frame))) { corrupted_page: - buf_page_print(block->frame, 0); + buf_page_print(block->frame, 0, + BUF_PAGE_PRINT_NO_CRASH); ut_print_timestamp(stderr); fprintf(stderr, diff --git a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c index 96af9038be2..157899b67a4 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.c +++ b/storage/innobase/ibuf/ibuf0ibuf.c @@ -3931,9 +3931,10 @@ ibuf_insert_to_index_page( "InnoDB: but the number of fields does not match!\n", stderr); dump: - buf_page_print(page, 0); + buf_page_print(page, 0, BUF_PAGE_PRINT_NO_CRASH); dtuple_print(stderr, entry); + ut_ad(0); fputs("InnoDB: The table where where" " this index record belongs\n" @@ -4506,12 +4507,14 @@ ibuf_merge_or_delete_for_page( bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, &mtr); - buf_page_print(bitmap_page, 0); + buf_page_print(bitmap_page, 0, + BUF_PAGE_PRINT_NO_CRASH); ibuf_mtr_commit(&mtr); fputs("\nInnoDB: Dump of the page:\n", stderr); - buf_page_print(block->frame, 0); + buf_page_print(block->frame, 0, + BUF_PAGE_PRINT_NO_CRASH); fprintf(stderr, "InnoDB: Error: corruption in the tablespace." @@ -4531,6 +4534,7 @@ ibuf_merge_or_delete_for_page( (ulong) page_no, (ulong) fil_page_get_type(block->frame)); + ut_ad(0); } } diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index 1bd22a0ebc6..55bdb289b21 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -277,7 +277,7 @@ btr_node_ptr_get_child_page_no( "InnoDB: a nonsensical page number 0" " in a node ptr record at offset %lu\n", (ulong) page_offset(rec)); - buf_page_print(page_align(rec), 0); + buf_page_print(page_align(rec), 0, 0); } return(page_no); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 456f077a13d..c8c2830d480 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2012, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -680,6 +680,13 @@ buf_print(void); /*============*/ #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ #endif /* !UNIV_HOTBACKUP */ +enum buf_page_print_flags { + /** Do not crash at the end of buf_page_print(). */ + BUF_PAGE_PRINT_NO_CRASH = 1, + /** Do not print the full page dump. */ + BUF_PAGE_PRINT_NO_FULL = 2 +}; + /********************************************************************//** Prints a page to stderr. */ UNIV_INTERN @@ -687,8 +694,12 @@ void buf_page_print( /*===========*/ const byte* read_buf, /*!< in: a database page */ - ulint zip_size); /*!< in: compressed page size, or + ulint zip_size, /*!< in: compressed page size, or 0 for uncompressed pages */ + ulint flags) /*!< in: 0 or + BUF_PAGE_PRINT_NO_CRASH or + BUF_PAGE_PRINT_NO_FULL */ + __attribute__((nonnull)); /********************************************************************//** Decompress a block. @return TRUE if successful */ diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index 115cee64f8b..50b4e3808c8 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -710,7 +710,7 @@ page_rec_get_next_low( (void*) rec, (ulong) page_get_space_id(page), (ulong) page_get_page_no(page)); - buf_page_print(page, 0); + buf_page_print(page, 0, 0); ut_error; } diff --git a/storage/innobase/lock/lock0lock.c b/storage/innobase/lock/lock0lock.c index 263516ab5fd..a516b5545de 100644 --- a/storage/innobase/lock/lock0lock.c +++ b/storage/innobase/lock/lock0lock.c @@ -1615,7 +1615,7 @@ lock_sec_rec_some_has_impl_off_kernel( if (!lock_check_trx_id_sanity(page_get_max_trx_id(page), rec, index, offsets, TRUE)) { - buf_page_print(page, 0); + buf_page_print(page, 0, 0); /* The page is corrupt: try to avoid a crash by returning NULL */ diff --git a/storage/innobase/page/page0cur.c b/storage/innobase/page/page0cur.c index 936762b986a..87358c3693d 100644 --- a/storage/innobase/page/page0cur.c +++ b/storage/innobase/page/page0cur.c @@ -900,7 +900,7 @@ page_cur_parse_insert_rec( ut_print_buf(stderr, ptr2, 300); putc('\n', stderr); - buf_page_print(page, 0); + buf_page_print(page, 0, 0); ut_error; } diff --git a/storage/innobase/page/page0page.c b/storage/innobase/page/page0page.c index e250bb359fe..ec4b80553c2 100644 --- a/storage/innobase/page/page0page.c +++ b/storage/innobase/page/page0page.c @@ -148,7 +148,7 @@ page_dir_find_owner_slot( fputs("\n" "InnoDB: on that page!\n", stderr); - buf_page_print(page, 0); + buf_page_print(page, 0, 0); ut_error; } @@ -569,8 +569,10 @@ page_copy_rec_list_end_no_locks( /* Track an assertion failure reported on the mailing list on June 18th, 2003 */ - buf_page_print(new_page, 0); - buf_page_print(page_align(rec), 0); + buf_page_print(new_page, 0, + BUF_PAGE_PRINT_NO_CRASH); + buf_page_print(page_align(rec), 0, + BUF_PAGE_PRINT_NO_CRASH); ut_print_timestamp(stderr); fprintf(stderr, @@ -1834,7 +1836,7 @@ page_check_dir( fprintf(stderr, "InnoDB: Page directory corruption:" " infimum not pointed to\n"); - buf_page_print(page, 0); + buf_page_print(page, 0, 0); } if (UNIV_UNLIKELY(!page_rec_is_supremum_low(supremum_offs))) { @@ -1842,7 +1844,7 @@ page_check_dir( fprintf(stderr, "InnoDB: Page directory corruption:" " supremum not pointed to\n"); - buf_page_print(page, 0); + buf_page_print(page, 0, 0); } } #endif /* !UNIV_HOTBACKUP */ @@ -2546,7 +2548,7 @@ func_exit2: (ulong) page_get_space_id(page), (ulong) page_get_page_no(page), index->name); - buf_page_print(page, 0); + buf_page_print(page, 0, 0); } return(ret); diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 0d1d3aad1c6..4216a020994 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -3998,7 +3998,8 @@ rec_loop: wrong_offs: if (srv_force_recovery == 0 || moves_up == FALSE) { ut_print_timestamp(stderr); - buf_page_print(page_align(rec), 0); + buf_page_print(page_align(rec), 0, + BUF_PAGE_PRINT_NO_CRASH); fprintf(stderr, "\nInnoDB: rec address %p," " buf block fix count %lu\n", @@ -4017,7 +4018,7 @@ wrong_offs: "InnoDB: restore from a backup, or" " dump + drop + reimport the table.\n", stderr); - + ut_ad(0); err = DB_CORRUPTION; goto lock_wait_or_error; diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c index 66d3ae5463c..ab8e63a8b1f 100644 --- a/storage/innobase/trx/trx0sys.c +++ b/storage/innobase/trx/trx0sys.c @@ -586,12 +586,16 @@ trx_sys_doublewrite_init_or_restore_pages( if (buf_page_is_corrupted(page, zip_size)) { fprintf(stderr, "InnoDB: Dump of the page:\n"); - buf_page_print(read_buf, zip_size); + buf_page_print( + read_buf, zip_size, + BUF_PAGE_PRINT_NO_CRASH); fprintf(stderr, "InnoDB: Dump of" " corresponding page" " in doublewrite buffer:\n"); - buf_page_print(page, zip_size); + buf_page_print( + page, zip_size, + BUF_PAGE_PRINT_NO_CRASH); fprintf(stderr, "InnoDB: Also the page in the" @@ -605,7 +609,7 @@ trx_sys_doublewrite_init_or_restore_pages( "InnoDB: option:\n" "InnoDB:" " innodb_force_recovery=6\n"); - exit(1); + ut_error; } /* Write the good page from the |