Commit 7f2d91cb authored by marko's avatar marko

branches/zip: Fix some bugs in incremental compression.

btr_create(): page_zip_compress() returns FALSE on failure.

page_zip_write_header(): Write to page_zip->data[] instead of page_zip[].

buf_flush_init_for_writing(): Add parameter page_zip and set the fields
also in the header of the compressed page.

btr_cur_search_to_nth_level(): Add ut_ad() on page_zip_validate().
parent 4387cbe0
...@@ -763,7 +763,7 @@ btr_create( ...@@ -763,7 +763,7 @@ btr_create(
page_zip = buf_block_get_page_zip(buf_block_align(page)); page_zip = buf_block_get_page_zip(buf_block_align(page));
if (UNIV_LIKELY_NULL(page_zip)) { if (UNIV_LIKELY_NULL(page_zip)) {
if (UNIV_UNLIKELY(page_zip_compress( if (UNIV_UNLIKELY(!page_zip_compress(
page_zip, page, index, mtr))) { page_zip, page, index, mtr))) {
/* An empty page should always be compressible */ /* An empty page should always be compressible */
ut_error; ut_error;
......
...@@ -450,6 +450,7 @@ btr_cur_search_to_nth_level( ...@@ -450,6 +450,7 @@ btr_cur_search_to_nth_level(
/* Loop and search until we arrive at the desired level */ /* Loop and search until we arrive at the desired level */
for (;;) { for (;;) {
buf_block_t* block;
retry_page_get: retry_page_get:
page = buf_page_get_gen(space, page_no, rw_latch, guess, page = buf_page_get_gen(space, page_no, rw_latch, guess,
buf_mode, buf_mode,
...@@ -482,7 +483,12 @@ btr_cur_search_to_nth_level( ...@@ -482,7 +483,12 @@ btr_cur_search_to_nth_level(
goto retry_page_get; goto retry_page_get;
} }
buf_block_align(page)->check_index_page_at_flush = TRUE; block = buf_block_align(page);
ut_ad(!buf_block_get_page_zip(block) || page_zip_validate(
buf_block_get_page_zip(block), page));
block->check_index_page_at_flush = TRUE;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
if (rw_latch != RW_NO_LATCH) { if (rw_latch != RW_NO_LATCH) {
......
...@@ -447,11 +447,14 @@ Initializes a page for writing to the tablespace. */ ...@@ -447,11 +447,14 @@ Initializes a page for writing to the tablespace. */
void void
buf_flush_init_for_writing( buf_flush_init_for_writing(
/*=======================*/ /*=======================*/
byte* page, /* in: page */ byte* page, /* in/out: page */
void* page_zip_, /* in/out: compressed page, or NULL */
dulint newest_lsn, /* in: newest modification lsn to the page */ dulint newest_lsn, /* in: newest modification lsn to the page */
ulint space, /* in: space id */ ulint space, /* in: space id */
ulint page_no) /* in: page number */ ulint page_no) /* in: page number */
{ {
page_zip_des_t* page_zip = page_zip_;
/* Write the newest modification lsn to the page header and trailer */ /* Write the newest modification lsn to the page header and trailer */
mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn);
...@@ -468,6 +471,14 @@ buf_flush_init_for_writing( ...@@ -468,6 +471,14 @@ 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_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
...@@ -510,8 +521,10 @@ buf_flush_write_block_low( ...@@ -510,8 +521,10 @@ buf_flush_write_block_low(
/* Force the log to the disk before writing the modified block */ /* Force the log to the disk before writing the modified block */
log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE); log_write_up_to(block->newest_modification, LOG_WAIT_ALL_GROUPS, TRUE);
#endif #endif
buf_flush_init_for_writing(block->frame, block->newest_modification, buf_flush_init_for_writing(block->frame,
block->space, block->offset); buf_block_get_page_zip(block),
block->newest_modification,
block->space, block->offset);
if (!srv_use_doublewrite_buf || !trx_doublewrite) { if (!srv_use_doublewrite_buf || !trx_doublewrite) {
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER, fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE, FALSE, block->space, block->offset, 0, UNIV_PAGE_SIZE,
......
...@@ -2432,7 +2432,8 @@ fil_create_new_single_table_tablespace( ...@@ -2432,7 +2432,8 @@ fil_create_new_single_table_tablespace(
fsp_header_write_space_id(page, *space_id); fsp_header_write_space_id(page, *space_id);
buf_flush_init_for_writing(page, ut_dulint_zero, *space_id, 0); buf_flush_init_for_writing(page, NULL/* TODO: page_zip */,
ut_dulint_zero, *space_id, 0);
ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE); ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
...@@ -2594,8 +2595,9 @@ fil_reset_too_high_lsns( ...@@ -2594,8 +2595,9 @@ fil_reset_too_high_lsns(
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
page_no = mach_read_from_4(page + FIL_PAGE_OFFSET); page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
buf_flush_init_for_writing(page, current_lsn, space_id, buf_flush_init_for_writing(page,
page_no); NULL/* TODO: page_zip */,
current_lsn, space_id, page_no);
success = os_file_write(filepath, file, page, success = os_file_write(filepath, file, page,
(ulint)(offset & 0xFFFFFFFFUL), (ulint)(offset & 0xFFFFFFFFUL),
(ulint)(offset >> 32), UNIV_PAGE_SIZE); (ulint)(offset >> 32), UNIV_PAGE_SIZE);
......
...@@ -34,7 +34,8 @@ Initializes a page for writing to the tablespace. */ ...@@ -34,7 +34,8 @@ Initializes a page for writing to the tablespace. */
void void
buf_flush_init_for_writing( buf_flush_init_for_writing(
/*=======================*/ /*=======================*/
byte* page, /* in: page */ byte* page, /* in/out: page */
void* page_zip, /* in/out: compressed page, or NULL */
dulint newest_lsn, /* in: newest modification lsn to the page */ dulint newest_lsn, /* in: newest modification lsn to the page */
ulint space, /* in: space id */ ulint space, /* in: space id */
ulint page_no); /* in: page number */ ulint page_no); /* in: page number */
......
...@@ -272,7 +272,7 @@ page_zip_write_header( ...@@ -272,7 +272,7 @@ page_zip_write_header(
ut_ad(pos < PAGE_DATA); ut_ad(pos < PAGE_DATA);
memcpy(page_zip + pos, str, length); memcpy(page_zip->data + pos, str, length);
/* The following would fail in page_cur_insert_rec_low(). */ /* The following would fail in page_cur_insert_rec_low(). */
/* ut_ad(page_zip_validate(page_zip, str - pos)); */ /* ut_ad(page_zip_validate(page_zip, str - pos)); */
......
...@@ -1612,6 +1612,7 @@ recv_addr->space, recv_addr->page_no); ...@@ -1612,6 +1612,7 @@ recv_addr->space, recv_addr->page_no);
fil0fil.c routines */ fil0fil.c routines */
buf_flush_init_for_writing(page, buf_flush_init_for_writing(page,
NULL,/* TODO: page_zip */
mach_read_from_8(page + FIL_PAGE_LSN), mach_read_from_8(page + FIL_PAGE_LSN),
recv_addr->space, recv_addr->page_no); recv_addr->space, recv_addr->page_no);
......
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