Commit f118a9c1 authored by marko's avatar marko

branches/zip: Prepare for writing compressed and reading pages.

buf_page_print(): Print also compressed pages.  Add parameter zip_size.

buf_flush_init_for_writing(): Stamp the fields on a compressed B-tree index
page.

Add the header field FIL_PAGE_ZBLOB_SPACE_ID as an alias of FIL_PAGE_PREV.

page_zip_calc_checksum(): New function.

page_zip_compress(): Avoid copying the fields that are written in
buf_flush_init_for_writing().

page_zip_header_cmp(): New function for comparing those fields of the
page header that will not be written in buf_flush_init_for_writing().
parent 7d6a4e70
...@@ -605,9 +605,9 @@ btr_page_get_father_for_rec( ...@@ -605,9 +605,9 @@ btr_page_get_father_for_rec(
buf_frame_get_page_no(page))) { buf_frame_get_page_no(page))) {
rec_t* print_rec; rec_t* print_rec;
fputs("InnoDB: Dump of the child page:\n", stderr); fputs("InnoDB: Dump of the child page:\n", stderr);
buf_page_print(buf_frame_align(page)); buf_page_print(buf_frame_align(page), 0);
fputs("InnoDB: Dump of the parent page:\n", stderr); fputs("InnoDB: Dump of the parent page:\n", stderr);
buf_page_print(buf_frame_align(node_ptr)); buf_page_print(buf_frame_align(node_ptr), 0);
fputs("InnoDB: Corruption of an index tree: table ", stderr); fputs("InnoDB: Corruption of an index tree: table ", stderr);
ut_print_name(stderr, NULL, index->table_name); ut_print_name(stderr, NULL, index->table_name);
...@@ -925,8 +925,8 @@ btr_page_reorganize_low( ...@@ -925,8 +925,8 @@ btr_page_reorganize_low(
if (UNIV_UNLIKELY(data_size1 != data_size2) if (UNIV_UNLIKELY(data_size1 != data_size2)
|| UNIV_UNLIKELY(max_ins_size1 != max_ins_size2)) { || UNIV_UNLIKELY(max_ins_size1 != max_ins_size2)) {
buf_page_print(page); buf_page_print(page, 0);
buf_page_print(temp_page); buf_page_print(temp_page, 0);
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: page old data size %lu new data size %lu\n" "InnoDB: Error: page old data size %lu new data size %lu\n"
"InnoDB: Error: page old max ins size %lu new max ins size %lu\n" "InnoDB: Error: page old max ins size %lu new max ins size %lu\n"
...@@ -2676,7 +2676,7 @@ btr_index_rec_validate( ...@@ -2676,7 +2676,7 @@ btr_index_rec_validate(
(ulong) rec_get_n_fields_old(rec), (ulong) n); (ulong) rec_get_n_fields_old(rec), (ulong) n);
if (dump_on_error) { if (dump_on_error) {
buf_page_print(page); buf_page_print(page, 0);
fputs("InnoDB: corrupt record ", stderr); fputs("InnoDB: corrupt record ", stderr);
rec_print_old(stderr, rec); rec_print_old(stderr, rec);
...@@ -2710,7 +2710,7 @@ btr_index_rec_validate( ...@@ -2710,7 +2710,7 @@ btr_index_rec_validate(
(ulong) i, (ulong) len, (ulong) dtype_get_fixed_size(type)); (ulong) i, (ulong) len, (ulong) dtype_get_fixed_size(type));
if (dump_on_error) { if (dump_on_error) {
buf_page_print(page); buf_page_print(page, 0);
fputs("InnoDB: corrupt record ", stderr); fputs("InnoDB: corrupt record ", stderr);
rec_print_new(stderr, rec, offsets); rec_print_new(stderr, rec, offsets);
...@@ -2924,8 +2924,8 @@ btr_validate_level( ...@@ -2924,8 +2924,8 @@ btr_validate_level(
fputs("InnoDB: records in wrong order" fputs("InnoDB: records in wrong order"
" on adjacent pages\n", stderr); " on adjacent pages\n", stderr);
buf_page_print(page); buf_page_print(page, 0);
buf_page_print(right_page); buf_page_print(right_page, 0);
fputs("InnoDB: record ", stderr); fputs("InnoDB: record ", stderr);
rec = page_rec_get_prev(page_get_supremum_rec(page)); rec = page_rec_get_prev(page_get_supremum_rec(page));
...@@ -2967,8 +2967,8 @@ btr_validate_level( ...@@ -2967,8 +2967,8 @@ btr_validate_level(
fputs("InnoDB: node pointer to the page is wrong\n", fputs("InnoDB: node pointer to the page is wrong\n",
stderr); stderr);
buf_page_print(father_page); buf_page_print(father_page, 0);
buf_page_print(page); buf_page_print(page, 0);
fputs("InnoDB: node ptr ", stderr); fputs("InnoDB: node ptr ", stderr);
rec_print_new(stderr, node_ptr, offsets); rec_print_new(stderr, node_ptr, offsets);
...@@ -3007,8 +3007,8 @@ btr_validate_level( ...@@ -3007,8 +3007,8 @@ btr_validate_level(
btr_validate_report1(index, level, page); btr_validate_report1(index, level, page);
buf_page_print(father_page); buf_page_print(father_page, 0);
buf_page_print(page); buf_page_print(page, 0);
fputs("InnoDB: Error: node ptrs differ" fputs("InnoDB: Error: node ptrs differ"
" on levels > 0\n" " on levels > 0\n"
...@@ -3052,9 +3052,9 @@ btr_validate_level( ...@@ -3052,9 +3052,9 @@ btr_validate_level(
btr_validate_report1(index, level, btr_validate_report1(index, level,
page); page);
buf_page_print(father_page); buf_page_print(father_page, 0);
buf_page_print(page); buf_page_print(page, 0);
buf_page_print(right_page); buf_page_print(right_page, 0);
} }
} else { } else {
right_father_page = buf_frame_align( right_father_page = buf_frame_align(
...@@ -3071,10 +3071,10 @@ btr_validate_level( ...@@ -3071,10 +3071,10 @@ btr_validate_level(
btr_validate_report1(index, level, btr_validate_report1(index, level,
page); page);
buf_page_print(father_page); buf_page_print(father_page, 0);
buf_page_print(right_father_page); buf_page_print(right_father_page, 0);
buf_page_print(page); buf_page_print(page, 0);
buf_page_print(right_page); buf_page_print(right_page, 0);
} }
if (buf_frame_get_page_no(right_father_page) if (buf_frame_get_page_no(right_father_page)
...@@ -3088,10 +3088,10 @@ btr_validate_level( ...@@ -3088,10 +3088,10 @@ btr_validate_level(
btr_validate_report1(index, level, btr_validate_report1(index, level,
page); page);
buf_page_print(father_page); buf_page_print(father_page, 0);
buf_page_print(right_father_page); buf_page_print(right_father_page, 0);
buf_page_print(page); buf_page_print(page, 0);
buf_page_print(right_page); buf_page_print(right_page, 0);
} }
} }
} }
......
...@@ -1672,7 +1672,7 @@ btr_search_validate(void) ...@@ -1672,7 +1672,7 @@ btr_search_validate(void)
(ulong) block->curr_n_bytes, (ulong) block->curr_side); (ulong) block->curr_n_bytes, (ulong) block->curr_side);
if (n_page_dumps < 20) { if (n_page_dumps < 20) {
buf_page_print(page); buf_page_print(page, 0);
n_page_dumps++; n_page_dumps++;
} }
} }
......
...@@ -410,19 +410,88 @@ Prints a page to stderr. */ ...@@ -410,19 +410,88 @@ Prints a page to stderr. */
void void
buf_page_print( buf_page_print(
/*===========*/ /*===========*/
byte* read_buf) /* in: a database page */ byte* read_buf, /* in: a database page */
ulint zip_size) /* in: compressed page size, or
0 for uncompressed pages */
{ {
dict_index_t* index; dict_index_t* index;
ulint checksum; ulint checksum;
ulint old_checksum; ulint old_checksum;
ulint size = zip_size;
if (!size) {
size = UNIV_PAGE_SIZE;
}
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n", fprintf(stderr, " InnoDB: Page dump in ascii and hex (%lu bytes):\n",
(ulint)UNIV_PAGE_SIZE); (ulong) size);
ut_print_buf(stderr, read_buf, UNIV_PAGE_SIZE); ut_print_buf(stderr, read_buf, size);
fputs("InnoDB: End of page dump\n", stderr); fputs("InnoDB: End of page dump\n", stderr);
/* TODO: print zipped pages differently, esp. BLOB pages */ if (zip_size) {
/* Print compressed page. */
switch (fil_page_get_type(read_buf)) {
case FIL_PAGE_TYPE_ZBLOB:
checksum = srv_use_checksums
? buf_calc_zblob_page_checksum(
read_buf, zip_size)
: BUF_NO_CHECKSUM_MAGIC;
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Compressed BLOB page checksum %lu, stored %lu\n"
"InnoDB: Page lsn %lu %lu\n"
"InnoDB: Page number (if stored to page already) %lu,\n"
"InnoDB: space id (if stored to page already) %lu\n",
(ulong) checksum,
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_SPACE_OR_CHKSUM),
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_LSN),
(ulong) mach_read_from_4(read_buf
+ (FIL_PAGE_LSN + 4)),
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_OFFSET),
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_ZBLOB_SPACE_ID));
return;
default:
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: unknown page type %lu, assuming FIL_PAGE_INDEX\n",
fil_page_get_type(read_buf));
/* fall through */
case FIL_PAGE_INDEX:
checksum = srv_use_checksums
? page_zip_calc_checksum(
read_buf, zip_size)
: BUF_NO_CHECKSUM_MAGIC;
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Compressed page checksum %lu, stored %lu\n"
"InnoDB: Page lsn %lu %lu\n"
"InnoDB: Page number (if stored to page already) %lu,\n"
"InnoDB: space id (if stored to page already) %lu\n",
(ulong) checksum,
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_SPACE_OR_CHKSUM),
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_LSN),
(ulong) mach_read_from_4(read_buf
+ (FIL_PAGE_LSN + 4)),
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_OFFSET),
(ulong) mach_read_from_4(read_buf
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
return;
case FIL_PAGE_TYPE_XDES:
/* This is an uncompressed page. */
break;
}
}
checksum = srv_use_checksums ? checksum = srv_use_checksums ?
buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC; buf_calc_page_new_checksum(read_buf) : BUF_NO_CHECKSUM_MAGIC;
old_checksum = srv_use_checksums ? old_checksum = srv_use_checksums ?
...@@ -465,18 +534,21 @@ buf_page_print( ...@@ -465,18 +534,21 @@ buf_page_print(
(ulong) ut_dulint_get_high(btr_page_get_index_id(read_buf)), (ulong) ut_dulint_get_high(btr_page_get_index_id(read_buf)),
(ulong) ut_dulint_get_low(btr_page_get_index_id(read_buf))); (ulong) ut_dulint_get_low(btr_page_get_index_id(read_buf)));
#ifdef UNIV_HOTBACKUP
/* If the code is in ibbackup, dict_sys may be uninitialized, /* If the code is in ibbackup, dict_sys may be uninitialized,
i.e., NULL */ i.e., NULL */
if (dict_sys != NULL) { if (dict_sys == NULL) {
break;
}
#endif /* UNIV_HOTBACKUP */
index = dict_index_find_on_id_low( index = dict_index_find_on_id_low(
btr_page_get_index_id(read_buf)); btr_page_get_index_id(read_buf));
if (index) { if (index) {
fputs("InnoDB: (", stderr); fputs("InnoDB: (", stderr);
dict_index_name_print(stderr, NULL, index); dict_index_name_print(stderr, NULL, index);
fputs(")\n", stderr); fputs(")\n", stderr);
}
} }
break; break;
case FIL_PAGE_INODE: case FIL_PAGE_INODE:
...@@ -1941,7 +2013,7 @@ buf_page_io_complete( ...@@ -1941,7 +2013,7 @@ buf_page_io_complete(
fputs( fputs(
"InnoDB: You may have to recover from a backup.\n", stderr); "InnoDB: You may have to recover from a backup.\n", stderr);
buf_page_print(block->frame); buf_page_print(block->frame, block->page_zip.size);
fprintf(stderr, fprintf(stderr,
"InnoDB: Database page corruption on disk or a failed\n" "InnoDB: Database page corruption on disk or a failed\n"
......
...@@ -16,6 +16,7 @@ Created 11/11/1995 Heikki Tuuri ...@@ -16,6 +16,7 @@ Created 11/11/1995 Heikki Tuuri
#include "ut0byte.h" #include "ut0byte.h"
#include "ut0lst.h" #include "ut0lst.h"
#include "page0page.h" #include "page0page.h"
#include "page0zip.h"
#include "fil0fil.h" #include "fil0fil.h"
#include "buf0buf.h" #include "buf0buf.h"
#include "buf0lru.h" #include "buf0lru.h"
...@@ -254,6 +255,8 @@ buf_flush_buffered_writes(void) ...@@ -254,6 +255,8 @@ buf_flush_buffered_writes(void)
block = trx_doublewrite->buf_block_arr[i]; block = trx_doublewrite->buf_block_arr[i];
ut_a(block->state == BUF_BLOCK_FILE_PAGE); ut_a(block->state == BUF_BLOCK_FILE_PAGE);
/* TODO: page_zip */
if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4) if (mach_read_from_4(block->frame + FIL_PAGE_LSN + 4)
!= mach_read_from_4(block->frame + UNIV_PAGE_SIZE != mach_read_from_4(block->frame + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) { - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
...@@ -269,7 +272,7 @@ buf_flush_buffered_writes(void) ...@@ -269,7 +272,7 @@ buf_flush_buffered_writes(void)
if (UNIV_UNLIKELY(!page_simple_validate_new( if (UNIV_UNLIKELY(!page_simple_validate_new(
block->frame))) { block->frame))) {
corrupted_page: corrupted_page:
buf_page_print(block->frame); buf_page_print(block->frame, 0);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
...@@ -456,12 +459,12 @@ buf_flush_init_for_writing( ...@@ -456,12 +459,12 @@ buf_flush_init_for_writing(
page_zip_des_t* page_zip = page_zip_; page_zip_des_t* page_zip = page_zip_;
ulint zip_size = fil_space_get_zip_size(space); ulint zip_size = fil_space_get_zip_size(space);
if (zip_size) { if (zip_size && zip_size != ULINT_UNDEFINED) {
switch (fil_page_get_type(page)) { switch (UNIV_EXPECT(fil_page_get_type(page), FIL_PAGE_INDEX)) {
case FIL_PAGE_TYPE_ZBLOB: case FIL_PAGE_TYPE_ZBLOB:
ut_ad(!page_zip); ut_ad(!page_zip);
mach_write_to_4(page + FIL_PAGE_OFFSET, page_no); mach_write_to_4(page + FIL_PAGE_OFFSET, page_no);
mach_write_to_4(page + FIL_PAGE_PREV, space); mach_write_to_4(page + FIL_PAGE_ZBLOB_SPACE_ID, space);
mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
srv_use_checksums srv_use_checksums
...@@ -469,9 +472,28 @@ buf_flush_init_for_writing( ...@@ -469,9 +472,28 @@ buf_flush_init_for_writing(
page, zip_size) page, zip_size)
: BUF_NO_CHECKSUM_MAGIC); : BUF_NO_CHECKSUM_MAGIC);
return; return;
case FIL_PAGE_INDEX: case FIL_PAGE_TYPE_XDES:
/* TODO: special handling */ /* This is essentially an uncompressed page. */
break; break;
case FIL_PAGE_INDEX:
ut_a(zip_size == page_zip->size);
mach_write_to_4(page_zip->data
+ FIL_PAGE_OFFSET, page_no);
mach_write_to_8(page_zip->data
+ FIL_PAGE_LSN, newest_lsn);
mach_write_to_4(page_zip->data
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
space);
memset(page_zip->data + FIL_PAGE_FILE_FLUSH_LSN, 0, 8);
mach_write_to_4(page_zip->data
+ FIL_PAGE_SPACE_OR_CHKSUM,
srv_use_checksums
? page_zip_calc_checksum(
page_zip->data, zip_size)
: BUF_NO_CHECKSUM_MAGIC);
return;
default:
ut_error;
} }
} }
...@@ -491,16 +513,6 @@ buf_flush_init_for_writing( ...@@ -491,16 +513,6 @@ buf_flush_init_for_writing(
srv_use_checksums ? srv_use_checksums ?
buf_calc_page_new_checksum(page) : BUF_NO_CHECKSUM_MAGIC); buf_calc_page_new_checksum(page) : BUF_NO_CHECKSUM_MAGIC);
if (UNIV_LIKELY_NULL(page_zip)) {
/* Copy FIL_PAGE_SPACE_OR_CHKSUM and FIL_PAGE_OFFSET */
memcpy(page_zip->data, page, FIL_PAGE_PREV);
/* Copy FIL_PAGE_LSN */
memcpy(page_zip->data + FIL_PAGE_LSN, page + FIL_PAGE_LSN, 8);
/* Copy FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID */
memcpy(page_zip->data + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 4);
}
/* We overwrite the first 4 bytes of the end lsn field to store /* We overwrite the first 4 bytes of the end lsn field to store
the old formula checksum. Since it depends also on the field the old formula checksum. Since it depends also on the field
FIL_PAGE_SPACE_OR_CHKSUM, it has to be calculated after storing the FIL_PAGE_SPACE_OR_CHKSUM, it has to be calculated after storing the
......
...@@ -2839,7 +2839,7 @@ ibuf_insert_to_index_page( ...@@ -2839,7 +2839,7 @@ ibuf_insert_to_index_page(
"InnoDB: Trying to insert a record from the insert buffer to an index page\n" "InnoDB: Trying to insert a record from the insert buffer to an index page\n"
"InnoDB: but the number of fields does not match!\n", stderr); "InnoDB: but the number of fields does not match!\n", stderr);
dump: dump:
buf_page_print(page); buf_page_print(page, 0);
dtuple_print(stderr, entry); dtuple_print(stderr, entry);
...@@ -3147,13 +3147,13 @@ ibuf_merge_or_delete_for_page( ...@@ -3147,13 +3147,13 @@ ibuf_merge_or_delete_for_page(
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, bitmap_page = ibuf_bitmap_get_map_page(space, page_no,
&mtr); &mtr);
buf_page_print(bitmap_page); buf_page_print(bitmap_page, 0);
mtr_commit(&mtr); mtr_commit(&mtr);
fputs("\nInnoDB: Dump of the page:\n", stderr); fputs("\nInnoDB: Dump of the page:\n", stderr);
buf_page_print(page); buf_page_print(page, 0);
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: corruption in the tablespace. Bitmap shows insert\n" "InnoDB: Error: corruption in the tablespace. Bitmap shows insert\n"
......
...@@ -235,7 +235,7 @@ btr_node_ptr_get_child_page_no( ...@@ -235,7 +235,7 @@ btr_node_ptr_get_child_page_no(
fprintf(stderr, fprintf(stderr,
"InnoDB: a nonsensical page number 0 in a node ptr record at offset %lu\n", "InnoDB: a nonsensical page number 0 in a node ptr record at offset %lu\n",
(ulong) ut_align_offset(rec, UNIV_PAGE_SIZE)); (ulong) ut_align_offset(rec, UNIV_PAGE_SIZE));
buf_page_print(buf_frame_align(rec)); buf_page_print(buf_frame_align(rec), 0);
} }
return(page_no); return(page_no);
......
...@@ -517,7 +517,9 @@ Prints a page to stderr. */ ...@@ -517,7 +517,9 @@ Prints a page to stderr. */
void void
buf_page_print( buf_page_print(
/*===========*/ /*===========*/
byte* read_buf); /* in: a database page */ byte* read_buf, /* in: a database page */
ulint zip_size); /* in: compressed page size, or
0 for uncompressed pages */
/************************************************************************* /*************************************************************************
Returns the number of latched pages in the buffer pool. */ Returns the number of latched pages in the buffer pool. */
......
...@@ -58,6 +58,8 @@ extern fil_addr_t fil_addr_null; ...@@ -58,6 +58,8 @@ extern fil_addr_t fil_addr_null;
#define FIL_PAGE_OFFSET 4 /* page offset inside space */ #define FIL_PAGE_OFFSET 4 /* page offset inside space */
#define FIL_PAGE_PREV 8 /* if there is a 'natural' predecessor #define FIL_PAGE_PREV 8 /* if there is a 'natural' predecessor
of the page, its offset */ of the page, its offset */
#define FIL_PAGE_ZBLOB_SPACE_ID 8 /* space id of a compressed BLOB page,
4 bytes */
#define FIL_PAGE_NEXT 12 /* if there is a 'natural' successor #define FIL_PAGE_NEXT 12 /* if there is a 'natural' successor
of the page, its offset */ of the page, its offset */
#define FIL_PAGE_LSN 16 /* lsn of the end of the newest #define FIL_PAGE_LSN 16 /* lsn of the end of the newest
......
...@@ -612,7 +612,7 @@ page_rec_get_next( ...@@ -612,7 +612,7 @@ page_rec_get_next(
rec, buf_pool->frame_zero, rec, buf_pool->frame_zero,
buf_pool->high_end, buf_pool->high_end,
(ulong)buf_block_align(rec)->buf_fix_count); (ulong)buf_block_align(rec)->buf_fix_count);
buf_page_print(page); buf_page_print(page, 0);
ut_error; ut_error;
} }
......
...@@ -291,6 +291,17 @@ page_zip_parse_compress( ...@@ -291,6 +291,17 @@ page_zip_parse_compress(
page_zip_des_t* page_zip)/* out: compressed page */ page_zip_des_t* page_zip)/* out: compressed page */
__attribute__((nonnull(1,2))); __attribute__((nonnull(1,2)));
/**************************************************************************
Calculate the compressed page checksum. */
ulint
page_zip_calc_checksum(
/*===================*/
/* out: page checksum */
const void* data, /* in: compressed page */
ulint size) /* in: size of compressed page */
__attribute__((nonnull));
#ifdef UNIV_MATERIALIZE #ifdef UNIV_MATERIALIZE
# undef UNIV_INLINE # undef UNIV_INLINE
# define UNIV_INLINE UNIV_INLINE_ORIGINAL # define UNIV_INLINE UNIV_INLINE_ORIGINAL
......
...@@ -1691,7 +1691,7 @@ lock_sec_rec_some_has_impl_off_kernel( ...@@ -1691,7 +1691,7 @@ lock_sec_rec_some_has_impl_off_kernel(
if (!lock_check_trx_id_sanity(page_get_max_trx_id(page), if (!lock_check_trx_id_sanity(page_get_max_trx_id(page),
rec, index, offsets, TRUE)) { rec, index, offsets, TRUE)) {
buf_page_print(page); buf_page_print(page, 0);
/* The page is corrupt: try to avoid a crash by returning /* The page is corrupt: try to avoid a crash by returning
NULL */ NULL */
......
...@@ -3928,6 +3928,8 @@ os_aio_simulated_handle( ...@@ -3928,6 +3928,8 @@ os_aio_simulated_handle(
is sensible; reported page checksum errors from is sensible; reported page checksum errors from
Linux seem to wipe over the page end */ Linux seem to wipe over the page end */
/* TODO: disable this for compressed pages */
for (len2 = 0; len2 + UNIV_PAGE_SIZE <= total_len; for (len2 = 0; len2 + UNIV_PAGE_SIZE <= total_len;
len2 += UNIV_PAGE_SIZE) { len2 += UNIV_PAGE_SIZE) {
if (mach_read_from_4(combined_buf + len2 if (mach_read_from_4(combined_buf + len2
...@@ -3941,7 +3943,7 @@ os_aio_simulated_handle( ...@@ -3941,7 +3943,7 @@ os_aio_simulated_handle(
fprintf(stderr, fprintf(stderr,
"InnoDB: Writing a block of %lu bytes, currently writing at offset %lu\n", "InnoDB: Writing a block of %lu bytes, currently writing at offset %lu\n",
(ulong)total_len, (ulong)len2); (ulong)total_len, (ulong)len2);
buf_page_print(combined_buf + len2); buf_page_print(combined_buf + len2, 0);
fprintf(stderr, fprintf(stderr,
"InnoDB: ERROR: The page to be written seems corrupt!\n"); "InnoDB: ERROR: The page to be written seems corrupt!\n");
} }
......
...@@ -838,7 +838,7 @@ page_cur_parse_insert_rec( ...@@ -838,7 +838,7 @@ page_cur_parse_insert_rec(
fputs("Dump of 300 bytes of log:\n", stderr); fputs("Dump of 300 bytes of log:\n", stderr);
ut_print_buf(stderr, ptr2, 300); ut_print_buf(stderr, ptr2, 300);
buf_page_print(page); buf_page_print(page, 0);
ut_error; ut_error;
} }
......
...@@ -140,7 +140,7 @@ page_dir_find_owner_slot( ...@@ -140,7 +140,7 @@ page_dir_find_owner_slot(
fputs("\n" fputs("\n"
"InnoDB: on that page!\n", stderr); "InnoDB: on that page!\n", stderr);
buf_page_print(page); buf_page_print(page, 0);
ut_error; ut_error;
} }
...@@ -559,8 +559,8 @@ page_copy_rec_list_end_no_locks( ...@@ -559,8 +559,8 @@ page_copy_rec_list_end_no_locks(
/* Track an assertion failure reported on the mailing /* Track an assertion failure reported on the mailing
list on June 18th, 2003 */ list on June 18th, 2003 */
buf_page_print(new_page); buf_page_print(new_page, 0);
buf_page_print(ut_align_down(rec, UNIV_PAGE_SIZE)); buf_page_print(ut_align_down(rec, UNIV_PAGE_SIZE), 0);
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
...@@ -1720,20 +1720,21 @@ page_check_dir( ...@@ -1720,20 +1720,21 @@ page_check_dir(
n_slots = page_dir_get_n_slots(page); n_slots = page_dir_get_n_slots(page);
if (page_dir_slot_get_rec(page_dir_get_nth_slot(page, 0)) if (UNIV_UNLIKELY(page_dir_slot_get_rec(page_dir_get_nth_slot(page, 0))
!= page_get_infimum_rec(page)) { != page_get_infimum_rec(page))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Page directory corruption: supremum not pointed to\n"); "InnoDB: Page directory corruption: infimum not pointed to\n");
buf_page_print(page); buf_page_print(page, 0);
} }
if (page_dir_slot_get_rec(page_dir_get_nth_slot(page, n_slots - 1)) if (UNIV_UNLIKELY(page_dir_slot_get_rec(page_dir_get_nth_slot(
!= page_get_supremum_rec(page)) { page, n_slots - 1))
!= page_get_supremum_rec(page))) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Page directory corruption: supremum not pointed to\n"); "InnoDB: Page directory corruption: supremum not pointed to\n");
buf_page_print(page); buf_page_print(page, 0);
} }
} }
...@@ -2389,7 +2390,7 @@ page_validate( ...@@ -2389,7 +2390,7 @@ page_validate(
(ulong) buf_frame_get_page_no(page)); (ulong) buf_frame_get_page_no(page));
dict_index_name_print(stderr, NULL, index); dict_index_name_print(stderr, NULL, index);
putc('\n', stderr); putc('\n', stderr);
buf_page_print(page); buf_page_print(page, 0);
} }
return(ret); return(ret);
......
...@@ -538,6 +538,7 @@ page_zip_compress( ...@@ -538,6 +538,7 @@ page_zip_compress(
byte* storage;/* storage of uncompressed columns */ byte* storage;/* storage of uncompressed columns */
ut_a(page_is_comp((page_t*) page)); ut_a(page_is_comp((page_t*) page));
ut_a(fil_page_get_type((page_t*) page) == FIL_PAGE_INDEX);
ut_ad(page_simple_validate_new((page_t*) page)); ut_ad(page_simple_validate_new((page_t*) page));
ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_simple_validate(page_zip));
...@@ -870,8 +871,13 @@ page_zip_compress( ...@@ -870,8 +871,13 @@ page_zip_compress(
page_zip->m_end = page_zip->m_start = PAGE_DATA + c_stream.total_out; page_zip->m_end = page_zip->m_start = PAGE_DATA + c_stream.total_out;
page_zip->n_blobs = n_blobs; page_zip->n_blobs = n_blobs;
/* Copy the page header */ /* Copy those header fields that will not be written
memcpy(page_zip->data, page, PAGE_DATA); in buf_flush_init_for_writing() */
memcpy(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV,
FIL_PAGE_LSN - FIL_PAGE_PREV);
memcpy(page_zip->data + FIL_PAGE_TYPE, page + FIL_PAGE_TYPE, 2);
memcpy(page_zip->data + FIL_PAGE_DATA, page + FIL_PAGE_DATA,
PAGE_DATA - FIL_PAGE_DATA);
/* Copy the rest of the compressed page */ /* Copy the rest of the compressed page */
memcpy(page_zip->data + PAGE_DATA, buf, page_zip->size - PAGE_DATA); memcpy(page_zip->data + PAGE_DATA, buf, page_zip->size - PAGE_DATA);
mem_heap_free(heap); mem_heap_free(heap);
...@@ -1902,6 +1908,26 @@ page_zip_validate( ...@@ -1902,6 +1908,26 @@ page_zip_validate(
} }
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */ #endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
#ifdef UNIV_DEBUG
static
ibool
page_zip_header_cmp(
/*================*/
/* out: TRUE */
const page_zip_des_t* page_zip,/* in: compressed page */
const byte* page) /* in: uncompressed page */
{
ut_ad(!memcmp(page_zip->data + FIL_PAGE_PREV, page + FIL_PAGE_PREV,
FIL_PAGE_LSN - FIL_PAGE_PREV));
ut_ad(!memcmp(page_zip->data + FIL_PAGE_TYPE, page + FIL_PAGE_TYPE,
2));
ut_ad(!memcmp(page_zip->data + FIL_PAGE_DATA, page + FIL_PAGE_DATA,
PAGE_DATA - FIL_PAGE_DATA));
return(TRUE);
}
#endif /* UNIV_DEBUG */
/************************************************************************** /**************************************************************************
Write an entire record on the compressed page. The data must already Write an entire record on the compressed page. The data must already
have been written to the uncompressed page. */ have been written to the uncompressed page. */
...@@ -1928,10 +1954,11 @@ page_zip_write_rec( ...@@ -1928,10 +1954,11 @@ page_zip_write_rec(
ut_ad(rec_offs_validate((rec_t*) rec, index, offsets)); ut_ad(rec_offs_validate((rec_t*) rec, index, offsets));
ut_ad(page_zip->m_start >= PAGE_DATA); ut_ad(page_zip->m_start >= PAGE_DATA);
ut_ad(!memcmp(ut_align_down((byte*) rec, UNIV_PAGE_SIZE),
page_zip->data, PAGE_DATA));
page = ut_align_down((rec_t*) rec, UNIV_PAGE_SIZE); page = ut_align_down((rec_t*) rec, UNIV_PAGE_SIZE);
ut_ad(page_zip_header_cmp(page_zip, page));
slot = page_zip_dir_find(page_zip, slot = page_zip_dir_find(page_zip,
ut_align_offset(rec, UNIV_PAGE_SIZE)); ut_align_offset(rec, UNIV_PAGE_SIZE));
ut_a(slot); ut_a(slot);
...@@ -2228,7 +2255,7 @@ page_zip_write_blob_ptr( ...@@ -2228,7 +2255,7 @@ page_zip_write_blob_ptr(
ut_ad(rec_offs_nth_extern(offsets, n)); ut_ad(rec_offs_nth_extern(offsets, n));
ut_ad(page_zip->m_start >= PAGE_DATA); ut_ad(page_zip->m_start >= PAGE_DATA);
ut_ad(!memcmp(page, page_zip->data, PAGE_DATA)); ut_ad(page_zip_header_cmp(page_zip, page));
ut_ad(page_is_leaf(page)); ut_ad(page_is_leaf(page));
...@@ -2379,7 +2406,7 @@ page_zip_write_node_ptr( ...@@ -2379,7 +2406,7 @@ page_zip_write_node_ptr(
ut_ad(page_rec_is_comp(rec)); ut_ad(page_rec_is_comp(rec));
ut_ad(page_zip->m_start >= PAGE_DATA); ut_ad(page_zip->m_start >= PAGE_DATA);
ut_ad(!memcmp(page, page_zip->data, PAGE_DATA)); ut_ad(page_zip_header_cmp(page_zip, page));
ut_ad(!page_is_leaf(page)); ut_ad(!page_is_leaf(page));
...@@ -2443,7 +2470,7 @@ page_zip_write_trx_id_and_roll_ptr( ...@@ -2443,7 +2470,7 @@ page_zip_write_trx_id_and_roll_ptr(
ut_ad(rec_offs_comp(offsets)); ut_ad(rec_offs_comp(offsets));
ut_ad(page_zip->m_start >= PAGE_DATA); ut_ad(page_zip->m_start >= PAGE_DATA);
ut_ad(!memcmp(page, page_zip->data, PAGE_DATA)); ut_ad(page_zip_header_cmp(page_zip, page));
ut_ad(page_is_leaf(page)); ut_ad(page_is_leaf(page));
...@@ -2936,3 +2963,19 @@ page_zip_parse_compress( ...@@ -2936,3 +2963,19 @@ page_zip_parse_compress(
return(ptr + size); return(ptr + size);
} }
/**************************************************************************
Calculate the compressed page checksum. */
ulint
page_zip_calc_checksum(
/*===================*/
/* out: page checksum */
const void* data, /* in: compressed page */
ulint size) /* in: size of compressed page */
{
/* Exclude the 32-bit checksum field from the checksum. */
return((ulint) adler32(0,
((const Bytef*) data) + FIL_PAGE_OFFSET,
size - FIL_PAGE_OFFSET));
}
...@@ -3720,7 +3720,7 @@ stderr); ...@@ -3720,7 +3720,7 @@ stderr);
wrong_offs: wrong_offs:
if (srv_force_recovery == 0 || moves_up == FALSE) { if (srv_force_recovery == 0 || moves_up == FALSE) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
buf_page_print(buf_frame_align(rec)); buf_page_print(buf_frame_align(rec), 0);
fprintf(stderr, fprintf(stderr,
"\nInnoDB: rec address %p, first buffer frame %p\n" "\nInnoDB: rec address %p, first buffer frame %p\n"
"InnoDB: buffer pool high end %p, buf block fix count %lu\n", "InnoDB: buffer pool high end %p, buf block fix count %lu\n",
......
...@@ -489,10 +489,10 @@ trx_sys_doublewrite_init_or_restore_pages( ...@@ -489,10 +489,10 @@ trx_sys_doublewrite_init_or_restore_pages(
if (buf_page_is_corrupted(page, zip_size)) { if (buf_page_is_corrupted(page, zip_size)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Dump of the page:\n"); "InnoDB: Dump of the page:\n");
buf_page_print(read_buf); buf_page_print(read_buf, zip_size);
fprintf(stderr, fprintf(stderr,
"InnoDB: Dump of corresponding page in doublewrite buffer:\n"); "InnoDB: Dump of corresponding page in doublewrite buffer:\n");
buf_page_print(page); buf_page_print(page, zip_size);
fprintf(stderr, fprintf(stderr,
"InnoDB: Also the page in the doublewrite buffer is corrupt.\n" "InnoDB: Also the page in the doublewrite buffer is corrupt.\n"
......
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