From b3df257cfde490066933c4dc8329f9670aa8de58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 9 Aug 2016 16:51:35 +0300 Subject: [PATCH] MDEV-10469: innodb.innodb-alter-tempfile fails in buildbot: InnoDB: Warning: database page corruption or a failed Test case intentionally crashes the server and that could lead partially written pages that are then restored from doublewrite buffer. --- .../innodb/r/innodb-alter-tempfile.result | 4 + .../suite/innodb/t/innodb-alter-tempfile.test | 7 ++ storage/innobase/buf/buf0buf.cc | 95 ++++++++++--------- storage/xtradb/buf/buf0buf.cc | 95 ++++++++++--------- 4 files changed, 107 insertions(+), 94 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter-tempfile.result b/mysql-test/suite/innodb/r/innodb-alter-tempfile.result index ce13ad0978b..3cc973ca3a3 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-tempfile.result +++ b/mysql-test/suite/innodb/r/innodb-alter-tempfile.result @@ -4,6 +4,10 @@ # Temporary tablename will be unique. This makes sure that future # in-place ALTERs of the same table will not be blocked due to # temporary tablename. +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed +"); +call mtr.add_suppression("InnoDB: file read of space .* page .*"); +call mtr.add_suppression("InnoDB: Trying to recover it from the doublewrite buffer."); # Crash the server in ha_innobase::commit_inplace_alter_table() CREATE TABLE t1 (f1 INT NOT NULL, f2 INT NOT NULL) ENGINE=innodb; SET debug='d,innodb_alter_commit_crash_before_commit'; diff --git a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test index ec1ea35f1cf..e1e736fc678 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-tempfile.test +++ b/mysql-test/suite/innodb/t/innodb-alter-tempfile.test @@ -20,6 +20,13 @@ --echo # in-place ALTERs of the same table will not be blocked due to --echo # temporary tablename. +# As we intentionally crash below, there could be partially written +# pages that are then recovered from the doublewrite buffer +call mtr.add_suppression("InnoDB: Warning: database page corruption or a failed +"); +call mtr.add_suppression("InnoDB: file read of space .* page .*"); +call mtr.add_suppression("InnoDB: Trying to recover it from the doublewrite buffer."); + let datadir= `select @@datadir`; --let $_server_id= `SELECT @@server_id` diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 5b1f479168a..2c7c578150d 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -614,7 +614,7 @@ buf_page_is_corrupted( "InnoDB: " REFMAN "forcing-innodb-recovery.html\n" "InnoDB: for more information.\n", - (ulong) mach_read_from_4( + (ulint) mach_read_from_4( read_buf + FIL_PAGE_OFFSET), (lsn_t) mach_read_from_8( read_buf + FIL_PAGE_LSN), @@ -802,7 +802,7 @@ buf_page_print( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", - (ulong) size); + size); ut_print_buf(stderr, read_buf, size); fputs("\nInnoDB: End of page dump\n", stderr); } @@ -2301,9 +2301,9 @@ buf_zip_decompress( } fprintf(stderr, - "InnoDB: unable to decompress space %lu page %lu\n", - (ulong) block->page.space, - (ulong) block->page.offset); + "InnoDB: unable to decompress space %u page %u\n", + block->page.space, + block->page.offset); return(FALSE); case FIL_PAGE_TYPE_ALLOCATED: @@ -3536,8 +3536,8 @@ buf_page_init( fprintf(stderr, "InnoDB: Error: page %lu %lu already found" " in the hash table: %p, %p\n", - (ulong) space, - (ulong) offset, + space, + offset, (const void*) hash_page, (const void*) block); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(&block->mutex); @@ -3898,7 +3898,7 @@ buf_page_create( #ifdef UNIV_DEBUG if (buf_debug_prints) { fprintf(stderr, "Creating space %lu page %lu to buffer\n", - (ulong) space, (ulong) offset); + space, offset); } #endif /* UNIV_DEBUG */ @@ -4200,10 +4200,10 @@ buf_page_io_complete( ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Error: reading page %lu\n" + " InnoDB: Error: reading page %u\n" "InnoDB: which is in the" " doublewrite buffer!\n", - (ulong) bpage->offset); + bpage->offset); } else if (!read_space_id && !read_page_no) { /* This is likely an uninitialized page. */ } else if ((bpage->space @@ -4219,10 +4219,11 @@ buf_page_io_complete( " InnoDB: Error: space id and page n:o" " stored in the page\n" "InnoDB: read in are %lu:%lu," - " should be %lu:%lu!\n", - (ulong) read_space_id, (ulong) read_page_no, - (ulong) bpage->space, - (ulong) bpage->offset); + " should be %u:%u!\n", + read_space_id, + read_page_no, + bpage->space, + bpage->offset); } /* From version 3.23.38 up we store the page checksum @@ -4246,19 +4247,19 @@ corrupt: fprintf(stderr, "InnoDB: Database page corruption on disk" " or a failed\n" - "InnoDB: file read of page %lu.\n" + "InnoDB: file read of page %u.\n" "InnoDB: You may have to recover" " from a backup.\n", - (ulong) bpage->offset); + bpage->offset); 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" - "InnoDB: file read of page %lu.\n" + "InnoDB: file read of page %u.\n" "InnoDB: You may have to recover" " from a backup.\n", - (ulong) bpage->offset); + bpage->offset); fputs("InnoDB: It is also possible that" " your operating\n" "InnoDB: system has corrupted its" @@ -4374,8 +4375,8 @@ corrupt: if (buf_debug_prints) { fprintf(stderr, "Has %s page space %lu page no %lu\n", io_type == BUF_IO_READ ? "read" : "written", - (ulong) buf_page_get_space(bpage), - (ulong) buf_page_get_page_no(bpage)); + buf_page_get_space(bpage), + buf_page_get_page_no(bpage)); } #endif /* UNIV_DEBUG */ @@ -4410,17 +4411,17 @@ buf_all_freed_instance( if (UNIV_LIKELY_NULL(block)) { fil_space_t* space = fil_space_get(block->page.space); ib_logf(IB_LOG_LEVEL_ERROR, - "Page %lu %lu still fixed or dirty.", - (ulong) block->page.space, - (ulong) block->page.offset); + "Page %u %u still fixed or dirty.", + block->page.space, + block->page.offset); ib_logf(IB_LOG_LEVEL_ERROR, "Page oldest_modification %lu fix_count %d io_fix %d.", block->page.oldest_modification, block->page.buf_fix_count, buf_page_get_io_fix(&block->page)); ib_logf(IB_LOG_LEVEL_ERROR, - "Page space_id %lu name %s.", - (ulong)block->page.space, + "Page space_id %u name %s.", + block->page.space, (space && space->name) ? space->name : "NULL"); ut_error; } @@ -4721,16 +4722,16 @@ assert_s_latched: if (n_lru + n_free > buf_pool->curr_size + n_zip) { fprintf(stderr, "n LRU %lu, n free %lu, pool %lu zip %lu\n", - (ulong) n_lru, (ulong) n_free, - (ulong) buf_pool->curr_size, (ulong) n_zip); + n_lru, n_free, + buf_pool->curr_size, n_zip); ut_error; } ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { fprintf(stderr, "Free list len %lu, free blocks %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) n_free); + UT_LIST_GET_LEN(buf_pool->free), + n_free); ut_error; } @@ -4809,20 +4810,20 @@ buf_print_instance( "n pending flush LRU %lu list %lu single page %lu\n" "pages made young %lu, not young %lu\n" "pages read %lu, created %lu, written %lu\n", - (ulong) size, - (ulong) UT_LIST_GET_LEN(buf_pool->LRU), - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), - (ulong) buf_pool->n_pend_unzip, - (ulong) buf_pool->n_pend_reads, - (ulong) buf_pool->n_flush[BUF_FLUSH_LRU], - (ulong) buf_pool->n_flush[BUF_FLUSH_LIST], - (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], - (ulong) buf_pool->stat.n_pages_made_young, - (ulong) buf_pool->stat.n_pages_not_made_young, - (ulong) buf_pool->stat.n_pages_read, - (ulong) buf_pool->stat.n_pages_created, - (ulong) buf_pool->stat.n_pages_written); + (ulint) size, + (ulint) UT_LIST_GET_LEN(buf_pool->LRU), + (ulint) UT_LIST_GET_LEN(buf_pool->free), + (ulint) UT_LIST_GET_LEN(buf_pool->flush_list), + (ulint) buf_pool->n_pend_unzip, + (ulint) buf_pool->n_pend_reads, + (ulint) buf_pool->n_flush[BUF_FLUSH_LRU], + (ulint) buf_pool->n_flush[BUF_FLUSH_LIST], + (ulint) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], + (ulint) buf_pool->stat.n_pages_made_young, + (ulint) buf_pool->stat.n_pages_not_made_young, + (ulint) buf_pool->stat.n_pages_read, + (ulint) buf_pool->stat.n_pages_created, + (ulint) buf_pool->stat.n_pages_written); buf_flush_list_mutex_exit(buf_pool); @@ -4873,7 +4874,7 @@ buf_print_instance( fprintf(stderr, "Block count for index %llu in buffer is about %lu", (ullint) index_ids[i], - (ulong) counts[i]); + (ulint) counts[i]); if (index) { putc(' ', stderr); @@ -5321,10 +5322,10 @@ buf_print_io_instance( fprintf(file, "Buffer pool hit rate %lu / 1000," " young-making rate %lu / 1000 not %lu / 1000\n", - (ulong) hit_rate, - (ulong) (1000 * pool_info->young_making_delta + (ulint) hit_rate, + (ulint) (1000 * pool_info->young_making_delta / pool_info->n_page_get_delta), - (ulong) (1000 * pool_info->not_young_making_delta + (ulint) (1000 * pool_info->not_young_making_delta / pool_info->n_page_get_delta)); } else { fputs("No buffer pool page gets since the last printout\n", diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 489c690d9f9..40a6fe6545f 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -683,7 +683,7 @@ buf_page_is_corrupted( "InnoDB: " REFMAN "forcing-innodb-recovery.html\n" "InnoDB: for more information.\n", - (ulong) mach_read_from_4( + (ulint) mach_read_from_4( read_buf + FIL_PAGE_OFFSET), (lsn_t) mach_read_from_8( read_buf + FIL_PAGE_LSN), @@ -878,7 +878,7 @@ buf_page_print( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", - (ulong) size); + size); ut_print_buf(stderr, read_buf, size); fputs("\nInnoDB: End of page dump\n", stderr); } @@ -2426,9 +2426,9 @@ buf_zip_decompress( } fprintf(stderr, - "InnoDB: unable to decompress space %lu page %lu\n", - (ulong) block->page.space, - (ulong) block->page.offset); + "InnoDB: unable to decompress space %u page %u\n", + block->page.space, + block->page.offset); return(FALSE); case FIL_PAGE_TYPE_ALLOCATED: @@ -3735,8 +3735,8 @@ buf_page_init( fprintf(stderr, "InnoDB: Error: page %lu %lu already found" " in the hash table: %p, %p\n", - (ulong) space, - (ulong) offset, + space, + offset, (const void*) hash_page, (const void*) block); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(&block->mutex); @@ -4102,7 +4102,7 @@ buf_page_create( #ifdef UNIV_DEBUG if (buf_debug_prints) { fprintf(stderr, "Creating space %lu page %lu to buffer\n", - (ulong) space, (ulong) offset); + space, offset); } #endif /* UNIV_DEBUG */ @@ -4412,10 +4412,10 @@ buf_page_io_complete( ut_print_timestamp(stderr); fprintf(stderr, - " InnoDB: Error: reading page %lu\n" + " InnoDB: Error: reading page %u\n" "InnoDB: which is in the" " doublewrite buffer!\n", - (ulong) bpage->offset); + bpage->offset); } else if (!read_space_id && !read_page_no) { /* This is likely an uninitialized page. */ } else if ((bpage->space @@ -4431,10 +4431,11 @@ buf_page_io_complete( " InnoDB: Error: space id and page n:o" " stored in the page\n" "InnoDB: read in are %lu:%lu," - " should be %lu:%lu!\n", - (ulong) read_space_id, (ulong) read_page_no, - (ulong) bpage->space, - (ulong) bpage->offset); + " should be %u:%u!\n", + read_space_id, + read_page_no, + bpage->space, + bpage->offset); } if (UNIV_LIKELY(!bpage->is_corrupt || @@ -4460,19 +4461,19 @@ corrupt: fprintf(stderr, "InnoDB: Database page corruption on disk" " or a failed\n" - "InnoDB: file read of page %lu.\n" + "InnoDB: file read of page %u.\n" "InnoDB: You may have to recover" " from a backup.\n", - (ulong) bpage->offset); + bpage->offset); 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" - "InnoDB: file read of page %lu.\n" + "InnoDB: file read of page %u.\n" "InnoDB: You may have to recover" " from a backup.\n", - (ulong) bpage->offset); + bpage->offset); fputs("InnoDB: It is also possible that" " your operating\n" "InnoDB: system has corrupted its" @@ -4658,8 +4659,8 @@ retry_mutex: if (buf_debug_prints) { fprintf(stderr, "Has %s page space %lu page no %lu\n", io_type == BUF_IO_READ ? "read" : "written", - (ulong) buf_page_get_space(bpage), - (ulong) buf_page_get_page_no(bpage)); + buf_page_get_space(bpage), + buf_page_get_page_no(bpage)); } #endif /* UNIV_DEBUG */ @@ -4696,17 +4697,17 @@ buf_all_freed_instance( if (UNIV_LIKELY_NULL(block)) { fil_space_t* space = fil_space_get(block->page.space); ib_logf(IB_LOG_LEVEL_ERROR, - "Page %lu %lu still fixed or dirty.", - (ulong) block->page.space, - (ulong) block->page.offset); + "Page %u %u still fixed or dirty.", + block->page.space, + block->page.offset); ib_logf(IB_LOG_LEVEL_ERROR, "Page oldest_modification %lu fix_count %d io_fix %d.", block->page.oldest_modification, block->page.buf_fix_count, buf_page_get_io_fix(&block->page)); ib_logf(IB_LOG_LEVEL_ERROR, - "Page space_id %lu name %s.", - (ulong)block->page.space, + "Page space_id %u name %s.", + block->page.space, (space && space->name) ? space->name : "NULL"); ut_error; } @@ -4999,8 +5000,8 @@ buf_pool_validate_instance( if (n_lru + n_free > buf_pool->curr_size + n_zip) { fprintf(stderr, "n LRU %lu, n free %lu, pool %lu zip %lu\n", - (ulong) n_lru, (ulong) n_free, - (ulong) buf_pool->curr_size, (ulong) n_zip); + n_lru, n_free, + buf_pool->curr_size, n_zip); ut_error; } @@ -5010,8 +5011,8 @@ buf_pool_validate_instance( if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { fprintf(stderr, "Free list len %lu, free blocks %lu\n", - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) n_free); + UT_LIST_GET_LEN(buf_pool->free), + n_free); ut_error; } @@ -5092,20 +5093,20 @@ buf_print_instance( "n pending flush LRU %lu list %lu single page %lu\n" "pages made young %lu, not young %lu\n" "pages read %lu, created %lu, written %lu\n", - (ulong) size, - (ulong) UT_LIST_GET_LEN(buf_pool->LRU), - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), - (ulong) buf_pool->n_pend_unzip, - (ulong) buf_pool->n_pend_reads, - (ulong) buf_pool->n_flush[BUF_FLUSH_LRU], - (ulong) buf_pool->n_flush[BUF_FLUSH_LIST], - (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], - (ulong) buf_pool->stat.n_pages_made_young, - (ulong) buf_pool->stat.n_pages_not_made_young, - (ulong) buf_pool->stat.n_pages_read, - (ulong) buf_pool->stat.n_pages_created, - (ulong) buf_pool->stat.n_pages_written); + (ulint) size, + (ulint) UT_LIST_GET_LEN(buf_pool->LRU), + (ulint) UT_LIST_GET_LEN(buf_pool->free), + (ulint) UT_LIST_GET_LEN(buf_pool->flush_list), + (ulint) buf_pool->n_pend_unzip, + (ulint) buf_pool->n_pend_reads, + (ulint) buf_pool->n_flush[BUF_FLUSH_LRU], + (ulint) buf_pool->n_flush[BUF_FLUSH_LIST], + (ulint) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE], + (ulint) buf_pool->stat.n_pages_made_young, + (ulint) buf_pool->stat.n_pages_not_made_young, + (ulint) buf_pool->stat.n_pages_read, + (ulint) buf_pool->stat.n_pages_created, + (ulint) buf_pool->stat.n_pages_written); /* Count the number of blocks belonging to each index in the buffer */ @@ -5156,7 +5157,7 @@ buf_print_instance( fprintf(stderr, "Block count for index %llu in buffer is about %lu", (ullint) index_ids[i], - (ulong) counts[i]); + (ulint) counts[i]); if (index) { putc(' ', stderr); @@ -5610,10 +5611,10 @@ buf_print_io_instance( fprintf(file, "Buffer pool hit rate %lu / 1000," " young-making rate %lu / 1000 not %lu / 1000\n", - (ulong) hit_rate, - (ulong) (1000 * pool_info->young_making_delta + (ulint) hit_rate, + (ulint) (1000 * pool_info->young_making_delta / pool_info->n_page_get_delta), - (ulong) (1000 * pool_info->not_young_making_delta + (ulint) (1000 * pool_info->not_young_making_delta / pool_info->n_page_get_delta)); } else { fputs("No buffer pool page gets since the last printout\n",