Skip to content
Permalink
Browse files

MDEV-19738: Skip doublewrite on MLOG_ZIP_PAGE_COMPRESS

page_zip_compress(), page_zip_compress_write_log(),
page_zip_copy_recs(): Replace the parameters page,page_zip with block,
and set buf_page_t::init_on_flush on success
if innodb_log_optimize_ddl=OFF.

page_zip_parse_compress_no_data(): Merge with the only caller
recv_parse_or_apply_log_rec_body().
  • Loading branch information...
dr-m committed Jun 12, 2019
1 parent 8bb4ea2 commit d46db415cef910c65b0e550a9d00fe188cfd8910
@@ -1507,7 +1507,7 @@ btr_page_reorganize_low(
}

if (page_zip
&& !page_zip_compress(page_zip, page, index, z_level, mtr)) {
&& !page_zip_compress(block, index, z_level, mtr)) {

/* Restore the old page and exit. */
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
@@ -1951,7 +1951,7 @@ btr_root_raise_and_insert(
ut_a(new_page_zip);

/* Copy the page byte for byte. */
page_zip_copy_recs(new_page_zip, new_page,
page_zip_copy_recs(new_block,
root_page_zip, root, index, mtr);

/* Update the lock table and possible hash index. */
@@ -3063,7 +3063,7 @@ btr_page_split_and_insert(
as appropriate. Deleting will always succeed. */
ut_a(new_page_zip);

page_zip_copy_recs(new_page_zip, new_page,
page_zip_copy_recs(new_block,
page_zip, page, cursor->index, mtr);
page_delete_rec_list_end(move_limit - page + new_page,
new_block, cursor->index,
@@ -3106,7 +3106,7 @@ btr_page_split_and_insert(
as appropriate. Deleting will always succeed. */
ut_a(new_page_zip);

page_zip_copy_recs(new_page_zip, new_page,
page_zip_copy_recs(new_block,
page_zip, page, cursor->index, mtr);
page_delete_rec_list_start(move_limit - page
+ new_page, new_block,
@@ -3396,7 +3396,6 @@ btr_lift_page_up(
mtr_t* mtr) /*!< in: mtr */
{
buf_block_t* father_block;
page_t* father_page;
ulint page_level;
page_zip_des_t* father_page_zip;
page_t* page = buf_block_get_frame(block);
@@ -3433,7 +3432,6 @@ btr_lift_page_up(
}
father_block = btr_cur_get_block(&cursor);
father_page_zip = buf_block_get_page_zip(father_block);
father_page = buf_block_get_frame(father_block);

n_blocks = 0;

@@ -3481,7 +3479,6 @@ btr_lift_page_up(

father_block = blocks[0];
father_page_zip = buf_block_get_page_zip(father_block);
father_page = buf_block_get_frame(father_block);
}

mem_heap_free(heap);
@@ -3515,7 +3512,7 @@ btr_lift_page_up(
ut_a(page_zip);

/* Copy the page byte for byte. */
page_zip_copy_recs(father_page_zip, father_page,
page_zip_copy_recs(father_block,
page_zip, page, index, mtr);

/* Update the lock table and possible hash index. */
@@ -3568,7 +3565,7 @@ btr_lift_page_up(
&& !index->table->is_temporary()) {
ibuf_reset_free_bits(father_block);
}
ut_ad(page_validate(father_page, index));
ut_ad(page_validate(father_block->frame, index));
ut_ad(btr_check_node_ptr(index, father_block, mtr));

return(lift_father_up ? block_orig : father_block);
@@ -373,8 +373,7 @@ PageBulk::compress()
{
ut_ad(m_page_zip != NULL);

return(page_zip_compress(m_page_zip, m_page, m_index,
page_zip_level, &m_mtr));
return page_zip_compress(m_block, m_index, page_zip_level, &m_mtr);
}

/** Get node pointer
@@ -922,7 +922,7 @@ rtr_split_page_move_rec_list(
if (new_page_zip) {
mtr_set_log_mode(mtr, log_mode);

if (!page_zip_compress(new_page_zip, new_page, index,
if (!page_zip_compress(new_block, index,
page_zip_level, mtr)) {
ulint ret_pos;

@@ -1130,7 +1130,7 @@ rtr_page_split_and_insert(
as appropriate. Deleting will always succeed. */
ut_a(new_page_zip);

page_zip_copy_recs(new_page_zip, new_page,
page_zip_copy_recs(new_block,
page_zip, page, cursor->index, mtr);

page_cursor = btr_cur_get_page_cur(cursor);
@@ -128,17 +128,12 @@ page_zip_set_alloc(
void* stream, /*!< in/out: zlib stream */
mem_heap_t* heap); /*!< in: memory heap to use */

/**********************************************************************//**
Compress a page.
@return TRUE on success, FALSE on failure; page_zip will be left
intact on failure. */
ibool
/** Attempt to compress a ROW_FORMAT=COMPRESSED page.
@retval true on success
@retval false on failure; block->page.zip will be left intact. */
bool
page_zip_compress(
/*==============*/
page_zip_des_t* page_zip, /*!< in: size; out: data,
n_blobs, m_start, m_end,
m_nonempty */
const page_t* page, /*!< in: uncompressed page */
buf_block_t* block, /*!< in/out: buffer block */
dict_index_t* index, /*!< in: index of the B-tree
node */
ulint level, /*!< in: commpression level */
@@ -461,11 +456,7 @@ related to the storage of records. Also copy PAGE_MAX_TRX_ID.
NOTE: The caller must update the lock table and the adaptive hash index. */
void
page_zip_copy_recs(
/*===============*/
page_zip_des_t* page_zip, /*!< out: copy of src_zip
(n_blobs, m_start, m_end,
m_nonempty, data[0..size-1]) */
page_t* page, /*!< out: copy of src */
buf_block_t* block, /*!< in/out: buffer block */
const page_zip_des_t* src_zip, /*!< in: compressed page */
const page_t* src, /*!< in: page */
dict_index_t* index, /*!< in: index of the B-tree */
@@ -511,19 +502,6 @@ page_zip_compress_write_log_no_data(
const page_t* page, /*!< in: page that is compressed */
dict_index_t* index, /*!< in: index */
mtr_t* mtr); /*!< in: mtr */
/**********************************************************************//**
Parses a log record of compressing an index page without the data.
@return end of log record or NULL */
UNIV_INLINE
byte*
page_zip_parse_compress_no_data(
/*============================*/
byte* ptr, /*!< in: buffer */
byte* end_ptr, /*!< in: buffer end */
page_t* page, /*!< in: uncompressed page */
page_zip_des_t* page_zip, /*!< out: compressed page */
dict_index_t* index) /*!< in: index */
MY_ATTRIBUTE((nonnull(1,2)));

/**********************************************************************//**
Reset the counters used for filling
@@ -379,38 +379,6 @@ page_zip_compress_write_log_no_data(
}
}

/**********************************************************************//**
Parses a log record of compressing an index page without the data.
@return end of log record or NULL */
UNIV_INLINE
byte*
page_zip_parse_compress_no_data(
/*============================*/
byte* ptr, /*!< in: buffer */
byte* end_ptr, /*!< in: buffer end */
page_t* page, /*!< in: uncompressed page */
page_zip_des_t* page_zip, /*!< out: compressed page */
dict_index_t* index) /*!< in: index */
{
ulint level;
if (end_ptr == ptr) {
return(NULL);
}

level = mach_read_from_1(ptr);

/* If page compression fails then there must be something wrong
because a compress log record is logged only if the compression
was successful. Crash in this case. */

if (page
&& !page_zip_compress(page_zip, page, index, level, NULL)) {
ut_error;
}

return(ptr + 1);
}

/**********************************************************************//**
Reset the counters used for filling
INFORMATION_SCHEMA.innodb_cmp_per_index. */
@@ -1662,8 +1662,15 @@ recv_parse_or_apply_log_rec_body(

ut_a(!page || ((ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table)));
ptr = page_zip_parse_compress_no_data(
ptr, end_ptr, page, page_zip, index);
if (end_ptr == ptr) {
ptr = NULL;
break;
}
if (page &&
!page_zip_compress(block, index, *ptr, NULL)) {
ut_error;
}
ptr++;
}
break;
case MLOG_ZIP_WRITE_TRX_ID:
@@ -1638,8 +1638,8 @@ page_cur_insert_rec_zip(

if (!log_compressed) {
if (page_zip_compress(
page_zip, page, index,
level, NULL)) {
page_cur_get_block(cursor),
index, level, NULL)) {
page_cur_insert_rec_write_log(
insert_rec, rec_size,
cursor->rec, index, mtr);
@@ -458,10 +458,9 @@ page_create_zip(
handle */
{
page_t* page;
page_zip_des_t* page_zip = buf_block_get_page_zip(block);

ut_ad(block);
ut_ad(page_zip);
ut_ad(buf_block_get_page_zip(block));
ut_ad(dict_table_is_comp(index->table));

/* PAGE_MAX_TRX_ID or PAGE_ROOT_AUTO_INC are always 0 for
@@ -484,7 +483,7 @@ page_create_zip(
mach_write_to_2(PAGE_HEADER + PAGE_LEVEL + page, level);
mach_write_to_8(PAGE_HEADER + PAGE_MAX_TRX_ID + page, max_trx_id);

if (!page_zip_compress(page_zip, page, index, page_zip_level, mtr)) {
if (!page_zip_compress(block, index, page_zip_level, mtr)) {
/* The compression of a newly created
page should always succeed. */
ut_error;
@@ -705,7 +704,7 @@ page_copy_rec_list_end(
if (new_page_zip) {
mtr_set_log_mode(mtr, log_mode);

if (!page_zip_compress(new_page_zip, new_page, index,
if (!page_zip_compress(new_block, index,
page_zip_level, mtr)) {
/* Before trying to reorganize the page,
store the number of preceding records on the page. */
@@ -867,7 +866,7 @@ page_copy_rec_list_start(
DBUG_EXECUTE_IF("page_copy_rec_list_start_compress_fail",
goto zip_reorganize;);

if (!page_zip_compress(new_page_zip, new_page, index,
if (!page_zip_compress(new_block, index,
page_zip_level, mtr)) {
ulint ret_pos;
#ifndef DBUG_OFF

0 comments on commit d46db41

Please sign in to comment.
You can’t perform that action at this time.