From 5bea43f5e03225327cd04e0c302f613600f06081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 9 Dec 2019 15:55:48 +0200 Subject: [PATCH] MDEV-12353: Deprecate and ignore innodb_log_compressed_pages page_zip_compress_write_log_no_data(): Remove. We no longer write the MLOG_ZIP_PAGE_COMPRESS_NO_DATA record. Instead, we will write MLOG_ZIP_PAGE_COMPRESS records. --- .../suite/innodb_zip/r/cmp_per_index.result | 14 ++- .../suite/innodb_zip/t/cmp_per_index.opt | 1 - .../suite/innodb_zip/t/cmp_per_index.test | 16 +-- .../innodb_log_compressed_pages_basic.result | 14 ++- .../suite/sys_vars/r/sysvars_innodb.result | 2 +- storage/innobase/btr/btr0btr.cc | 24 +---- storage/innobase/handler/ha_innodb.cc | 32 ++++-- storage/innobase/include/page0zip.h | 16 --- storage/innobase/include/page0zip.ic | 21 ---- storage/innobase/page/page0cur.cc | 100 +++++------------- storage/innobase/page/page0zip.cc | 4 - 11 files changed, 73 insertions(+), 171 deletions(-) diff --git a/mysql-test/suite/innodb_zip/r/cmp_per_index.result b/mysql-test/suite/innodb_zip/r/cmp_per_index.result index b4e34040630..f26cc952ca9 100644 --- a/mysql-test/suite/innodb_zip/r/cmp_per_index.result +++ b/mysql-test/suite/innodb_zip/r/cmp_per_index.result @@ -52,24 +52,22 @@ SELECT database_name, table_name, index_name, -CASE WHEN compress_ops=47 and @@innodb_compression_level IN (4,8,9) THEN 65 -ELSE compress_ops END as compress_ops, -CASE WHEN compress_ops_ok=47 and @@innodb_compression_level IN (4,8,9) THEN 65 -ELSE compress_ops_ok END as compress_ops_ok, +compress_ops, +compress_ops_ok, uncompress_ops FROM information_schema.innodb_cmp_per_index ORDER BY 1, 2, 3; database_name test table_name t index_name b -compress_ops 43 -compress_ops_ok 43 +compress_ops 52 +compress_ops_ok 52 uncompress_ops 0 database_name test table_name t index_name PRIMARY -compress_ops 65 -compress_ops_ok 65 +compress_ops 64 +compress_ops_ok 64 uncompress_ops 0 DROP TABLE t; SET GLOBAL innodb_cmp_per_index_enabled=@save_enabled; diff --git a/mysql-test/suite/innodb_zip/t/cmp_per_index.opt b/mysql-test/suite/innodb_zip/t/cmp_per_index.opt index a031a64fc6c..37aab727b87 100644 --- a/mysql-test/suite/innodb_zip/t/cmp_per_index.opt +++ b/mysql-test/suite/innodb_zip/t/cmp_per_index.opt @@ -1,2 +1 @@ ---innodb_log_compressed_pages=on --innodb_cmp_per_index_reset diff --git a/mysql-test/suite/innodb_zip/t/cmp_per_index.test b/mysql-test/suite/innodb_zip/t/cmp_per_index.test index 74ed17b1213..02c07305b88 100644 --- a/mysql-test/suite/innodb_zip/t/cmp_per_index.test +++ b/mysql-test/suite/innodb_zip/t/cmp_per_index.test @@ -4,16 +4,6 @@ -- source include/have_innodb.inc -# Using innodb_log_compressed=0 leads to a larger number of page -# compressions, because page_cur_insert_rec_zip() will reorganize the -# page before attempting an insert followed by page compression and -# page_zip_compress_write_log_no_data(). - -if (`SELECT @@innodb_log_compressed_pages = 0`) -{ - --skip Needs innodb_log_compressed_pages -} - # numbers read in this test depend on the page size -- source include/have_innodb_16k.inc # include/restart_mysqld.inc does not work in embedded mode @@ -86,10 +76,8 @@ SELECT database_name, table_name, index_name, -CASE WHEN compress_ops=47 and @@innodb_compression_level IN (4,8,9) THEN 65 -ELSE compress_ops END as compress_ops, -CASE WHEN compress_ops_ok=47 and @@innodb_compression_level IN (4,8,9) THEN 65 -ELSE compress_ops_ok END as compress_ops_ok, +compress_ops, +compress_ops_ok, uncompress_ops FROM information_schema.innodb_cmp_per_index ORDER BY 1, 2, 3; diff --git a/mysql-test/suite/sys_vars/r/innodb_log_compressed_pages_basic.result b/mysql-test/suite/sys_vars/r/innodb_log_compressed_pages_basic.result index 8cb8d900b59..62c7bf73176 100644 --- a/mysql-test/suite/sys_vars/r/innodb_log_compressed_pages_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_log_compressed_pages_basic.result @@ -9,18 +9,26 @@ COUNT(@@GLOBAL.innodb_log_compressed_pages) 1 Expected '#---------------------BS_STVARS_028_02----------------------#' SET @@global.innodb_log_compressed_pages = 0; +Warnings: +Warning 138 The parameter innodb_log_compressed_pages is deprecated and has no effect. SELECT @@global.innodb_log_compressed_pages; @@global.innodb_log_compressed_pages -0 +1 SET @@global.innodb_log_compressed_pages ='On' ; +Warnings: +Warning 138 The parameter innodb_log_compressed_pages is deprecated and has no effect. SELECT @@global.innodb_log_compressed_pages; @@global.innodb_log_compressed_pages 1 SET @@global.innodb_log_compressed_pages ='Off' ; +Warnings: +Warning 138 The parameter innodb_log_compressed_pages is deprecated and has no effect. SELECT @@global.innodb_log_compressed_pages; @@global.innodb_log_compressed_pages -0 +1 SET @@global.innodb_log_compressed_pages = 1; +Warnings: +Warning 138 The parameter innodb_log_compressed_pages is deprecated and has no effect. SELECT @@global.innodb_log_compressed_pages; @@global.innodb_log_compressed_pages 1 @@ -64,6 +72,8 @@ COUNT(@@GLOBAL.innodb_log_compressed_pages) SELECT innodb_log_compressed_pages = @@SESSION.innodb_log_compressed_pages; ERROR 42S22: Unknown column 'innodb_log_compressed_pages' in 'field list' SET @@global.innodb_log_compressed_pages = @start_global_value; +Warnings: +Warning 138 The parameter innodb_log_compressed_pages is deprecated and has no effect. SELECT @@global.innodb_log_compressed_pages; @@global.innodb_log_compressed_pages 1 diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 4afe97d80f3..d1b1fccc1b8 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1214,7 +1214,7 @@ SESSION_VALUE NULL DEFAULT_VALUE ON VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Enables/disables the logging of entire compressed page images. InnoDB logs the compressed pages to prevent corruption if the zlib compression algorithm changes. When turned OFF, InnoDB will assume that the zlib compression algorithm doesn't change. +VARIABLE_COMMENT Deprecated parameter with no effect. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 3414e05ffb8..bc84ba0d670 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1400,7 +1400,6 @@ btr_page_reorganize_low( ulint max_ins_size2; bool success = false; ulint pos; - bool log_compressed; bool is_spatial; ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); @@ -1477,14 +1476,6 @@ btr_page_reorganize_low( ? page_is_leaf(temp_block->frame) : block->page.id.page_no() == index->page)); - /* If innodb_log_compressed_pages is ON, page reorganize should log the - compressed page image.*/ - log_compressed = page_zip && page_zip_log_pages; - - if (log_compressed) { - mtr_set_log_mode(mtr, log_mode); - } - if (page_zip && !page_zip_compress(block, index, z_level, mtr)) { @@ -1585,7 +1576,6 @@ func_exit: if (success) { mlog_id_t type; - byte* log_ptr; /* Write the log record */ if (page_zip) { @@ -1597,16 +1587,10 @@ func_exit: type = MLOG_PAGE_REORGANIZE; } - log_ptr = log_compressed - ? NULL - : mlog_open_and_write_index( - mtr, page, index, type, - page_zip ? 1 : 0); - - /* For compressed pages write the compression level. */ - if (log_ptr && page_zip) { - mach_write_to_1(log_ptr, z_level); - mlog_close(mtr, log_ptr + 1); + if (byte* log_ptr = mlog_open_and_write_index( + mtr, page, index, type, page_zip ? 1 : 0)) { + *log_ptr++ = z_level; + mlog_close(mtr, log_ptr); } MONITOR_INC(MONITOR_INDEX_REORG_SUCCESSFUL); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index dc12aef7ff8..0a078cce7df 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3423,6 +3423,11 @@ static my_bool innodb_log_checksums; static const char* innodb_log_checksums_deprecated = "The parameter innodb_log_checksums is deprecated and has no effect."; /** Deprecated parameter with no effect */ +static my_bool innodb_log_compressed_pages; +/** Deprecation message for innodb_log_compressed_pages */ +static const char* innodb_log_compressed_pages_deprecated += "The parameter innodb_log_compressed_pages is deprecated and has no effect."; +/** Deprecated parameter with no effect */ static my_bool innodb_log_optimize_ddl; static const char* innodb_log_optimize_ddl_deprecated = "The parameter innodb_log_optimize_ddl is deprecated and has no effect."; @@ -3742,6 +3747,11 @@ static int innodb_init_params() innodb_log_checksums = TRUE; } + if (UNIV_UNLIKELY(!innodb_log_compressed_pages)) { + sql_print_warning(innodb_log_compressed_pages_deprecated); + innodb_log_compressed_pages = TRUE; + } + if (UNIV_UNLIKELY(innodb_log_optimize_ddl)) { sql_print_warning(innodb_log_optimize_ddl_deprecated); innodb_log_optimize_ddl = FALSE; @@ -18853,6 +18863,17 @@ innodb_log_checksums_warn(THD* thd, st_mysql_sys_var*, void*, const void*) innodb_log_checksums_deprecated); } +/** Issue a deprecation warning for SET GLOBAL innodb_log_compressed_pages. +@param[in,out] thd client connection */ +static void +innodb_log_compressed_pages_warn(THD* thd, st_mysql_sys_var*, void*, + const void*) +{ + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + HA_ERR_UNSUPPORTED, + innodb_log_compressed_pages_deprecated); +} + /** Issue a deprecation warning for SET GLOBAL innodb_log_optimize_ddl. @param[in,out] thd client connection */ static void @@ -19372,14 +19393,9 @@ static MYSQL_SYSVAR_UINT(compression_level, page_zip_level, ", 1 is fastest, 9 is best compression and default is 6.", NULL, NULL, DEFAULT_COMPRESSION_LEVEL, 0, 9, 0); -static MYSQL_SYSVAR_BOOL(log_compressed_pages, page_zip_log_pages, - PLUGIN_VAR_OPCMDARG, - "Enables/disables the logging of entire compressed page images." - " InnoDB logs the compressed pages to prevent corruption if" - " the zlib compression algorithm changes." - " When turned OFF, InnoDB will assume that the zlib" - " compression algorithm doesn't change.", - NULL, NULL, TRUE); +static MYSQL_SYSVAR_BOOL(log_compressed_pages, innodb_log_compressed_pages, + PLUGIN_VAR_OPCMDARG, + innodb_deprecated_ignored, NULL, innodb_log_compressed_pages_warn, TRUE); static MYSQL_SYSVAR_BOOL(log_optimize_ddl, innodb_log_optimize_ddl, PLUGIN_VAR_OPCMDARG, diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index a8e44899ea8..64e6f8d2158 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -59,10 +59,6 @@ extern uint page_zip_level; /** 'deleted' flag */ #define PAGE_ZIP_DIR_SLOT_DEL 0x8000U -/* Whether or not to log compressed page images to avoid possible -compression algorithm changes in zlib. */ -extern my_bool page_zip_log_pages; - /**********************************************************************//** Determine the size of a compressed page in bytes. @return size in bytes */ @@ -475,18 +471,6 @@ innodb_checksum_algorithm */ bool page_zip_verify_checksum(const void* data, ulint size); #ifndef UNIV_INNOCHECKSUM -/**********************************************************************//** -Write a log record of compressing an index page without the data on the page. */ -UNIV_INLINE -void -page_zip_compress_write_log_no_data( -/*================================*/ - ulint level, /*!< in: compression level */ - buf_block_t* block, /*!< in: ROW_FORMAT=COMPRESSED index page */ - dict_index_t* index, /*!< in: index */ - mtr_t* mtr) /*!< in: mtr */ - MY_ATTRIBUTE((nonnull)); - /**********************************************************************//** Reset the counters used for filling INFORMATION_SCHEMA.innodb_cmp_per_index. */ diff --git a/storage/innobase/include/page0zip.ic b/storage/innobase/include/page0zip.ic index c7e6737c0d8..edc67b8f42c 100644 --- a/storage/innobase/include/page0zip.ic +++ b/storage/innobase/include/page0zip.ic @@ -362,27 +362,6 @@ page_zip_write_header( } } -/**********************************************************************//** -Write a log record of compressing an index page without the data on the page. */ -UNIV_INLINE -void -page_zip_compress_write_log_no_data( -/*================================*/ - ulint level, /*!< in: compression level */ - buf_block_t* block, /*!< in: ROW_FORMAT=COMPRESSED index page */ - dict_index_t* index, /*!< in: index */ - mtr_t* mtr) /*!< in: mtr */ -{ - if (byte* log_ptr = mlog_open(mtr, 11 + 1)) { - log_ptr = mlog_write_initial_log_record_low( - MLOG_ZIP_PAGE_COMPRESS_NO_DATA, - block->page.id.space(), block->page.id.page_no(), - log_ptr, mtr); - mach_write_to_1(log_ptr, level); - mlog_close(mtr, log_ptr + 1); - } -} - /**********************************************************************//** Reset the counters used for filling INFORMATION_SCHEMA.innodb_cmp_per_index. */ diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 846cfa3134b..d864294a722 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1629,7 +1629,6 @@ page_cur_insert_rec_zip( rec_size, 1) || reorg_before_insert) { /* The values can change dynamically. */ - bool log_compressed = page_zip_log_pages; ulint level = page_zip_level; #ifdef UNIV_DEBUG rec_t* cursor_rec = page_cur_get_rec(cursor); @@ -1664,9 +1663,6 @@ page_cur_insert_rec_zip( } else if (!page_zip->m_nonempty && !page_has_garbage(page)) { /* The page has been freshly compressed, so reorganizing it will not help. */ - } else if (log_compressed && !reorg_before_insert) { - /* Insert into uncompressed page only, and - try page_zip_reorganize() afterwards. */ } else if (btr_page_reorganize_low( recv_recovery_is_on(), level, cursor, index, mtr)) { @@ -1724,82 +1720,34 @@ page_cur_insert_rec_zip( ulint pos = page_rec_get_n_recs_before(insert_rec); ut_ad(pos > 0); - if (!log_compressed) { - const mtr_log_t log_mode = mtr->set_log_mode( - MTR_LOG_NONE); - const bool ok = page_zip_compress( - page_cur_get_block(cursor), - index, level, mtr); - mtr->set_log_mode(log_mode); - if (ok) { - page_cur_insert_rec_write_log( - insert_rec, rec_size, - cursor->rec, index, mtr); - page_zip_compress_write_log_no_data( - level, - page_cur_get_block(cursor), - index, mtr); - - rec_offs_make_valid( - insert_rec, index, - page_is_leaf(page), offsets); - return(insert_rec); + /* We are writing entire page images to the + log. Reduce the redo log volume by + reorganizing the page at the same time. */ + if (page_zip_reorganize(cursor->block, index, mtr)) { + /* The page was reorganized: Seek to pos. */ + if (pos > 1) { + cursor->rec = page_rec_get_nth( + page, pos - 1); + } else { + cursor->rec = page + PAGE_NEW_INFIMUM; } - /* Page compress failed. If this happened on a - leaf page, put the data size into the sample - buffer. */ - if (page_is_leaf(page)) { - ulint occupied = page_get_data_size(page) - + page_dir_calc_reserved_space( - page_get_n_recs(page)); - index->stat_defrag_data_size_sample[ - index->stat_defrag_sample_next_slot] = - occupied; - index->stat_defrag_sample_next_slot = - (index->stat_defrag_sample_next_slot - + 1) % STAT_DEFRAG_DATA_SIZE_N_SAMPLE; - } - - ut_ad(cursor->rec - == (pos > 1 - ? page_rec_get_nth( - page, pos - 1) - : page + PAGE_NEW_INFIMUM)); - } else { - /* We are writing entire page images - to the log. Reduce the redo log volume - by reorganizing the page at the same time. */ - if (page_zip_reorganize( - cursor->block, index, mtr)) { - /* The page was reorganized: - Seek to pos. */ - if (pos > 1) { - cursor->rec = page_rec_get_nth( - page, pos - 1); - } else { - cursor->rec = page - + PAGE_NEW_INFIMUM; - } - - insert_rec = page + rec_get_next_offs( - cursor->rec, TRUE); - rec_offs_make_valid( - insert_rec, index, - page_is_leaf(page), offsets); - return(insert_rec); - } - - /* Theoretically, we could try one - last resort of btr_page_reorganize_low() - followed by page_zip_available(), but - that would be very unlikely to - succeed. (If the full reorganized page - failed to compress, why would it - succeed to compress the page, plus log - the insert of this record? */ + insert_rec = page + rec_get_next_offs( + cursor->rec, TRUE); + rec_offs_make_valid( + insert_rec, index, + page_is_leaf(page), offsets); + return(insert_rec); } + /* Theoretically, we could try one last resort + of btr_page_reorganize_low() followed by + page_zip_available(), but that would be very + unlikely to succeed. (If the full reorganized + page failed to compress, why would it succeed + to compress the page, plus log the insert of + this record?) */ + /* Out of space: restore the page */ if (!page_zip_decompress(page_zip, page, FALSE)) { ut_error; /* Memory corrupted? */ diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 4bb722bd1b0..de7cbc5f12d 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -62,10 +62,6 @@ page_zip_stat_per_index_t page_zip_stat_per_index; /** Compression level to be used by zlib. Settable by user. */ uint page_zip_level; -/** Whether or not to log compressed page images to avoid possible -compression algorithm changes in zlib. */ -my_bool page_zip_log_pages; - /* Please refer to ../include/page0zip.ic for a description of the compressed page format. */