Commit 39100cd9 authored by Marko Mäkelä's avatar Marko Mäkelä

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
parent 99ce9430
......@@ -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 @@ btr_validate_level(
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 @@ btr_validate_level(
!= 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 @@ btr_validate_level(
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 @@ btr_validate_level(
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 @@ btr_validate_level(
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 @@ btr_validate_level(
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 @@ btr_validate_level(
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 @@ btr_validate_level(
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);
}
}
}
......
/*****************************************************************************
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 @@ btr_search_drop_page_hash_index(
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++;
}
}
......
......@@ -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 @@ buf_page_io_complete(
"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"
......
......@@ -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,
......
......@@ -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);
}
}
......
......@@ -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);
......
/*****************************************************************************
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 */
......
......@@ -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;
}
......
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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 @@ page_validate(
(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);
......
......@@ -3998,7 +3998,8 @@ row_search_for_mysql(
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 @@ row_search_for_mysql(
"InnoDB: restore from a backup, or"
" dump + drop + reimport the table.\n",
stderr);
ut_ad(0);
err = DB_CORRUPTION;
goto lock_wait_or_error;
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment