From 716c748f97d8f7cb7caaf39dd7b9cdaf79b2229a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 23 Sep 2019 18:28:55 +1000 Subject: MDEV-20684: innodb/query cache use madvise CORE/NOCORE on FreeBSD This applies to large allocations. This maps to the way Linux does it in MDEV-10814 except FreeBSD uses different constants. Adjust error string to match to implementation. Tested on FreeBSD-12.0 --- storage/innobase/include/ut0new.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage') diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index 6732a12ecf1..46867a60023 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -252,7 +252,7 @@ static inline void ut_allocate_trace_dontdump(void *ptr, size_t bytes, #if defined(DBUG_OFF) && defined(HAVE_MADVISE) && defined(MADV_DONTDUMP) if (dontdump && madvise(ptr, bytes, MADV_DONTDUMP)) { - ib::warn() << "Failed to set memory to DONTDUMP: " + ib::warn() << "Failed to set memory to " DONTDUMP_STR ": " << strerror(errno) << " ptr " << ptr << " size " << bytes; @@ -270,7 +270,7 @@ static inline void ut_allocate_trace_dontdump(void *ptr, size_t bytes, static inline void ut_dodump(void* ptr, size_t m_size) { if (ptr && madvise(ptr, m_size, MADV_DODUMP)) { - ib::warn() << "Failed to set memory to DODUMP: " + ib::warn() << "Failed to set memory to " DODUMP_STR ": " << strerror(errno) << " ptr " << ptr << " size " << m_size; -- cgit v1.2.1 From 5b2fa078e8aee75a180461963bd54ce885445c17 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 2 Oct 2019 20:17:00 +0400 Subject: Cleanup mman.h includes As it is included from my_global.h already. --- storage/innobase/include/univ.i | 1 - storage/innobase/include/ut0new.h | 3 --- storage/maria/ma_check.c | 3 --- storage/maria/ma_extra.c | 3 --- storage/maria/ma_packrec.c | 3 --- storage/maria/maria_chk.c | 3 --- storage/myisam/mi_check.c | 3 --- storage/myisam/mi_extra.c | 3 --- storage/myisam/mi_packrec.c | 3 --- storage/myisam/myisamchk.c | 3 --- 10 files changed, 28 deletions(-) (limited to 'storage') diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index b1271ec85d1..19a03009ad5 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -92,7 +92,6 @@ support cross-platform development and expose comonly used SQL names. */ #include #ifndef _WIN32 -# include /* mmap() for os0proc.cc */ # include # include "my_config.h" #endif diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index 46867a60023..a190b872549 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -129,9 +129,6 @@ InnoDB: #include /* strlen(), strrchr(), strncmp() */ #include "my_global.h" /* needed for headers from mysql/psi/ */ -#if !defined(DBUG_OFF) && defined(HAVE_MADVISE) -#include -#endif /* JAN: TODO: missing 5.7 header */ #ifdef HAVE_MYSQL_MEMORY_H diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index bfed6698428..eadac5b04eb 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -52,9 +52,6 @@ #ifdef HAVE_SYS_VADVISE_H #include #endif -#ifdef HAVE_SYS_MMAN_H -#include -#endif /* Functions defined in this file */ diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 2697c72f2b8..c2ac4d588a9 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -14,9 +14,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ #include "maria_def.h" -#ifdef HAVE_SYS_MMAN_H -#include -#endif #include "ma_blockrec.h" static void maria_extra_keyflag(MARIA_HA *info, diff --git a/storage/maria/ma_packrec.c b/storage/maria/ma_packrec.c index e2c1e353616..2e7add8f61d 100644 --- a/storage/maria/ma_packrec.c +++ b/storage/maria/ma_packrec.c @@ -1528,9 +1528,6 @@ static uint max_bit(register uint value) /***************************************************************************** Some redefined functions to handle files when we are using memmap *****************************************************************************/ -#ifdef HAVE_SYS_MMAN_H -#include -#endif #ifdef HAVE_MMAP diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index 6ea40e65b29..85cdaa06701 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -23,9 +23,6 @@ #include #include #include -#ifdef HAVE_SYS_MMAN_H -#include -#endif static uint decode_bits; static char **default_argv; diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 76accc0978e..eac50c4a04c 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -46,9 +46,6 @@ #ifdef HAVE_SYS_VADVISE_H #include #endif -#ifdef HAVE_SYS_MMAN_H -#include -#endif #include "rt_index.h" #include diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 27e08f093ff..07592ced5db 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -15,9 +15,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ #include "myisamdef.h" -#ifdef HAVE_SYS_MMAN_H -#include -#endif static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function); diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index 72ce17b6a78..b28eaf21090 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -1479,9 +1479,6 @@ static uint max_bit(register uint value) /***************************************************************************** Some redefined functions to handle files when we are using memmap *****************************************************************************/ -#ifdef HAVE_SYS_MMAN_H -#include -#endif #ifdef HAVE_MMAP diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index a3021ed72a7..f616a9f9b1a 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -21,9 +21,6 @@ #include #include #include -#ifdef HAVE_SYS_MMAN_H -#include -#endif static uint decode_bits; static char **default_argv; -- cgit v1.2.1 From 5e65c67cfcc79c48c22798babee7555b04f40d18 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 3 Oct 2019 17:45:36 +0300 Subject: fix clang warning --- storage/connect/inihandl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'storage') diff --git a/storage/connect/inihandl.cpp b/storage/connect/inihandl.cpp index 8e79aeac7ef..dacab3c485c 100644 --- a/storage/connect/inihandl.cpp +++ b/storage/connect/inihandl.cpp @@ -194,7 +194,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section ) } for (key = section->key; key; key = key->next) - if (key->name && key->name[0]) { + if (key->name[0]) { fprintf(file, "%s", SVP(key->name)); if (key->value) -- cgit v1.2.1 From db9a4d928dc8e81ce449b54ef0bf02c248d931d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 7 Oct 2019 17:18:10 +0300 Subject: Remove orphan declaration buf_flush_wait_batch_end_wait_only() The function was declared but not defined in commit 9d6d1902e091c868bb288e0ccf9f975ccb474db9 --- storage/innobase/include/buf0flu.h | 11 ----------- storage/xtradb/include/buf0flu.h | 11 ----------- 2 files changed, 22 deletions(-) (limited to 'storage') diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index b5cfcb125e6..4cc26be3918 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -141,17 +141,6 @@ buf_flush_wait_batch_end( buf_pool_t* buf_pool, /*!< in: buffer pool instance */ enum buf_flush type); /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ -/******************************************************************//** -Waits until a flush batch of the given type ends. This is called by -a thread that only wants to wait for a flush to end but doesn't do -any flushing itself. */ -UNIV_INTERN -void -buf_flush_wait_batch_end_wait_only( -/*===============================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ - enum buf_flush type); /*!< in: BUF_FLUSH_LRU - or BUF_FLUSH_LIST */ /********************************************************************//** This function should be called at a mini-transaction commit, if a page was modified in it. Puts the block to the list of modified blocks, if it not diff --git a/storage/xtradb/include/buf0flu.h b/storage/xtradb/include/buf0flu.h index ed01b627bf4..83d4dae7f1c 100644 --- a/storage/xtradb/include/buf0flu.h +++ b/storage/xtradb/include/buf0flu.h @@ -143,17 +143,6 @@ buf_flush_wait_batch_end( buf_pool_t* buf_pool, /*!< in: buffer pool instance */ enum buf_flush type); /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ -/******************************************************************//** -Waits until a flush batch of the given type ends. This is called by -a thread that only wants to wait for a flush to end but doesn't do -any flushing itself. */ -UNIV_INTERN -void -buf_flush_wait_batch_end_wait_only( -/*===============================*/ - buf_pool_t* buf_pool, /*!< in: buffer pool instance */ - enum buf_flush type); /*!< in: BUF_FLUSH_LRU - or BUF_FLUSH_LIST */ /********************************************************************//** This function should be called at a mini-transaction commit, if a page was modified in it. Puts the block to the list of modified blocks, if it not -- cgit v1.2.1 From d480d28f4f389d34248e3889cc059238a803008e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 8 Oct 2019 18:18:48 +0300 Subject: Add page_has_prev(), page_has_next(), page_has_siblings() Until now, InnoDB inefficiently compared the aligned fields FIL_PAGE_PREV, FIL_PAGE_NEXT to the byte-order-agnostic value FIL_NULL. This is a backport of 32170f8c6d55c497ae7a791997e17ff7c992b86f from MariaDB Server 10.3. --- storage/innobase/btr/btr0btr.cc | 12 +++++------- storage/innobase/btr/btr0cur.cc | 28 +++++++++++----------------- storage/innobase/btr/btr0defragment.cc | 2 +- storage/innobase/dict/dict0stats.cc | 4 ++-- storage/innobase/gis/gis0rtree.cc | 2 +- storage/innobase/gis/gis0sea.cc | 2 +- storage/innobase/ibuf/ibuf0ibuf.cc | 3 +-- storage/innobase/include/btr0cur.ic | 15 ++++++--------- storage/innobase/include/btr0pcur.ic | 16 ++++------------ storage/innobase/include/page0page.h | 18 ++++++++++++++++++ storage/innobase/page/page0cur.cc | 2 +- storage/innobase/page/page0page.cc | 3 +-- storage/innobase/page/page0zip.cc | 11 ++++------- 13 files changed, 56 insertions(+), 62 deletions(-) (limited to 'storage') diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index f2b7b0d3f73..1bd49fa048e 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1987,7 +1987,7 @@ btr_root_raise_and_insert( they should already have been set. The previous node field must be FIL_NULL if root_page_zip != NULL, because the REC_INFO_MIN_REC_FLAG (of the first user record) will be - set if and only if btr_page_get_prev() == FIL_NULL. */ + set if and only if !page_has_prev(). */ btr_page_set_next(root, root_page_zip, FIL_NULL, mtr); btr_page_set_prev(root, root_page_zip, FIL_NULL, mtr); @@ -3361,8 +3361,7 @@ btr_lift_page_up( bool lift_father_up; buf_block_t* block_orig = block; - ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL); - ut_ad(btr_page_get_next(page, mtr) == FIL_NULL); + ut_ad(!page_has_siblings(page)); ut_ad(mtr_is_block_fix(mtr, block, MTR_MEMO_PAGE_X_FIX, index->table)); page_level = btr_page_get_level(page, mtr); @@ -3429,8 +3428,7 @@ btr_lift_page_up( page = buf_block_get_frame(block); page_level = btr_page_get_level(page, mtr); - ut_ad(btr_page_get_prev(page, mtr) == FIL_NULL); - ut_ad(btr_page_get_next(page, mtr) == FIL_NULL); + ut_ad(!page_has_siblings(page)); ut_ad(mtr_is_block_fix( mtr, block, MTR_MEMO_PAGE_X_FIX, index->table)); @@ -5077,13 +5075,13 @@ loop: if (left_page_no == FIL_NULL) { ut_a(node_ptr == page_rec_get_next( page_get_infimum_rec(father_page))); - ut_a(btr_page_get_prev(father_page, &mtr) == FIL_NULL); + ut_a(!page_has_prev(father_page)); } if (right_page_no == FIL_NULL) { ut_a(node_ptr == page_rec_get_prev( page_get_supremum_rec(father_page))); - ut_a(btr_page_get_next(father_page, &mtr) == FIL_NULL); + ut_a(!page_has_next(father_page)); } else { const rec_t* right_node_ptr; diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index b23cacac227..d0d453ed828 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -595,10 +595,10 @@ btr_cur_will_modify_tree( /* is first, 2nd or last record */ if (page_rec_is_first(rec, page) - || (mach_read_from_4(page + FIL_PAGE_NEXT) != FIL_NULL + || (page_has_next(page) && (page_rec_is_last(rec, page) || page_rec_is_second_last(rec, page))) - || (mach_read_from_4(page + FIL_PAGE_PREV) != FIL_NULL + || (page_has_prev(page) && page_rec_is_second(rec, page))) { return(true); } @@ -680,13 +680,10 @@ btr_cur_need_opposite_intention( { switch (lock_intention) { case BTR_INTENTION_DELETE: - return((mach_read_from_4(page + FIL_PAGE_PREV) != FIL_NULL - && page_rec_is_first(rec, page)) - || (mach_read_from_4(page + FIL_PAGE_NEXT) != FIL_NULL - && page_rec_is_last(rec, page))); + return (page_has_prev(page) && page_rec_is_first(rec, page)) || + (page_has_next(page) && page_rec_is_last(rec, page)); case BTR_INTENTION_INSERT: - return(mach_read_from_4(page + FIL_PAGE_NEXT) != FIL_NULL - && page_rec_is_last(rec, page)); + return page_has_next(page) && page_rec_is_last(rec, page); case BTR_INTENTION_BOTH: return(false); } @@ -1898,7 +1895,7 @@ need_opposite_intention: MTR_MEMO_PAGE_S_FIX | MTR_MEMO_PAGE_X_FIX)); - if (btr_page_get_prev(page, mtr) != FIL_NULL + if (page_has_prev(page) && page_rec_is_first(node_ptr, page)) { if (leftmost_from_level == 0) { @@ -2015,7 +2012,7 @@ need_opposite_intention: } else if (!dict_index_is_spatial(index) && latch_mode == BTR_MODIFY_TREE && lock_intention == BTR_INTENTION_INSERT - && mach_read_from_4(page + FIL_PAGE_NEXT) != FIL_NULL + && page_has_next(page) && page_rec_is_last(page_cur_get_rec(page_cursor), page)) { /* btr_insert_into_right_sibling() might cause @@ -5302,7 +5299,7 @@ btr_cur_pessimistic_delete( } else if (UNIV_UNLIKELY(page_rec_is_first(rec, page))) { rec_t* next_rec = page_rec_get_next(rec); - if (btr_page_get_prev(page, mtr) == FIL_NULL) { + if (!page_has_prev(page)) { /* If we delete the leftmost node pointer on a non-leaf level, we must mark the new leftmost node @@ -6325,7 +6322,8 @@ btr_estimate_number_of_different_key_vals( } } - if (n_cols == dict_index_get_n_unique_in_tree(index)) { + if (n_cols == dict_index_get_n_unique_in_tree(index) + && page_has_siblings(page)) { /* If there is more than one leaf page in the tree, we add one because we know that the first record @@ -6336,11 +6334,7 @@ btr_estimate_number_of_different_key_vals( algorithm grossly underestimated the number of rows in the table. */ - if (btr_page_get_prev(page, &mtr) != FIL_NULL - || btr_page_get_next(page, &mtr) != FIL_NULL) { - - n_diff[n_cols - 1]++; - } + n_diff[n_cols - 1]++; } mtr_commit(&mtr); diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index 6995c6f0998..bcabfd3a3bf 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -602,7 +602,7 @@ btr_defragment_n_pages( } if (n_pages == 1) { - if (btr_page_get_prev(first_page, mtr) == FIL_NULL) { + if (!page_has_prev(first_page)) { /* last page in the index */ if (dict_index_get_page(index) == page_get_page_no(first_page)) diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 4db4687e600..f49fb87e4ea 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -1076,7 +1076,7 @@ dict_stats_analyze_index_level( ut_a(btr_page_get_level(page, mtr) == level); /* there should not be any pages on the left */ - ut_a(btr_page_get_prev(page, mtr) == FIL_NULL); + ut_a(!page_has_prev(page)); /* check whether the first record on the leftmost page is marked as such, if we are on a non-leaf level */ @@ -1689,7 +1689,7 @@ dict_stats_analyze_index_for_n_prefix( ut_a(btr_page_get_level(page, mtr) == n_diff_data->level); /* there should not be any pages on the left */ - ut_a(btr_page_get_prev(page, mtr) == FIL_NULL); + ut_a(!page_has_prev(page)); /* check whether the first record on the leftmost page is marked as such; we are on a non-leaf level */ diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index 2965a19a5e0..dc9e34903c2 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -1063,7 +1063,7 @@ func_start: page_no = block->page.id.page_no(); - if (btr_page_get_prev(page, mtr) == FIL_NULL && !page_is_leaf(page)) { + if (!page_has_prev(page) && !page_is_leaf(page)) { first_rec = page_rec_get_next( page_get_infimum_rec(buf_block_get_frame(block))); } diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index f1e4b82fd36..0a0a542689a 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -1713,7 +1713,7 @@ rtr_cur_search_with_match( first page as much as possible, as there will be problem when update MIN_REC rec in compress table */ if (buf_block_get_page_zip(block) - && mach_read_from_4(page + FIL_PAGE_PREV) == FIL_NULL + && !page_has_prev(page) && page_get_n_recs(page) >= 2) { rec = page_rec_get_next_const(rec); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 5581d1d1093..34cba10c6b5 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -3254,8 +3254,7 @@ ibuf_get_entry_counter_func( return(ULINT_UNDEFINED); } else if (!page_rec_is_infimum(rec)) { return(ibuf_get_entry_counter_low(mtr, rec, space, page_no)); - } else if (only_leaf - || fil_page_get_prev(page_align(rec)) == FIL_NULL) { + } else if (only_leaf || !page_has_prev(page_align(rec))) { /* The parent node pointer did not contain the searched for (space, page_no), which means that the search ended on the correct page regardless of the diff --git a/storage/innobase/include/btr0cur.ic b/storage/innobase/include/btr0cur.ic index 1decfa09e5b..7cf6c5982fa 100644 --- a/storage/innobase/include/btr0cur.ic +++ b/storage/innobase/include/btr0cur.ic @@ -138,10 +138,9 @@ btr_cur_compress_recommendation( LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page) * 2U, return(FALSE)); - if ((page_get_data_size(page) - < BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index)) - || ((btr_page_get_next(page, mtr) == FIL_NULL) - && (btr_page_get_prev(page, mtr) == FIL_NULL))) { + if (page_get_data_size(page) + < BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index) + || !page_has_siblings(page)) { /* The page fillfactor has dropped below a predefined minimum value OR the level in the B-tree contains just @@ -174,11 +173,9 @@ btr_cur_can_delete_without_compress( page = btr_cur_get_page(cursor); - if ((page_get_data_size(page) - rec_size - < BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index)) - || ((btr_page_get_next(page, mtr) == FIL_NULL) - && (btr_page_get_prev(page, mtr) == FIL_NULL)) - || (page_get_n_recs(page) < 2)) { + if (page_get_data_size(page) - rec_size + < BTR_CUR_PAGE_COMPRESS_LIMIT(cursor->index) + || !page_has_siblings(page) || page_get_n_recs(page) < 2) { /* The page fillfactor will drop below a predefined minimum value, OR the level in the B-tree contains just diff --git a/storage/innobase/include/btr0pcur.ic b/storage/innobase/include/btr0pcur.ic index 51ebcfbb2ee..8b0da666250 100644 --- a/storage/innobase/include/btr0pcur.ic +++ b/storage/innobase/include/btr0pcur.ic @@ -219,12 +219,8 @@ btr_pcur_is_before_first_in_tree( ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->latch_mode != BTR_NO_LATCHES); - if (btr_page_get_prev(btr_pcur_get_page(cursor), mtr) != FIL_NULL) { - - return(FALSE); - } - - return(page_cur_is_before_first(btr_pcur_get_page_cur(cursor))); + return !page_has_prev(btr_pcur_get_page(cursor)) + && page_cur_is_before_first(btr_pcur_get_page_cur(cursor)); } /*********************************************************//** @@ -240,12 +236,8 @@ btr_pcur_is_after_last_in_tree( ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->latch_mode != BTR_NO_LATCHES); - if (btr_page_get_next(btr_pcur_get_page(cursor), mtr) != FIL_NULL) { - - return(FALSE); - } - - return(page_cur_is_after_last(btr_pcur_get_page_cur(cursor))); + return !page_has_next(btr_pcur_get_page(cursor)) + && page_cur_is_after_last(btr_pcur_get_page_cur(cursor)); } /*********************************************************//** diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index ee261b55d16..c50e72a6542 100644 --- a/storage/innobase/include/page0page.h +++ b/storage/innobase/include/page0page.h @@ -697,6 +697,24 @@ inline bool page_has_siblings(const page_t* page) != ~uint64_t(0); } +/** Determine whether a page has a predecessor. +@param[in] page page frame +@return true if the page has a predecessor */ +inline bool page_has_prev(const page_t* page) +{ + return *reinterpret_cast(page + FIL_PAGE_PREV) + != FIL_NULL; +} + +/** Determine whether a page has a successor. +@param[in] page page frame +@return true if the page has a successor */ +inline bool page_has_next(const page_t* page) +{ + return *reinterpret_cast(page + FIL_PAGE_NEXT) + != FIL_NULL; +} + /************************************************************//** Gets the pointer to the next record on the page. @return pointer to next record */ diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 92ff3e104ba..4071db7b4d9 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -521,7 +521,7 @@ up_rec_match: ulint rec_info = rec_get_info_bits(mid_rec, rec_offs_comp(offsets)); ut_ad(rec_info & REC_INFO_MIN_REC_FLAG); - ut_ad(btr_page_get_prev(page, &mtr) == FIL_NULL); + ut_ad(!page_has_prev(page)); mtr_commit(&mtr); #endif diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index 12a0f44011d..f950af02e31 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2764,8 +2764,7 @@ page_delete_rec( if (!rec_offs_any_extern(offsets) && ((page_get_data_size(page) - rec_offs_size(offsets) < BTR_CUR_PAGE_COMPRESS_LIMIT(index)) - || (mach_read_from_4(page + FIL_PAGE_NEXT) == FIL_NULL - && mach_read_from_4(page + FIL_PAGE_PREV) == FIL_NULL) + || !page_has_siblings(page) || (page_get_n_recs(page) < 2))) { ulint root_page_no = dict_index_get_page(index); diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index e90c5f67f8e..9e3e58efa3a 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -670,8 +670,7 @@ page_zip_dir_encode( status = REC_STATUS_ORDINARY; } else { status = REC_STATUS_NODE_PTR; - if (UNIV_UNLIKELY - (mach_read_from_4(page + FIL_PAGE_PREV) == FIL_NULL)) { + if (UNIV_UNLIKELY(!page_has_prev(page))) { min_mark = REC_INFO_MIN_REC_FLAG; } } @@ -3187,8 +3186,7 @@ zlib_error: goto err_exit; } - info_bits = mach_read_from_4(page + FIL_PAGE_PREV) == FIL_NULL - ? REC_INFO_MIN_REC_FLAG : 0; + info_bits = page_has_prev(page) ? 0 : REC_INFO_MIN_REC_FLAG; if (UNIV_UNLIKELY(!page_zip_set_extra_bytes(page_zip, page, info_bits))) { @@ -4826,9 +4824,8 @@ page_zip_copy_recs( + page_zip->m_end < page_zip_get_size(page_zip)); if (!page_is_leaf(src) - && UNIV_UNLIKELY(mach_read_from_4(src + FIL_PAGE_PREV) == FIL_NULL) - && UNIV_LIKELY(mach_read_from_4(page - + FIL_PAGE_PREV) != FIL_NULL)) { + && UNIV_UNLIKELY(!page_has_prev(src)) + && UNIV_LIKELY(page_has_prev(page))) { /* Clear the REC_INFO_MIN_REC_FLAG of the first user record. */ ulint offs = rec_get_next_offs(page + PAGE_NEW_INFIMUM, TRUE); -- cgit v1.2.1 From 99dc40d6ac2234fa4c990665cc1914c1925cd641 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 30 Sep 2019 20:58:50 +0300 Subject: MDEV-19783 Random crashes and corrupt data in INSTANT-added columns The bug affects MariaDB Server 10.3 or later, but it makes sense to improve CHECK TABLE in earlier versions already. page_validate(): Check REC_INFO_MIN_REC_FLAG in the records. This allows CHECK TABLE to catch more bugs. --- storage/innobase/page/page0page.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'storage') diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index f950af02e31..bda4693648b 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2392,6 +2392,7 @@ page_validate( ulint data_size; const rec_t* rec; const rec_t* old_rec = NULL; + const rec_t* first_rec = NULL; ulint offs; ulint n_slots; ibool ret = FALSE; @@ -2488,6 +2489,21 @@ page_validate( goto func_exit; } + if (rec == first_rec) { + if ((rec_get_info_bits(rec, page_is_comp(page)) + & REC_INFO_MIN_REC_FLAG) + && page_is_leaf(page)) { + ib::error() << "REC_INFO_MIN_REC_FLAG " + "is set in a leaf-page record"; + ret = false; + } + } else if (rec_get_info_bits(rec, page_is_comp(page)) + & REC_INFO_MIN_REC_FLAG) { + ib::error() << "REC_INFO_MIN_REC_FLAG record is not " + "first in page"; + ret = false; + } + /* Check that the records are in the ascending order */ if (count >= PAGE_HEAP_NO_USER_LOW && !page_rec_is_supremum(rec)) { @@ -2599,6 +2615,11 @@ page_validate( old_rec = rec; rec = page_rec_get_next_const(rec); + if (page_rec_is_infimum(old_rec) + && page_rec_is_user_rec(rec)) { + first_rec = rec; + } + /* set old_offsets to offsets; recycle offsets */ { ulint* offs = old_offsets; -- cgit v1.2.1 From ed0793e096a17955c5a03844b248bcf8303dd335 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 2 Oct 2019 22:47:45 +0300 Subject: MDEV-19783: Add more REC_INFO_MIN_REC_FLAG checks btr_cur_pessimistic_delete(): code changed in a way that allows to put more REC_INFO_MIN_REC_FLAG assertions inside btr_set_min_rec_mark(). Without that change tests innodb.innodb-table-online, innodb.temp_table_savepoint and innodb_zip.prefix_index_liftedlimit fail. Removed basically duplicated page_zip_validate() calls which fails because of temporary(!) invariant violation. That fixed innodb_zip.wl5522_debug_zip and innodb_zip.prefix_index_liftedlimit --- storage/innobase/btr/btr0btr.cc | 21 +++++++++------------ storage/innobase/btr/btr0cur.cc | 26 ++++++++++++++++---------- storage/innobase/include/btr0btr.h | 12 ++++-------- storage/innobase/include/page0page.ic | 4 ++++ storage/innobase/page/page0cur.cc | 4 ---- storage/innobase/page/page0zip.cc | 4 ---- 6 files changed, 33 insertions(+), 38 deletions(-) (limited to 'storage') diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 1bd49fa048e..473e4248656 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -3309,25 +3309,22 @@ btr_parse_set_min_rec_mark( return(ptr + 2); } -/****************************************************************//** -Sets a record as the predefined minimum record. */ -void -btr_set_min_rec_mark( -/*=================*/ - rec_t* rec, /*!< in: record */ - mtr_t* mtr) /*!< in: mtr */ +/** Sets a record as the predefined minimum record. */ +void btr_set_min_rec_mark(rec_t* rec, mtr_t* mtr) { - ulint info_bits; + const bool comp = page_rec_is_comp(rec); - if (page_rec_is_comp(rec)) { - info_bits = rec_get_info_bits(rec, TRUE); + ut_ad(rec == page_rec_get_next_const(page_get_infimum_rec( + page_align(rec)))); + ut_ad(!(rec_get_info_bits(page_rec_get_next(rec), comp) + & REC_INFO_MIN_REC_FLAG)); + size_t info_bits = rec_get_info_bits(rec, comp); + if (comp) { rec_set_info_bits_new(rec, info_bits | REC_INFO_MIN_REC_FLAG); btr_set_min_rec_mark_log(rec, MLOG_COMP_REC_MIN_MARK, mtr); } else { - info_bits = rec_get_info_bits(rec, FALSE); - rec_set_info_bits_old(rec, info_bits | REC_INFO_MIN_REC_FLAG); btr_set_min_rec_mark_log(rec, MLOG_REC_MIN_MARK, mtr); diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index d0d453ed828..3060865bc8e 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -5277,8 +5277,15 @@ btr_cur_pessimistic_delete( #endif /* UNIV_ZIP_DEBUG */ } - if (flags == 0) { - lock_update_delete(block, rec); + rec_t* next_rec = NULL; + bool min_mark_next_rec = false; + + if (page_is_leaf(page)) { + ut_ad(!(rec_get_info_bits(rec, page_rec_is_comp(rec)) + & REC_INFO_MIN_REC_FLAG)); + if (flags == 0) { + lock_update_delete(block, rec); + } } if (UNIV_UNLIKELY(page_get_n_recs(page) < 2) @@ -5297,20 +5304,14 @@ btr_cur_pessimistic_delete( if (page_is_leaf(page)) { btr_search_update_hash_on_delete(cursor); } else if (UNIV_UNLIKELY(page_rec_is_first(rec, page))) { - rec_t* next_rec = page_rec_get_next(rec); + next_rec = page_rec_get_next(rec); if (!page_has_prev(page)) { - /* If we delete the leftmost node pointer on a non-leaf level, we must mark the new leftmost node pointer as the predefined minimum record */ - /* This will make page_zip_validate() fail until - page_cur_delete_rec() completes. This is harmless, - because everything will take place within a single - mini-transaction and because writing to the redo log - is an atomic operation (performed by mtr_commit()). */ - btr_set_min_rec_mark(next_rec, mtr); + min_mark_next_rec = true; } else if (dict_index_is_spatial(index)) { /* For rtree, if delete the leftmost node pointer, we need to update parent page. */ @@ -5379,6 +5380,11 @@ btr_cur_pessimistic_delete( block->page.size, mtr); page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, offsets, mtr); + + if (min_mark_next_rec) { + btr_set_min_rec_mark(next_rec, mtr); + } + #ifdef UNIV_ZIP_DEBUG ut_a(!page_zip || page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index e00b2545708..604890ed03c 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -508,14 +508,10 @@ btr_insert_on_non_leaf_level_func( mtr_t* mtr); /*!< in: mtr */ #define btr_insert_on_non_leaf_level(f,i,l,t,m) \ btr_insert_on_non_leaf_level_func(f,i,l,t,__FILE__,__LINE__,m) -/****************************************************************//** -Sets a record as the predefined minimum record. */ -void -btr_set_min_rec_mark( -/*=================*/ - rec_t* rec, /*!< in/out: record */ - mtr_t* mtr) /*!< in: mtr */ - MY_ATTRIBUTE((nonnull)); + +/** Sets a record as the predefined minimum record. */ +void btr_set_min_rec_mark(rec_t* rec, mtr_t* mtr) MY_ATTRIBUTE((nonnull)); + /** Seek to the parent page of a B-tree page. @param[in,out] index b-tree @param[in] block child page diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic index 05774daac50..3956ecce0ee 100644 --- a/storage/innobase/include/page0page.ic +++ b/storage/innobase/include/page0page.ic @@ -659,6 +659,10 @@ page_rec_get_next_low( return(NULL); } + ut_ad(page_rec_is_infimum(rec) + || !(rec_get_info_bits(page + offs, comp) + & REC_INFO_MIN_REC_FLAG)); + return(page + offs); } diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 4071db7b4d9..90c0dd377e1 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -2421,10 +2421,6 @@ page_cur_delete_rec( if (cur_n_owned <= PAGE_DIR_SLOT_MIN_N_OWNED) { page_dir_balance_slot(page, page_zip, cur_slot_no); } - -#ifdef UNIV_ZIP_DEBUG - ut_a(!page_zip || page_zip_validate(page_zip, page, index)); -#endif /* UNIV_ZIP_DEBUG */ } #ifdef UNIV_COMPILE_TEST_FUNCS diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 9e3e58efa3a..d6abec57821 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -4291,10 +4291,6 @@ page_zip_clear_rec( } else { ut_ad(!rec_offs_any_extern(offsets)); } - -#ifdef UNIV_ZIP_DEBUG - ut_a(page_zip_validate(page_zip, page, index)); -#endif /* UNIV_ZIP_DEBUG */ } /**********************************************************************//** -- cgit v1.2.1 From b7408be0c3a4027b505f6122306c8d88ad0e92b2 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 4 Oct 2019 16:46:41 +0200 Subject: MDEV-20753: Sequence with limit 0 crashes server Do not try to push down conditions to engine if query was resolved without tables (and so the engine). --- storage/sequence/mysql-test/sequence/group_by.result | 6 ++++++ storage/sequence/mysql-test/sequence/group_by.test | 7 +++++++ 2 files changed, 13 insertions(+) (limited to 'storage') diff --git a/storage/sequence/mysql-test/sequence/group_by.result b/storage/sequence/mysql-test/sequence/group_by.result index 2941e85c1f4..7902fe6a348 100644 --- a/storage/sequence/mysql-test/sequence/group_by.result +++ b/storage/sequence/mysql-test/sequence/group_by.result @@ -97,3 +97,9 @@ count(NULL) select count(NULL) from seq_1_to_3; count(NULL) 0 +# +# MDEV-20753: Sequence with limit 0 crashes server +# +select count(NULL) from seq_1_to_3 limit 0; +count(NULL) +# End of 10.3 tests diff --git a/storage/sequence/mysql-test/sequence/group_by.test b/storage/sequence/mysql-test/sequence/group_by.test index b3f4ab58771..18e44cd2ab1 100644 --- a/storage/sequence/mysql-test/sequence/group_by.test +++ b/storage/sequence/mysql-test/sequence/group_by.test @@ -49,3 +49,10 @@ explain select count(*) from seq_1_to_15_step_2 group by mod(seq,2); create temporary table t1 select * from seq_1_to_3; select count(NULL) from t1; select count(NULL) from seq_1_to_3; + +--echo # +--echo # MDEV-20753: Sequence with limit 0 crashes server +--echo # +select count(NULL) from seq_1_to_3 limit 0; + +--echo # End of 10.3 tests -- cgit v1.2.1 From 896b869685484beac11785f7d1099be0fe265c49 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Sat, 5 Oct 2019 09:12:56 +0200 Subject: MDEV-19238 Mariadb spider - crashes on where null (fix and explanation came with MDEV-20753 (duplicate of this bug)) --- .../bugfix/include/select_by_null_deinit.inc | 11 +++ .../spider/bugfix/include/select_by_null_init.inc | 24 ++++++ .../spider/bugfix/r/select_by_null.result | 90 ++++++++++++++++++++++ .../mysql-test/spider/bugfix/t/select_by_null.cnf | 3 + .../mysql-test/spider/bugfix/t/select_by_null.test | 72 +++++++++++++++++ 5 files changed, 200 insertions(+) create mode 100644 storage/spider/mysql-test/spider/bugfix/include/select_by_null_deinit.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc create mode 100644 storage/spider/mysql-test/spider/bugfix/r/select_by_null.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/select_by_null.cnf create mode 100644 storage/spider/mysql-test/spider/bugfix/t/select_by_null.test (limited to 'storage') diff --git a/storage/spider/mysql-test/spider/bugfix/include/select_by_null_deinit.inc b/storage/spider/mysql-test/spider/bugfix/include/select_by_null_deinit.inc new file mode 100644 index 00000000000..76b7582abfe --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/select_by_null_deinit.inc @@ -0,0 +1,11 @@ +--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP +--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP +--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP +--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_deinit.inc +--enable_result_log +--enable_query_log +--enable_warnings diff --git a/storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc b/storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc new file mode 100644 index 00000000000..d07ba2a9fee --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc @@ -0,0 +1,24 @@ +--disable_warnings +--disable_query_log +--disable_result_log +--source ../t/test_init.inc +--enable_result_log +--enable_query_log +--enable_warnings +--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 +let $MASTER_1_COMMENT_2_1= + COMMENT='table "tbl_a", srv "s_2_1"'; +--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES +let $CHILD2_1_DROP_TABLES= + DROP TABLE IF EXISTS tbl_a; +--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES +let $CHILD2_1_CREATE_TABLES= + CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) + ) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; +--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES +let $CHILD2_1_SELECT_TABLES= + SELECT pkey FROM tbl_a ORDER BY pkey; +let $CHILD2_1_SELECT_ARGUMENT1= + SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/select_by_null.result b/storage/spider/mysql-test/spider/bugfix/r/select_by_null.result new file mode 100644 index 00000000000..a7fa1b3b91f --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/select_by_null.result @@ -0,0 +1,90 @@ +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +this test is for MDEV-16279 + +drop and create databases +connection master_1; +CREATE DATABASE auto_test_local; +USE auto_test_local; +connection child2_1; +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; + +create table and insert +connection child2_1; +CHILD2_1_CREATE_TABLES +TRUNCATE TABLE mysql.general_log; +connection master_1; +CREATE TABLE tbl_a ( +pkey int NOT NULL, +PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1 +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +FLUSH TABLES; + +select test 1 +connection child2_1; +TRUNCATE TABLE mysql.general_log; +connection master_1; +SELECT pkey FROM tbl_a WHERE NULL; +pkey +connection child2_1; +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +argument +SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT pkey FROM tbl_a ORDER BY pkey; +pkey +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 + +deinit +connection master_1; +DROP DATABASE IF EXISTS auto_test_local; +connection child2_1; +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; +for master_1 +for child2 +child2_1 +child2_2 +child2_3 +for child3 + +end of test diff --git a/storage/spider/mysql-test/spider/bugfix/t/select_by_null.cnf b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.cnf new file mode 100644 index 00000000000..05dfd8a0bce --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.cnf @@ -0,0 +1,3 @@ +!include include/default_mysqld.cnf +!include ../my_1_1.cnf +!include ../my_2_1.cnf diff --git a/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test new file mode 100644 index 00000000000..1f540b2a15f --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test @@ -0,0 +1,72 @@ +--source ../include/select_by_null_init.inc +--echo +--echo this test is for MDEV-16279 +--echo +--echo drop and create databases + +--connection master_1 +--disable_warnings +CREATE DATABASE auto_test_local; +USE auto_test_local; + +--connection child2_1 +SET @old_log_output = @@global.log_output; +SET GLOBAL log_output = 'TABLE,FILE'; +CREATE DATABASE auto_test_remote; +USE auto_test_remote; +--enable_warnings + +--echo +--echo create table and insert + +--connection child2_1 +--disable_query_log +echo CHILD2_1_CREATE_TABLES; +eval $CHILD2_1_CREATE_TABLES; +--enable_query_log +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +--disable_query_log +echo CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1; +eval CREATE TABLE tbl_a ( + pkey int NOT NULL, + PRIMARY KEY (pkey) +) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1; +--enable_query_log +INSERT INTO tbl_a (pkey) VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +INSERT INTO tbl_a (pkey) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19); +INSERT INTO tbl_a (pkey) VALUES (20),(21),(22),(23),(24),(25),(26),(27),(28),(29); +FLUSH TABLES; + +--echo +--echo select test 1 + +--connection child2_1 +TRUNCATE TABLE mysql.general_log; + +--connection master_1 +SELECT pkey FROM tbl_a WHERE NULL; + +--connection child2_1 +eval $CHILD2_1_SELECT_ARGUMENT1; +eval $CHILD2_1_SELECT_TABLES; + +--echo +--echo deinit +--disable_warnings + +--connection master_1 +DROP DATABASE IF EXISTS auto_test_local; + +--connection child2_1 +DROP DATABASE IF EXISTS auto_test_remote; +SET GLOBAL log_output = @old_log_output; + +--enable_warnings +--source ../include/select_by_null_deinit.inc +--echo +--echo end of test -- cgit v1.2.1 From c65cb244b35412ef54192b17120f7ace8a8af5fd Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 3 Oct 2019 18:12:08 +0530 Subject: MDEV-19335 Remove buf_page_t::encrypted The field buf_page_t::encrypted was added in MDEV-8588. It was made mostly redundant in MDEV-12699. Remove the field. --- storage/innobase/buf/buf0buf.cc | 82 +++++++++--------------------------- storage/innobase/fil/fil0crypt.cc | 6 +-- storage/innobase/ibuf/ibuf0ibuf.cc | 4 +- storage/innobase/include/buf0buf.h | 2 - storage/innobase/include/fil0crypt.h | 4 +- 5 files changed, 24 insertions(+), 74 deletions(-) (limited to 'storage') diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index e3c6605652f..b5ca51c81dc 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -589,12 +589,6 @@ decrypt_failed: << mach_read_from_4( FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + dst_frame); - /* Mark page encrypted in case it should be. */ - if (space->crypt_data->type - != CRYPT_SCHEME_UNENCRYPTED) { - bpage->encrypted = true; - } - return false; } @@ -605,8 +599,7 @@ decrypt_failed: ut_d(fil_page_type_validate(dst_frame)); /* decrypt using crypt_buf to dst_frame */ - if (!fil_space_decrypt(space, slot->crypt_buf, - dst_frame, &bpage->encrypted)) { + if (!fil_space_decrypt(space, slot->crypt_buf, dst_frame)) { slot->release(); goto decrypt_failed; } @@ -1534,7 +1527,6 @@ buf_block_init( block->page.buf_fix_count = 0; block->page.io_fix = BUF_IO_NONE; block->page.flush_observer = NULL; - block->page.encrypted = false; block->page.real_size = 0; block->page.write_size = 0; block->modify_clock = 0; @@ -4044,7 +4036,6 @@ err_exit: if (encrypted) { ib::info() << "Row compressed page could be encrypted" " with key_version " << key_version; - block->page.encrypted = true; dict_set_encrypted_by_space(block->page.id.space()); } else { dict_set_corrupted_by_space(block->page.id.space()); @@ -5248,7 +5239,6 @@ buf_page_init_low( bpage->newest_modification = 0; bpage->oldest_modification = 0; bpage->write_size = 0; - bpage->encrypted = false; bpage->real_size = 0; bpage->slot = NULL; @@ -5841,15 +5831,16 @@ buf_page_monitor( } /** Mark a table corrupted. -@param[in] bpage Corrupted page. */ -static -void -buf_mark_space_corrupt(buf_page_t* bpage) +@param[in] bpage corrupted page +@param[in] space tablespace of the corrupted page */ +ATTRIBUTE_COLD +static void buf_mark_space_corrupt(buf_page_t* bpage, const fil_space_t& space) { /* If block is not encrypted find the table with specified space id, and mark it corrupted. Encrypted tables are marked unusable later e.g. in ::open(). */ - if (!bpage->encrypted) { + if (!space.crypt_data + || space.crypt_data->type == CRYPT_SCHEME_UNENCRYPTED) { dict_set_corrupted_by_space(bpage->id.space()); } else { dict_set_encrypted_by_space(bpage->id.space()); @@ -5891,7 +5882,7 @@ buf_corrupt_page_release(buf_page_t* bpage, const fil_space_t* space) mutex_exit(buf_page_get_mutex(bpage)); if (!srv_force_recovery) { - buf_mark_space_corrupt(bpage); + buf_mark_space_corrupt(bpage, *space); } /* After this point bpage can't be referenced. */ @@ -5921,7 +5912,6 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) byte* dst_frame = (bpage->zip.data) ? bpage->zip.data : ((buf_block_t*) bpage)->frame; dberr_t err = DB_SUCCESS; - bool corrupted = false; /* In buf_decrypt_after_read we have either decrypted the page if page post encryption checksum matches and used key_id is found @@ -5929,33 +5919,20 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) not decrypted and it could be either encrypted and corrupted or corrupted or good page. If we decrypted, there page could still be corrupted if used key does not match. */ - const bool still_encrypted = mach_read_from_4( + const bool seems_encrypted = mach_read_from_4( dst_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) && space->crypt_data - && space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED - && !bpage->encrypted - && fil_space_verify_crypt_checksum(dst_frame, bpage->size); - - if (!still_encrypted) { - /* If traditional checksums match, we assume that page is - not anymore encrypted. */ - corrupted = buf_page_is_corrupted( - true, dst_frame, bpage->size, space); - - if (!corrupted) { - bpage->encrypted = false; - } else { - err = DB_PAGE_CORRUPTED; - } + && space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED; + + /* If traditional checksums match, we assume that page is + not anymore encrypted. */ + if (buf_page_is_corrupted( + true, dst_frame, bpage->size, space)) { + err = DB_PAGE_CORRUPTED; } - /* Pages that we think are unencrypted but do not match the checksum - checks could be corrupted or encrypted or both. */ - if (corrupted && !bpage->encrypted) { - /* An error will be reported by - buf_page_io_complete(). */ - } else if (still_encrypted || (bpage->encrypted && corrupted)) { - bpage->encrypted = true; + if (seems_encrypted && err == DB_PAGE_CORRUPTED + && bpage->id.page_no() != 0) { err = DB_DECRYPTION_FAILED; ib::error() @@ -6017,7 +5994,6 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict) if (io_type == BUF_IO_READ) { ulint read_page_no = 0; ulint read_space_id = 0; - uint key_version = 0; byte* frame = bpage->zip.data ? bpage->zip.data : reinterpret_cast(bpage)->frame; @@ -6057,8 +6033,6 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict) read_page_no = mach_read_from_4(frame + FIL_PAGE_OFFSET); read_space_id = mach_read_from_4( frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); - key_version = mach_read_from_4( - frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); if (bpage->id.space() == TRX_SYS_SPACE && buf_dblwr_page_inside(bpage->id.page_no())) { @@ -6174,23 +6148,9 @@ database_corrupted: && fil_page_get_type(frame) == FIL_PAGE_INDEX && page_is_leaf(frame)) { - if (bpage->encrypted) { - ib::warn() - << "Table in tablespace " - << bpage->id.space() - << " encrypted. However key " - "management plugin or used " - << "key_version " << key_version - << " is not found or" - " used encryption algorithm or method does not match." - " Can't continue opening the table."; - } else { - - ibuf_merge_or_delete_for_page( - (buf_block_t*) bpage, bpage->id, - &bpage->size, TRUE); - } - + ibuf_merge_or_delete_for_page( + (buf_block_t*) bpage, bpage->id, + &bpage->size, TRUE); } fil_space_release_for_io(space); diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index e1817985685..918ffd77542 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -793,7 +793,6 @@ Decrypt a page. @param[in] space Tablespace @param[in] tmp_frame Temporary buffer used for decrypting @param[in,out] src_frame Page to decrypt -@param[out] decrypted true if page was decrypted @return decrypted page, or original not encrypted page if decryption is not needed.*/ UNIV_INTERN @@ -801,13 +800,11 @@ byte* fil_space_decrypt( const fil_space_t* space, byte* tmp_frame, - byte* src_frame, - bool* decrypted) + byte* src_frame) { dberr_t err = DB_SUCCESS; byte* res = NULL; const page_size_t page_size(space->flags); - *decrypted = false; ut_ad(space->crypt_data != NULL && space->crypt_data->is_encrypted()); ut_ad(space->n_pending_ios > 0); @@ -817,7 +814,6 @@ fil_space_decrypt( if (err == DB_SUCCESS) { if (encrypted) { - *decrypted = true; /* Copy the decrypted page back to page buffer, not really any other options. */ memcpy(src_frame, tmp_frame, page_size.physical()); diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 34cba10c6b5..ccc471da2aa 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -342,10 +342,8 @@ ibuf_header_page_get( page_id_t(IBUF_SPACE_ID, FSP_IBUF_HEADER_PAGE_NO), univ_page_size, RW_X_LATCH, mtr); - - if (!block->page.encrypted) { + if (block) { buf_block_dbg_add_level(block, SYNC_IBUF_HEADER); - page = buf_block_get_frame(block); } diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 6bfeeb83018..af2a7d90101 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1468,8 +1468,6 @@ public: if written again we check is TRIM operation needed. */ - bool encrypted; /*!< page is still encrypted */ - ulint real_size; /*!< Real size of the page Normal pages == UNIV_PAGE_SIZE page compressed pages, payload diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h index 24108f95167..3c56315ee9a 100644 --- a/storage/innobase/include/fil0crypt.h +++ b/storage/innobase/include/fil0crypt.h @@ -375,7 +375,6 @@ Decrypt a page @param[in] space Tablespace @param[in] tmp_frame Temporary buffer used for decrypting @param[in,out] src_frame Page to decrypt -@param[out] decrypted true if page was decrypted @return decrypted page, or original not encrypted page if decryption is not needed.*/ UNIV_INTERN @@ -383,8 +382,7 @@ byte* fil_space_decrypt( const fil_space_t* space, byte* tmp_frame, - byte* src_frame, - bool* decrypted) + byte* src_frame) MY_ATTRIBUTE((warn_unused_result)); /****************************************************************** -- cgit v1.2.1