From 2bde065525bfa1535bfc62ce1c428ad55d11839a Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 19 Mar 2020 21:52:52 -0700 Subject: [PATCH 01/18] MDEV-17177 Crash in Item_func_in::cleanup() for SELECT executed via prepared statement The method Item_func_in::build_clone() that builds a clone item for an Item_func_in item first calls a generic method Item_func::build_item() that builds the the clones for the arguments of the Item_func_in item to be cloned, creates a copy of the Item_func_in object and attaches the clones for the arguments to this copy. Then the method Item_func_in::build_clone() makes the copy fully independent on the copied object in order to guarantee a proper destruction of the clone. The fact is the copy of the Item_func_in object is registered as any other item object and should be destructed as any other item object. If the method Item_func::build_item fails to build a clone of an argument then it returns 0. In this case no copy of the Item_func_in object should be created. Otherwise the finalizing actions for this copy would not be performed and the copy would remain in a state that would prevent its proper destruction. The code of Item_func_in::build_clone() before this patch created the copy of the Item_func_in object before cloning the argument items. If this cloning failed the server crashed when trying to destruct the copy item. The code of Item_row::build_clone() was changed similarly to the code of Item_func::build_clone though this code could not cause any problems. --- mysql-test/r/derived_cond_pushdown.result | 12 ++++++++ mysql-test/t/derived_cond_pushdown.test | 16 +++++++++++ sql/item.cc | 35 ++++++++++++----------- sql/item_row.cc | 11 ++++--- 4 files changed, 54 insertions(+), 20 deletions(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index 1010ed6eccb..e2c24639cc7 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -10581,4 +10581,16 @@ a b max_c a b dayname(v1.b) DROP VIEW v1; DROP TABLE t1, t2; SET optimizer_switch=DEFAULT; +# +# MDEV-17177: an attempt to push down IN predicate when one of +# the arguments is too complex to be cloned +# +CREATE TABLE t1 (a VARCHAR(8)); +INSERT INTO t1 VALUES ('abc'),('def'); +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY a; +SELECT * FROM v1 WHERE IF( a REGEXP 'def', 'foo', a ) IN ('abc', 'foobar'); +a +abc +DROP VIEW v1; +DROP TABLE t1; # End of 10.2 tests diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index ec15791ddbd..a7df65f2951 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -2168,4 +2168,20 @@ DROP TABLE t1, t2; SET optimizer_switch=DEFAULT; + + +--echo # +--echo # MDEV-17177: an attempt to push down IN predicate when one of +--echo # the arguments is too complex to be cloned +--echo # + +CREATE TABLE t1 (a VARCHAR(8)); +INSERT INTO t1 VALUES ('abc'),('def'); +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY a; + +SELECT * FROM v1 WHERE IF( a REGEXP 'def', 'foo', a ) IN ('abc', 'foobar'); + +DROP VIEW v1; +DROP TABLE t1; + --echo # End of 10.2 tests diff --git a/sql/item.cc b/sql/item.cc index 4f8433c28c0..ab7340a4689 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2389,37 +2389,40 @@ bool Item_func_or_sum::agg_item_set_converter(const DTCollation &coll, @param mem_root part of the memory for the clone @details - This method gets copy of the current item and also - build clones for its referencies. For the referencies - build_copy is called again. + This method fisrt builds clones of the arguments. If it is successful with + buiding the clones then it constructs a copy of this Item_func_or_sum object + and attaches to it the built clones of the arguments. @retval - clone of the item - 0 if an error occured + clone of the item on success + 0 on a failure */ Item* Item_func_or_sum::build_clone(THD *thd, MEM_ROOT *mem_root) { - Item_func_or_sum *copy= (Item_func_or_sum *) get_copy(thd, mem_root); - if (!copy) - return 0; + Item *copy_tmp_args[2]= {0,0}; + Item **copy_args= copy_tmp_args; if (arg_count > 2) { - copy->args= - (Item**) alloc_root(mem_root, sizeof(Item*) * arg_count); - if (!copy->args) + if (!(copy_args= (Item**) alloc_root(mem_root, sizeof(Item*) * arg_count))) return 0; } - else if (arg_count > 0) - copy->args= copy->tmp_arg; - - for (uint i= 0; i < arg_count; i++) { Item *arg_clone= args[i]->build_clone(thd, mem_root); if (!arg_clone) return 0; - copy->args[i]= arg_clone; + copy_args[i]= arg_clone; + } + Item_func_or_sum *copy= (Item_func_or_sum *) get_copy(thd, mem_root); + if (!copy) + return 0; + if (arg_count > 2) + copy->args= copy_args; + else if (arg_count > 0) + { + copy->args= copy->tmp_arg; + memcpy(copy->args, copy_args, sizeof(Item *) * arg_count); } return copy; } diff --git a/sql/item_row.cc b/sql/item_row.cc index 000253ece07..6ae049dbfe5 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -166,17 +166,20 @@ void Item_row::bring_value() Item* Item_row::build_clone(THD *thd, MEM_ROOT *mem_root) { - Item_row *copy= (Item_row *) get_copy(thd, mem_root); - if (!copy) + Item **copy_args= 0; + if (!(copy_args= (Item**) alloc_root(mem_root, sizeof(Item*) * arg_count))) return 0; - copy->args= (Item**) alloc_root(mem_root, sizeof(Item*) * arg_count); for (uint i= 0; i < arg_count; i++) { Item *arg_clone= args[i]->build_clone(thd, mem_root); if (!arg_clone) return 0; - copy->args[i]= arg_clone; + copy_args[i]= arg_clone; } + Item_row *copy= (Item_row *) get_copy(thd, mem_root); + if (!copy) + return 0; + copy->args= copy_args; return copy; } From 884d22f28884e1decced1dee9c69ddcb25002ed1 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 18 Mar 2020 14:57:01 +0300 Subject: [PATCH 02/18] remove fishy reinterpret_cast from buf_page_is_zeroes() In my micro-benchmarks memcmp(4196) 3 times faster than old implementation. Also, it's generally better to use as less reinterpret_casts<> as possible. buf_is_zeroes(): renamed from buf_page_is_zeroes() and argument changed to span<> for convenience. st_::span::const_iterator: fixed page_zip-verify_checksum(): make argument byte* instead of void* --- storage/innobase/buf/buf0buf.cc | 28 ++++++++++++++-------------- storage/innobase/buf/buf0dblwr.cc | 9 ++++++--- storage/innobase/ibuf/ibuf0ibuf.cc | 11 +++++++---- storage/innobase/include/buf0buf.h | 12 ++++++------ storage/innobase/include/page0zip.h | 2 +- storage/innobase/include/span.h | 4 ++-- storage/innobase/page/page0zip.cc | 16 +++++++--------- 7 files changed, 43 insertions(+), 39 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 57dc54f38b4..6b8784adb89 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -83,6 +83,8 @@ Created 11/5/1995 Heikki Tuuri #include "lzo/lzo1x.h" #endif +using st_::span; + #ifdef HAVE_LIBNUMA #include #include @@ -461,7 +463,7 @@ buf_pool_register_chunk( @return true if temporary tablespace decrypted, false if not */ static bool buf_tmp_page_decrypt(byte* tmp_frame, byte* src_frame) { - if (buf_page_is_zeroes(src_frame, srv_page_size)) { + if (buf_is_zeroes(span(src_frame, srv_page_size))) { return true; } @@ -950,20 +952,18 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum) # define buf_page_check_crc32(page, checksum) buf_calc_page_crc32(page) #endif /* INNODB_BUG_ENDIAN_CRC32 */ -/** Check if a page is all zeroes. -@param[in] read_buf database page -@param[in] page_size page frame size -@return whether the page is all zeroes */ -bool buf_page_is_zeroes(const void* read_buf, size_t page_size) + +/** Check if a buffer is all zeroes. +@param[in] buf data to check +@return whether the buffer is all zeroes */ +bool buf_is_zeroes(span buf) { - const ulint* b = reinterpret_cast(read_buf); - const ulint* const e = b + page_size / sizeof *b; - do { - if (*b++) { - return false; - } - } while (b != e); - return true; + static const byte zeroes[4 * 1024] = {0}; + for (size_t i = 0; i < buf.size(); i += sizeof(zeroes)) { + if (memcmp(zeroes, buf.data() + i, sizeof(zeroes)) != 0) + return false; + } + return true; } /** Check if a page is corrupt. diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index d44bfbf2b9e..7fb4cf9a9d3 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -34,6 +34,8 @@ Created 2011/12/19 #include "fil0crypt.h" #include "fil0pagecompress.h" +using st_::span; + /** The doublewrite buffer */ buf_dblwr_t* buf_dblwr = NULL; @@ -581,7 +583,8 @@ buf_dblwr_process() } const page_size_t page_size(space->flags); - ut_ad(!buf_page_is_zeroes(page, page_size.physical())); + ut_ad(!buf_is_zeroes(span(page, + page_size.physical()))); /* We want to ensure that for partial reads the unread portion of the page is NUL. */ @@ -604,8 +607,8 @@ buf_dblwr_process() << "error: " << ut_strerr(err); } - const bool is_all_zero = buf_page_is_zeroes( - read_buf, page_size.physical()); + const bool is_all_zero = buf_is_zeroes( + span(read_buf, page_size.physical())); const bool expect_encrypted = space->crypt_data && space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED; diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index d71a37cdd0b..32f9b20a1d0 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -28,6 +28,8 @@ Created 7/19/1997 Heikki Tuuri #include "sync0sync.h" #include "btr0sea.h" +using st_::span; + #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG my_bool srv_ibuf_disable_background_merge; #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ @@ -4970,7 +4972,8 @@ ibuf_check_bitmap_on_import( bitmap_page = ibuf_bitmap_get_map_page( page_id_t(space_id, page_no), page_size, &mtr); - if (buf_page_is_zeroes(bitmap_page, page_size.physical())) { + if (buf_is_zeroes(span(bitmap_page, + page_size.physical()))) { /* This means we got all-zero page instead of ibuf bitmap page. The subsequent page should be all-zero pages. */ @@ -4983,8 +4986,8 @@ ibuf_check_bitmap_on_import( page_size, RW_S_LATCH, &mtr); page_t* page = buf_block_get_frame(block); - ut_ad(buf_page_is_zeroes( - page, page_size.physical())); + ut_ad(buf_is_zeroes(span( + page, page_size.physical()))); } #endif /* UNIV_DEBUG */ ibuf_exit(&mtr); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index a061d8e18f8..a04936a19cf 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2019, MariaDB Corporation. +Copyright (c) 2013, 2020 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -33,6 +33,7 @@ Created 11/5/1995 Heikki Tuuri #include "fil0fil.h" #include "mtr0types.h" #include "buf0types.h" +#include "span.h" #ifndef UNIV_INNOCHECKSUM #include "hash0hash.h" #include "ut0byte.h" @@ -646,11 +647,10 @@ buf_block_unfix(buf_block_t* block); # endif /* UNIV_DEBUG */ #endif /* !UNIV_INNOCHECKSUM */ -/** Check if a page is all zeroes. -@param[in] read_buf database page -@param[in] page_size page frame size -@return whether the page is all zeroes */ -bool buf_page_is_zeroes(const void* read_buf, size_t page_size); +/** Check if a buffer is all zeroes. +@param[in] buf data to check +@return whether the buffer is all zeroes */ +bool buf_is_zeroes(st_::span buf); /** Checks if the page is in crc32 checksum format. @param[in] read_buf database page diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 63674748463..01b51ea2a0b 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -507,7 +507,7 @@ page_zip_calc_checksum( @param data ROW_FORMAT=COMPRESSED page @param size size of the page, in bytes @return whether the stored checksum matches innodb_checksum_algorithm */ -bool page_zip_verify_checksum(const void *data, size_t size); +bool page_zip_verify_checksum(const byte *data, size_t size); #ifndef UNIV_INNOCHECKSUM /**********************************************************************//** diff --git a/storage/innobase/include/span.h b/storage/innobase/include/span.h index faeb41029b8..62bcd80acd5 100644 --- a/storage/innobase/include/span.h +++ b/storage/innobase/include/span.h @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2019, MariaDB Corporation. +Copyright (c) 2019, 2020 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -34,7 +34,7 @@ public: typedef element_type& reference; typedef const element_type& const_reference; typedef pointer iterator; - typedef const pointer const_iterator; + typedef const_pointer const_iterator; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 6a86ad6be23..a64be931584 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -27,6 +27,9 @@ Created June 2005 by Marko Makela #include "page0size.h" #include "page0zip.h" +#include "span.h" + +using st_::span; /** A BLOB field reference full of zero, for use in assertions and tests. Initially, BLOB field references are set to zero, in @@ -4990,7 +4993,7 @@ page_zip_calc_checksum( @param data ROW_FORMAT=COMPRESSED page @param size size of the page, in bytes @return whether the stored checksum matches innodb_checksum_algorithm */ -bool page_zip_verify_checksum(const void *data, size_t size) +bool page_zip_verify_checksum(const byte *data, size_t size) { const srv_checksum_algorithm_t curr_algo = static_cast(srv_checksum_algorithm); @@ -4999,17 +5002,12 @@ bool page_zip_verify_checksum(const void *data, size_t size) return true; } - for (size_t i = 0; i < size; i++) { - if (static_cast(data)[i] != 0) { - goto not_all_zeroes; - } + if (buf_is_zeroes(span(data, size))) { + return true; } - return true; - -not_all_zeroes: const uint32_t stored = mach_read_from_4( - static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM); + data + FIL_PAGE_SPACE_OR_CHKSUM); uint32_t calc = page_zip_calc_checksum(data, size, curr_algo); From 1f53335d3740648c167b5d0a8217b66731228395 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 18 Mar 2020 15:19:45 +0300 Subject: [PATCH 03/18] st_::span fixes move span.h to a proper place to make it available for the whole server Reformat it. Constuctors from a contigous container are fixed to use cont.data() instead of cont.begin() span<>::index_type is replaced with span<>::size_type --- include/span.h | 141 +++++++++++++++++++++++++++++++ storage/innobase/include/span.h | 145 -------------------------------- 2 files changed, 141 insertions(+), 145 deletions(-) create mode 100644 include/span.h delete mode 100644 storage/innobase/include/span.h diff --git a/include/span.h b/include/span.h new file mode 100644 index 00000000000..0ed0158088c --- /dev/null +++ b/include/span.h @@ -0,0 +1,141 @@ +/***************************************************************************** + +Copyright (c) 2019, 2020 MariaDB Corporation. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +#pragma once + +#include +#include + +namespace st_ +{ + +template class span +{ +public: + typedef ElementType element_type; + typedef ElementType value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef element_type *pointer; + typedef const element_type *const_pointer; + typedef element_type &reference; + typedef const element_type &const_reference; + typedef pointer iterator; + typedef const_pointer const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + + span() : data_(NULL), size_(0) {} + + span(pointer ptr, size_type count) : data_(ptr), size_(count) {} + + span(pointer first, pointer last) : data_(first), size_(last - first) {} + + template span(element_type (&arr)[N]) : data_(arr), size_(N) {} + + template + span(Container &cont) : data_(cont.data()), size_(cont.size()) + { + } + + template + span(const Container &cont) : data_(cont.data()), size_(cont.size()) + { + } + + span(const span &other) : data_(other.data_), size_(other.size_) {} + + ~span(){}; + + span &operator=(const span &other) + { + data_= other.data_; + size_= other.size_; + return *this; + } + + template span first() const + { + assert(!empty()); + return span(data_, 1); + } + template span last() const + { + assert(!empty()); + return span(data_ + size() - 1, 1); + } + + span first(size_type count) const + { + assert(!empty()); + return span(data_, 1); + } + span last(size_type count) const + { + assert(!empty()); + return span(data_ + size() - 1, 1); + } + span subspan(size_type offset, size_type count) const + { + assert(!empty()); + assert(size() >= offset + count); + return span(data_ + offset, count); + } + + size_type size() const { return size_; } + size_type size_bytes() const { return size_ * sizeof(ElementType); } + bool empty() const __attribute__((warn_unused_result)) { return size_ == 0; } + + reference operator[](size_type idx) const + { + assert(size() > idx); + return data_[idx]; + } + reference front() const + { + assert(!empty()); + return data_[0]; + } + reference back() const + { + assert(!empty()); + return data_[size() - 1]; + } + pointer data() const + { + assert(!empty()); + return data_; + } + + iterator begin() const { return data_; } + iterator end() const { return data_ + size_; } + reverse_iterator rbegin() const + { + return std::reverse_iterator(std::advance(end(), -1)); + } + reverse_iterator rend() const + { + return std::reverse_iterator(std::advance(begin(), -1)); + } + +private: + pointer data_; + size_type size_; +}; + +} // namespace st_ diff --git a/storage/innobase/include/span.h b/storage/innobase/include/span.h deleted file mode 100644 index 62bcd80acd5..00000000000 --- a/storage/innobase/include/span.h +++ /dev/null @@ -1,145 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2019, 2020 MariaDB Corporation. - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA - -*****************************************************************************/ - -#pragma once - -#include -#include - -namespace st_ { - -template class span { -public: - typedef ElementType element_type; - typedef ElementType value_type; - typedef size_t index_type; - typedef ptrdiff_t difference_type; - typedef element_type* pointer; - typedef const element_type* const_pointer; - typedef element_type& reference; - typedef const element_type& const_reference; - typedef pointer iterator; - typedef const_pointer const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - span() : data_(NULL), size_(0) {} - - span(pointer ptr, index_type count) : data_(ptr), size_(count) {} - - span(pointer first, pointer last) : data_(first), size_(last - first) {} - - template span(element_type (&arr)[N]) : data_(arr), size_(N) - { - } - - template - span(Container& cont) : data_(cont.begin()), size_(cont.size()) - { - } - - template - span(const Container& cont) : data_(cont.begin()), size_(cont.size()) - { - } - - span(const span& other) : data_(other.data_), size_(other.size_) {} - - ~span(){}; - - span& operator=(const span& other) - { - data_ = other.data_; - size_ = other.size_; - return *this; - } - - template span first() const - { - assert(!empty()); - return span(data_, 1); - } - template span last() const - { - assert(!empty()); - return span(data_ + size() - 1, 1); - } - - span first(index_type count) const - { - assert(!empty()); - return span(data_, 1); - } - span last(index_type count) const - { - assert(!empty()); - return span(data_ + size() - 1, 1); - } - span subspan(index_type offset, index_type count) const - { - assert(!empty()); - assert(size() >= offset + count); - return span(data_ + offset, count); - } - - index_type size() const { return size_; } - index_type size_bytes() const { return size_ * sizeof(ElementType); } - bool empty() const __attribute__((warn_unused_result)) - { - return size_ == 0; - } - - reference operator[](index_type idx) const - { - assert(size() > idx); - return data_[idx]; - } - reference front() const - { - assert(!empty()); - return data_[0]; - } - reference back() const - { - assert(!empty()); - return data_[size() - 1]; - } - pointer data() const - { - assert(!empty()); - return data_; - } - - iterator begin() const { return data_; } - iterator end() const { return data_ + size_; } - reverse_iterator rbegin() const - { - return std::reverse_iterator(std::advance(end(), -1)); - } - reverse_iterator rend() const - { - return std::reverse_iterator( - std::advance(begin(), -1)); - } - -private: - pointer data_; - index_type size_; -}; - -} // namespace st_ From 54b2da9535614f3115723bb026b6ef56064f0c82 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 18 Mar 2020 18:22:38 +0300 Subject: [PATCH 04/18] correct comment in buf_page_is_corrupted() --- storage/innobase/buf/buf0buf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 6b8784adb89..8881ab5eb7a 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1081,7 +1081,7 @@ buf_page_is_corrupted( /* A page filled with NUL bytes is considered not corrupted. The FIL_PAGE_FILE_FLUSH_LSN field may be written nonzero for - the first page of each file of the system tablespace. + the first page of the system tablespace. Ignore it for the system tablespace. */ if (!checksum_field1 && !checksum_field2) { /* Checksum fields can have valid value as zero. From 45973ec61058b1428ae88316631f49e58d227207 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 19 Mar 2020 18:33:19 +0300 Subject: [PATCH 05/18] InnoDB: reduce size of dtuple_t Making a linked list of dtuple_t is needed only for inserting records. It's better to store tuples in a non-intrusive container to not affect all other use cases of dtuple_t dtuple_t::tuple_list: removed, it was 2 * sizeof(void*) bytes ins_node_t::entry_list: now it's std::vector ins_node_t::entry: now it's std::vector::iterator DBUG_EXECUTE_IF("row_ins_skip_sec": this dead code removed --- storage/innobase/include/data0data.h | 6 ++--- storage/innobase/include/row0ins.h | 15 +++++++---- storage/innobase/que/que0que.cc | 4 ++- storage/innobase/row/row0ins.cc | 38 +++++++++++++--------------- storage/innobase/row/row0mysql.cc | 2 +- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index 33d03c8a2c9..fdf1a14feee 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2019, 2020 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -32,6 +32,7 @@ Created 5/30/1994 Heikki Tuuri #include "mem0mem.h" #include "dict0types.h" #include "btr0types.h" +#include #include @@ -510,9 +511,6 @@ struct dtuple_t { dfield_t* fields; /*!< fields */ ulint n_v_fields; /*!< number of virtual fields */ dfield_t* v_fields; /*!< fields on virtual column */ - UT_LIST_NODE_T(dtuple_t) tuple_list; - /*!< data tuples can be linked into a - list using this field */ #ifdef UNIV_DEBUG ulint magic_n; /*!< magic number, used in debug assertions */ diff --git a/storage/innobase/include/row0ins.h b/storage/innobase/include/row0ins.h index 164f6fe1ddb..27fe442f6ff 100644 --- a/storage/innobase/include/row0ins.h +++ b/storage/innobase/include/row0ins.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2019, 2020 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -31,6 +31,7 @@ Created 4/20/1996 Heikki Tuuri #include "que0types.h" #include "trx0types.h" #include "row0types.h" +#include /***************************************************************//** Checks if foreign key constraint fails for an index entry. Sets shared locks @@ -159,7 +160,10 @@ row_ins_step( /* Insert node structure */ struct ins_node_t{ - que_common_t common; /*!< node type: QUE_NODE_INSERT */ + ins_node_t() : common(QUE_NODE_INSERT, NULL), entry(entry_list.end()) + { + } + que_common_t common; /*!< node type: QUE_NODE_INSERT */ ulint ins_type;/* INS_VALUES, INS_SEARCHED, or INS_DIRECT */ dtuple_t* row; /*!< row to insert */ dict_table_t* table; /*!< table where to insert */ @@ -169,11 +173,12 @@ struct ins_node_t{ ulint state; /*!< node execution state */ dict_index_t* index; /*!< NULL, or the next index where the index entry should be inserted */ - dtuple_t* entry; /*!< NULL, or entry to insert in the index; + std::vector + entry_list;/* list of entries, one for each index */ + std::vector::iterator + entry; /*!< NULL, or entry to insert in the index; after a successful insert of the entry, this should be reset to NULL */ - UT_LIST_BASE_NODE_T(dtuple_t) - entry_list;/* list of entries, one for each index */ /** buffer for the system columns */ byte sys_buf[DATA_ROW_ID_LEN + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN]; diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc index 1d3d1573299..3ad948af4d2 100644 --- a/storage/innobase/que/que0que.cc +++ b/storage/innobase/que/que0que.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2018, 2020 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -460,6 +460,8 @@ que_graph_free_recursive( que_graph_free_recursive(ins->select); ins->select = NULL; + ins->~ins_node_t(); + if (ins->entry_sys_heap != NULL) { mem_heap_free(ins->entry_sys_heap); ins->entry_sys_heap = NULL; diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index cb27d4f8dd3..c4410f15b84 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2019, 2020 MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -73,8 +73,8 @@ ins_node_create( { ins_node_t* node; - node = static_cast( - mem_heap_alloc(heap, sizeof(ins_node_t))); + node = new (static_cast( + mem_heap_alloc(heap, sizeof(ins_node_t)))) ins_node_t; node->common.type = QUE_NODE_INSERT; @@ -83,7 +83,6 @@ ins_node_create( node->state = INS_NODE_SET_IX_LOCK; node->table = table; node->index = NULL; - node->entry = NULL; node->select = NULL; @@ -109,12 +108,12 @@ ins_node_create_entry_list( ut_ad(node->entry_sys_heap); - UT_LIST_INIT(node->entry_list, &dtuple_t::tuple_list); - /* We will include all indexes (include those corrupted - secondary indexes) in the entry list. Filteration of + secondary indexes) in the entry list. Filtration of these corrupted index will be done in row_ins() */ + node->entry_list.reserve(UT_LIST_GET_LEN(node->table->indexes)); + for (index = dict_table_get_first_index(node->table); index != 0; index = dict_table_get_next_index(index)) { @@ -123,7 +122,7 @@ ins_node_create_entry_list( node->row, NULL, index, node->entry_sys_heap, ROW_BUILD_FOR_INSERT); - UT_LIST_ADD_LAST(node->entry_list, entry); + node->entry_list.push_back(entry); } } @@ -189,7 +188,8 @@ ins_node_set_new_row( { node->state = INS_NODE_SET_IX_LOCK; node->index = NULL; - node->entry = NULL; + node->entry_list.clear(); + node->entry = node->entry_list.end(); node->row = row; @@ -3413,15 +3413,16 @@ row_ins_index_entry_step( ut_ad(dtuple_check_typed(node->row)); - err = row_ins_index_entry_set_vals(node->index, node->entry, node->row); + err = row_ins_index_entry_set_vals(node->index, *node->entry, + node->row); if (err != DB_SUCCESS) { DBUG_RETURN(err); } - ut_ad(dtuple_check_typed(node->entry)); + ut_ad(dtuple_check_typed(*node->entry)); - err = row_ins_index_entry(node->index, node->entry, thr); + err = row_ins_index_entry(node->index, *node->entry, thr); DEBUG_SYNC_C_IF_THD(thr_get_trx(thr)->mysql_thd, "after_row_ins_index_entry_step"); @@ -3539,7 +3540,8 @@ row_ins( row_ins_alloc_row_id_step(node); node->index = dict_table_get_first_index(node->table); - node->entry = UT_LIST_GET_FIRST(node->entry_list); + ut_ad(node->entry_list.empty() == false); + node->entry = node->entry_list.begin(); if (node->ins_type == INS_SEARCHED) { @@ -3565,20 +3567,16 @@ row_ins( } node->index = dict_table_get_next_index(node->index); - node->entry = UT_LIST_GET_NEXT(tuple_list, node->entry); - - DBUG_EXECUTE_IF( - "row_ins_skip_sec", - node->index = NULL; node->entry = NULL; break;); + ++node->entry; /* Skip corrupted secondary index and its entry */ while (node->index && node->index->is_corrupted()) { node->index = dict_table_get_next_index(node->index); - node->entry = UT_LIST_GET_NEXT(tuple_list, node->entry); + ++node->entry; } } - ut_ad(node->entry == NULL); + ut_ad(node->entry == node->entry_list.end()); node->state = INS_NODE_ALLOC_ROW_ID; diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 9add75b3a67..c708842b04d 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1092,7 +1092,7 @@ row_get_prebuilt_insert_row( may need to rebuild the row insert template. */ if (prebuilt->trx_id == table->def_trx_id - && UT_LIST_GET_LEN(prebuilt->ins_node->entry_list) + && prebuilt->ins_node->entry_list.size() == UT_LIST_GET_LEN(table->indexes)) { return(prebuilt->ins_node->row); From de9072ca19b84e0a33425248b7d4557c3e5ae89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 21 Mar 2020 12:51:24 +0200 Subject: [PATCH 06/18] Connect: Remove some unused variables --- storage/connect/jdbconn.cpp | 1 - storage/connect/tabrest.cpp | 3 +-- storage/connect/tabrest.h | 5 +---- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index 2cb75e0adc1..2dab385a36f 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -766,7 +766,6 @@ void JDBConn::AddJars(PSTRG jpop, char sep) /***********************************************************************/ bool JDBConn::Connect(PJPARM sop) { - int irc = RC_FX; bool err = false; jint rc; jboolean jt = (trace(1)); diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp index 9c6b724973f..3ef2a460b9d 100644 --- a/storage/connect/tabrest.cpp +++ b/storage/connect/tabrest.cpp @@ -167,8 +167,7 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info) #endif // !MARIADB // We used the file name relative to recorded datapath - strcat(strcat(strcat(strcpy(filename, "."), slash), db), slash); - strncat(filename, fn, _MAX_PATH - strlen(filename)); + snprintf(filename, sizeof filename, IF_WIN(".\\%s\\%s","./%s/%s"), db, fn); // Retrieve the file from the web and copy it locally if (http && grf(g->Message, trace(515), http, uri, filename)) { diff --git a/storage/connect/tabrest.h b/storage/connect/tabrest.h index 9cf2d10a6b8..f08ac7984c9 100644 --- a/storage/connect/tabrest.h +++ b/storage/connect/tabrest.h @@ -5,10 +5,7 @@ /***********************************************************************/ #pragma once -#if defined(__WIN__) -static PCSZ slash = "\\"; -#else // !__WIN__ -static PCSZ slash = "/"; +#ifndef __WIN__ #define stricmp strcasecmp #endif // !__WIN__ From 23993c0036bcccffb61bd7b13c4e0df9e94a6c7e Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Sat, 21 Mar 2020 17:06:00 +0300 Subject: [PATCH 07/18] MDEV-21993 asan failure in encryption.innochecksum buf_is_zeroes(): stop assuming that argument buffer size is always a multiply of 4096. And thus stop reading past that buffer. --- storage/innobase/buf/buf0buf.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 8881ab5eb7a..cec39ab8e47 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -959,8 +959,10 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum) bool buf_is_zeroes(span buf) { static const byte zeroes[4 * 1024] = {0}; - for (size_t i = 0; i < buf.size(); i += sizeof(zeroes)) { - if (memcmp(zeroes, buf.data() + i, sizeof(zeroes)) != 0) + for (size_t i = 0; i < buf.size(); i += std::min(sizeof(zeroes), + buf.size() - i)) { + if (memcmp(zeroes, buf.data() + i, std::min(sizeof(zeroes), + buf.size() - i)) != 0) return false; } return true; From 5e9e0b8e3bf78327aa7054b0615bb40f9273e3a3 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Sat, 21 Mar 2020 17:57:04 +0300 Subject: [PATCH 08/18] MDEV-21993 asan failure in encryption.innochecksum simplify fix field_ref_zero: make bigger buf_is_zeroes(): remove a loop and check in one go --- storage/innobase/buf/buf0buf.cc | 10 ++-------- storage/innobase/include/page0size.h | 2 +- storage/innobase/page/page0zip.cc | 10 +++------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index cec39ab8e47..ad0f40ce67e 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -958,14 +958,8 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum) @return whether the buffer is all zeroes */ bool buf_is_zeroes(span buf) { - static const byte zeroes[4 * 1024] = {0}; - for (size_t i = 0; i < buf.size(); i += std::min(sizeof(zeroes), - buf.size() - i)) { - if (memcmp(zeroes, buf.data() + i, std::min(sizeof(zeroes), - buf.size() - i)) != 0) - return false; - } - return true; + ut_ad(buf.size() <= sizeof field_ref_zero); + return memcmp(buf.data(), field_ref_zero, buf.size()) == 0; } /** Check if a page is corrupt. diff --git a/storage/innobase/include/page0size.h b/storage/innobase/include/page0size.h index eb11db7781d..74fcfb106ea 100644 --- a/storage/innobase/include/page0size.h +++ b/storage/innobase/include/page0size.h @@ -34,7 +34,7 @@ Created Nov 14, 2013 Vasil Dimov /** A BLOB field reference full of zero, for use in assertions and tests.Initially, BLOB field references are set to zero, in dtuple_convert_big_rec(). */ -extern const byte field_ref_zero[FIELD_REF_SIZE]; +extern const byte field_ref_zero[UNIV_PAGE_SIZE_MAX]; #define PAGE_SIZE_T_SIZE_BITS 17 diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index a64be931584..9db2bd1c341 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -34,12 +34,8 @@ using st_::span; /** A BLOB field reference full of zero, for use in assertions and tests. Initially, BLOB field references are set to zero, in dtuple_convert_big_rec(). */ -const byte field_ref_zero[FIELD_REF_SIZE] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -}; +MY_ALIGNED(UNIV_PAGE_SIZE_MAX) +const byte field_ref_zero[UNIV_PAGE_SIZE_MAX] = { 0, }; #ifndef UNIV_INNOCHECKSUM #include "page0page.h" @@ -113,7 +109,7 @@ Compare at most sizeof(field_ref_zero) bytes. /** Assert that a BLOB pointer is filled with zero bytes. @param b in: BLOB pointer */ #define ASSERT_ZERO_BLOB(b) \ - ut_ad(!memcmp(b, field_ref_zero, sizeof field_ref_zero)) + ut_ad(!memcmp(b, field_ref_zero, FIELD_REF_SIZE)) /* Enable some extra debugging output. This code can be enabled independently of any UNIV_ debugging conditions. */ From 7e168634e97a1f976b421cc5673db9b1cb55f7f7 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Sat, 21 Mar 2020 20:37:00 +0300 Subject: [PATCH 09/18] blind fix for Windows building --- storage/innobase/page/page0zip.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 9db2bd1c341..30491cabd16 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -34,7 +34,6 @@ using st_::span; /** A BLOB field reference full of zero, for use in assertions and tests. Initially, BLOB field references are set to zero, in dtuple_convert_big_rec(). */ -MY_ALIGNED(UNIV_PAGE_SIZE_MAX) const byte field_ref_zero[UNIV_PAGE_SIZE_MAX] = { 0, }; #ifndef UNIV_INNOCHECKSUM From ad6e421bd2ef2c63ea673da387276f74c23b7f5b Mon Sep 17 00:00:00 2001 From: Alice Sherepa Date: Thu, 19 Mar 2020 18:55:57 +0100 Subject: [PATCH 10/18] MDEV-21360 restore debud_dbug through a session variable instead of '-d,..' --- .../extra/rpl_tests/rpl_binlog_errors.inc | 42 +++++------ mysql-test/extra/rpl_tests/rpl_corruption.inc | 24 +++---- .../rpl_get_master_version_and_clock.test | 6 +- .../rpl_tests/rpl_stop_middle_group.test | 12 ++-- mysql-test/include/io_thd_fault_injection.inc | 9 ++- .../rpl_binlog_errors.result | 70 +++++++++---------- .../binlog_encryption/rpl_corruption.result | 24 +++---- .../gcol/r/innodb_virtual_debug_purge.result | 16 ++--- .../gcol/t/innodb_virtual_debug_purge.test | 16 ++--- mysql-test/suite/rpl/disabled.def | 2 +- .../suite/rpl/r/circular_serverid0.result | 4 +- .../suite/rpl/r/rpl_binlog_errors.result | 70 +++++++++---------- mysql-test/suite/rpl/r/rpl_corruption.result | 24 +++---- .../r/rpl_domain_id_filter_io_crash.result | 24 +++---- .../r/rpl_get_master_version_and_clock.result | 19 +++-- mysql-test/suite/rpl/r/rpl_gtid_strict.result | 17 ++--- .../suite/rpl/r/rpl_row_corruption.result | 14 ++-- .../rpl/r/rpl_stm_stop_middle_group.result | 12 ++-- .../suite/rpl/t/circular_serverid0.test | 4 +- mysql-test/suite/rpl/t/rpl_bug41902-slave.opt | 1 - .../rpl/t/rpl_domain_id_filter_io_crash.test | 24 +++---- mysql-test/suite/rpl/t/rpl_gtid_strict.test | 17 ++--- .../suite/rpl/t/rpl_row_corruption.test | 14 ++-- 23 files changed, 228 insertions(+), 237 deletions(-) delete mode 100644 mysql-test/suite/rpl/t/rpl_bug41902-slave.opt diff --git a/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc b/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc index 49ab4f386bf..097239f78d4 100644 --- a/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc +++ b/mysql-test/extra/rpl_tests/rpl_binlog_errors.inc @@ -84,14 +84,14 @@ FLUSH LOGS; ### (should show just one binlog) RESET MASTER; -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- error ER_NO_UNIQUE_LOGFILE FLUSH LOGS; -- echo # assert: must show one binlog -- source include/show_binary_logs.inc ### ACTION: clean up and move to next test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; -- echo ###################### TEST #3 @@ -116,7 +116,7 @@ RESET MASTER; -- source include/show_binary_logs.inc # clean up the table and the binlog to be used in next part of test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -127,7 +127,7 @@ RESET MASTER; ### changes performed despite the fact that it reported an ### error. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -- error ER_NO_UNIQUE_LOGFILE -- eval LOAD DATA INFILE '$load_file' INTO TABLE t2 @@ -137,7 +137,7 @@ SET GLOBAL debug_dbug="+d,error_unique_log_filename"; SELECT count(*) FROM t2; # clean up the table and the binlog to be used in next part of test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -146,7 +146,7 @@ RESET MASTER; ### ASSERTION: load the small file into a transactional table and ### check that it succeeds -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -- eval LOAD DATA INFILE '$load_file2' INTO TABLE t2 @@ -155,7 +155,7 @@ SET GLOBAL debug_dbug="+d,error_unique_log_filename"; SELECT count(*) FROM t2; # clean up the table and the binlog to be used in next part of test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -166,7 +166,7 @@ RESET MASTER; ### fails we get the error. Transaction is not rolledback ### because rotation happens after the commit. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET AUTOCOMMIT=0; INSERT INTO t2 VALUES ('muse'); -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -181,7 +181,7 @@ SELECT count(*) FROM t2; ### ACTION: clean up and move to the next test SET AUTOCOMMIT= 1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -191,7 +191,7 @@ RESET MASTER; ### fails then an error is reported and an incident event ### is written to the current binary log. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; # Disable logging Annotate_rows events to preserve events count. let $binlog_annotate_row_events_saved= `SELECT @@binlog_annotate_row_events`; @@ -206,7 +206,7 @@ SELECT count(*) FROM t4; SELECT count(*) FROM t4; -- echo ### check that the incident event is written to the current log -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; if (!$binlog_limit) { -- let $binlog_limit= 4,1 @@ -227,7 +227,7 @@ RESET MASTER; ### ASSERTION: check that statements end up in error but they succeed ### on changing the data. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- echo # must show 0 entries SELECT count(*) FROM t4; SELECT count(*) FROM t2; @@ -258,13 +258,13 @@ SELECT count(*) FROM t4; SELECT count(*) FROM t2; # remove fault injection -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- echo ###################### TEST #9 ### ASSERTION: check that if we disable binlogging, then statements ### succeed. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET SQL_LOG_BIN=0; INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'); INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh'); @@ -277,7 +277,7 @@ DELETE FROM t4; SELECT count(*) FROM t2; SELECT count(*) FROM t4; SET SQL_LOG_BIN=1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- echo ###################### TEST #10 @@ -292,11 +292,11 @@ RESET MASTER; SHOW WARNINGS; # +d,fault_injection_registering_index => injects fault on MYSQL_BIN_LOG::open -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; -- replace_regex /\.[\\\/]master/master/ -- error ER_CANT_OPEN_FILE FLUSH LOGS; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- error ER_NO_BINARY_LOGGING SHOW BINARY LOGS; @@ -321,11 +321,11 @@ flush tables; --source include/rpl_restart_server.inc # +d,fault_injection_openning_index => injects fault on MYSQL_BIN_LOG::open_index_file -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; -- replace_regex /\.[\\\/]master/master/ -- error ER_CANT_OPEN_FILE FLUSH LOGS; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- error ER_FLUSH_MASTER_BINLOG_CLOSED RESET MASTER; @@ -350,10 +350,10 @@ flush tables; ### file. # +d,fault_injection_new_file_rotate_event => injects fault on MYSQL_BIN_LOG::MYSQL_BIN_LOG::new_file_impl -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; -- error ER_ERROR_ON_WRITE FLUSH LOGS; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- error ER_FLUSH_MASTER_BINLOG_CLOSED RESET MASTER; diff --git a/mysql-test/extra/rpl_tests/rpl_corruption.inc b/mysql-test/extra/rpl_tests/rpl_corruption.inc index 4106bb45eef..c7a913af9d7 100644 --- a/mysql-test/extra/rpl_tests/rpl_corruption.inc +++ b/mysql-test/extra/rpl_tests/rpl_corruption.inc @@ -73,8 +73,8 @@ while ($i) { # Emulate corruption in binlog file when SHOW BINLOG EVENTS is executing --echo # 2. Corruption in master binlog and SHOW BINLOG EVENTS -set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @saved_dbug = @@global.debug_dbug; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; --echo SHOW BINLOG EVENTS; --disable_query_log send_eval SHOW BINLOG EVENTS FROM $pos; @@ -82,7 +82,7 @@ send_eval SHOW BINLOG EVENTS FROM $pos; --error ER_ERROR_WHEN_EXECUTING_COMMAND reap; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; +SET @@global.debug_dbug=@saved_dbug; # Emulate corruption on master with crc checking on master --echo # 3. Master read a corrupted event from binlog and send the error to slave @@ -107,20 +107,20 @@ let $wait_condition= SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE command = 'Binlog Dump'; --source include/wait_condition.inc -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; --connection slave START SLAVE IO_THREAD; let $slave_io_errno= 1236; --let $slave_timeout= 10 --source include/wait_for_slave_io_error.inc --connection master -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug=@saved_dbug; # Emulate corruption on master without crc checking on master --echo # 4. Master read a corrupted event from binlog and send it to slave --connection master SET GLOBAL master_verify_checksum=0; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; --connection slave START SLAVE IO_THREAD; # When the checksum error is detected, the slave sets error code 1743 @@ -130,31 +130,29 @@ START SLAVE IO_THREAD; let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE --source include/wait_for_slave_io_error.inc --connection master -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; -SET GLOBAL debug_dbug=@saved_dbug; +SET @@global.debug_dbug=@saved_dbug; SET GLOBAL master_verify_checksum=1; # Emulate corruption in network --echo # 5. Slave. Corruption in network --connection slave SET @saved_dbug_slave = @@GLOBAL.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_queue_event"; +SET @@global.debug_dbug="d,corrupt_queue_event"; START SLAVE IO_THREAD; let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE --source include/wait_for_slave_io_error.inc -SET GLOBAL debug_dbug="-d,corrupt_queue_event"; +SET @@global.debug_dbug=@saved_dbug_slave; # Emulate corruption in relay log --echo # 6. Slave. Corruption in relay log -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; START SLAVE SQL_THREAD; let $slave_sql_errno= 1593; --source include/wait_for_slave_sql_error.inc -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; -SET GLOBAL debug_dbug=@saved_dbug_slave; +SET @@global.debug_dbug=@saved_dbug_slave; # Start normal replication and compare same table on master # and slave diff --git a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test index eb0e5e21d62..181759283e2 100644 --- a/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test +++ b/mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test @@ -41,8 +41,8 @@ if (!$debug_sync_action) # Restart slave --source include/stop_slave.inc - -eval SET @@global.debug_dbug= "+d,$dbug_sync_point"; +SET @old_dbug = @@global.debug_dbug; +eval SET @@global.debug_dbug= "d,$dbug_sync_point"; --source include/start_slave.inc --echo slave is going to hang in get_master_version_and_clock @@ -70,7 +70,7 @@ source include/wait_for_slave_io_error.inc; # now to avoid restarting IO-thread to re-enter it. # There will be a new IO thread forked out with its @@session.debug # unset. -eval set @@global.debug_dbug= "-d,$dbug_sync_point"; +set @@global.debug_dbug= @old_dbug; --let $rpl_server_number= 1 --source include/rpl_start_server.inc diff --git a/mysql-test/extra/rpl_tests/rpl_stop_middle_group.test b/mysql-test/extra/rpl_tests/rpl_stop_middle_group.test index 5c88c14d9b5..ac01fb04d16 100644 --- a/mysql-test/extra/rpl_tests/rpl_stop_middle_group.test +++ b/mysql-test/extra/rpl_tests/rpl_stop_middle_group.test @@ -14,7 +14,7 @@ create table ti (a int auto_increment primary key) engine=innodb; sync_slave_with_master; SET @saved_dbug = @@GLOBAL.debug_dbug; -set @@global.debug_dbug="+d,stop_slave_middle_group"; +set @@global.debug_dbug="d,stop_slave_middle_group"; connection master; @@ -44,7 +44,7 @@ eval SELECT "NO$error" AS Last_SQL_Error, @check as `true`; select count(*) as one from tm; select count(*) as one from ti; -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; # # bug#45940 issues around rli->last_event_start_time @@ -68,8 +68,7 @@ truncate table ti; #connection slave; sync_slave_with_master; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; @@ -97,7 +96,7 @@ eval SELECT "$error" AS Last_SQL_Error, @check as `true`; select count(*) as one from tm; select count(*) as zero from ti; -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; # # The mixed multi-table update @@ -110,8 +109,7 @@ connection master; #connection slave; sync_slave_with_master; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2; diff --git a/mysql-test/include/io_thd_fault_injection.inc b/mysql-test/include/io_thd_fault_injection.inc index 11479b3a66c..67b41371913 100644 --- a/mysql-test/include/io_thd_fault_injection.inc +++ b/mysql-test/include/io_thd_fault_injection.inc @@ -1,20 +1,19 @@ # # Takes the flag as an argument: -# -- let $io_thd_injection_fault_flag=+d,fault_injection_new_file_rotate_event +# -- let $io_thd_injection_fault_flag=d,fault_injection_new_file_rotate_event # -- source include/io_thd_fault_injection.inc # -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; -- disable_warnings -- source include/stop_slave.inc -- enable_warnings --- eval SET GLOBAL debug_dbug="+d,$io_thd_injection_fault_flag" +-- eval SET @@global.debug_dbug="d,$io_thd_injection_fault_flag" START SLAVE io_thread; -- source include/wait_for_slave_io_error.inc --- eval SET GLOBAL debug_dbug="-d,$io_thd_injection_fault_flag" -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; # restart because slave is in bad shape --let $rpl_server_number= 2 diff --git a/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result b/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result index 06be72d523b..32b158e7041 100644 --- a/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result +++ b/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result @@ -22,7 +22,7 @@ master-bin.000001 # master-bin.000002 # ###################### TEST #2 RESET MASTER; -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; FLUSH LOGS; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -30,7 +30,7 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) show binary logs; Log_name File_size master-bin.000001 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ###################### TEST #3 CREATE TABLE t1 (a INT); @@ -44,11 +44,11 @@ show binary logs; Log_name File_size master-bin.000001 # master-bin.000002 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #4 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -56,21 +56,21 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #5 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166-2.data' INTO TABLE t2; # assert: must show one entry SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #6 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET AUTOCOMMIT=0; INSERT INTO t2 VALUES ('muse'); LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; @@ -83,11 +83,11 @@ SELECT count(*) FROM t2; count(*) 3 SET AUTOCOMMIT= 1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #7 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET @@binlog_annotate_row_events= 0; SELECT count(*) FROM t4; count(*) @@ -100,14 +100,14 @@ SELECT count(*) FROM t4; count(*) 1 ### check that the incident event is written to the current log -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Incident # # #1 (LOST_EVENTS) DELETE FROM t4; RESET MASTER; ###################### TEST #8 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; # must show 0 entries SELECT count(*) FROM t4; count(*) @@ -147,9 +147,9 @@ count(*) SELECT count(*) FROM t2; count(*) 0 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #9 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET SQL_LOG_BIN=0; INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'); INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh'); @@ -170,17 +170,17 @@ SELECT count(*) FROM t4; count(*) 0 SET SQL_LOG_BIN=1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #10 call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Could not open .*"); RESET MASTER; SHOW WARNINGS; Level Code Message -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.000002' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; SHOW BINARY LOGS; ERROR HY000: You are not using binary logging CREATE TABLE t5 (a INT); @@ -192,10 +192,10 @@ DROP TABLE t5; flush tables; ###################### TEST #11 include/rpl_restart_server.inc [server_number=1] -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.index' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -207,10 +207,10 @@ DROP TABLE t5; flush tables; include/rpl_restart_server.inc [server_number=1] ###################### TEST #12 -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin' (errno: 2 "No such file or directory") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -237,44 +237,40 @@ call mtr.add_suppression("Could not open .*"); call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Can't generate a unique log-filename .*"); ###################### TEST #13 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,error_unique_log_filename"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #14 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_new_file_rotate_event"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #15 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_registering_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #16 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_openning_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] include/stop_slave_sql.inc Warnings: diff --git a/mysql-test/suite/binlog_encryption/rpl_corruption.result b/mysql-test/suite/binlog_encryption/rpl_corruption.result index f32b7c58ad1..73bb373d6be 100644 --- a/mysql-test/suite/binlog_encryption/rpl_corruption.result +++ b/mysql-test/suite/binlog_encryption/rpl_corruption.result @@ -13,42 +13,40 @@ connection master; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100)); include/stop_slave.inc # 2. Corruption in master binlog and SHOW BINLOG EVENTS -set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @saved_dbug = @@global.debug_dbug; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; SHOW BINLOG EVENTS; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; +SET @@global.debug_dbug=@saved_dbug; # 3. Master read a corrupted event from binlog and send the error to slave -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1236] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug=@saved_dbug; # 4. Master read a corrupted event from binlog and send it to slave connection master; SET GLOBAL master_verify_checksum=0; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; -SET GLOBAL debug_dbug=@saved_dbug; +SET @@global.debug_dbug=@saved_dbug; SET GLOBAL master_verify_checksum=1; # 5. Slave. Corruption in network connection slave; SET @saved_dbug_slave = @@GLOBAL.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_queue_event"; +SET @@global.debug_dbug="d,corrupt_queue_event"; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] -SET GLOBAL debug_dbug="-d,corrupt_queue_event"; +SET @@global.debug_dbug=@saved_dbug_slave; # 6. Slave. Corruption in relay log -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; START SLAVE SQL_THREAD; include/wait_for_slave_sql_error.inc [errno=1593] -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; -SET GLOBAL debug_dbug=@saved_dbug_slave; +SET @@global.debug_dbug=@saved_dbug_slave; # 7. Seek diff for tables on master and slave connection slave; include/start_slave.inc diff --git a/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result b/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result index 1a5734ca516..11dfdf8b52e 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result @@ -12,7 +12,7 @@ CREATE TABLE `t` ( INSERT INTO t VALUES (REPEAT('g', 16000), REPEAT('x', 16000), DEFAULT, "kk", 1); INSERT INTO t VALUES (REPEAT('a', 16000), REPEAT('b', 16000), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 16000) WHERE a like "aaa%"; InnoDB 0 transactions not purged SET global debug_dbug=@old_dbug; @@ -27,7 +27,7 @@ i INT INSERT INTO t VALUES (REPEAT('g', 100), REPEAT('x', 100), DEFAULT, "kk", 1); INSERT INTO t VALUES (REPEAT('a', 100), REPEAT('b', 100), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 100) WHERE a like "aaa%"; InnoDB 0 transactions not purged SET global debug_dbug=@old_dbug; @@ -48,7 +48,7 @@ insert into t1 values(3, 4, default); insert into t1 values(3, 12, default); insert into t1 values(4, 18, default); CREATE INDEX idx ON t1(x); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t1 SET id = 10 WHERE id = 1; InnoDB 0 transactions not purged SET global debug_dbug=@old_dbug; @@ -138,7 +138,7 @@ DROP TABLE t0, t1; create table t (a blob, b blob, c blob as (concat(a,b)), h varchar(10), index (c(100))); insert t(a,b,h) values (repeat('g', 16000), repeat('x', 16000), "kk"); insert t(a,b,h) values (repeat('a', 16000), repeat('b', 16000), "mm"); -set global debug_dbug="+d,ib_purge_virtual_index_callback"; +set global debug_dbug="d,ib_purge_virtual_index_callback"; connect prevent_purge, localhost, root; start transaction with consistent snapshot; connection default; @@ -181,7 +181,7 @@ CREATE TABLE t1 (y YEAR, vy YEAR AS (y) VIRTUAL UNIQUE, pk INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 (pk,y) VALUES (1,2022); CREATE TABLE t2(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; -SET GLOBAL debug_dbug = '+d,ib_purge_virtual_index_callback'; +SET GLOBAL debug_dbug = 'd,ib_purge_virtual_index_callback'; BEGIN; INSERT INTO t2(f1) VALUES(1); connection prevent_purge; @@ -209,7 +209,7 @@ DROP TABLE t1, t2; # on table with virtual columns and indexes # SET @saved_dbug= @@GLOBAL.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; +set global debug_dbug= "d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; create table t1 ( pk serial, vb tinyblob as (b) virtual, b tinyblob, primary key(pk), index (vb(64))) @@ -218,7 +218,7 @@ insert ignore into t1 (b) values ('foo'); select * into outfile 'load.data' from t1; load data infile 'load.data' replace into table t1; set debug_sync= "now WAIT_FOR latch_released TIMEOUT 1"; -set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; +set global debug_dbug= @saved_dbug; drop table t1; set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table TIMEOUT 1"; create table t1 ( @@ -254,7 +254,7 @@ SET GLOBAL innodb_debug_sync = "ib_open_after_dict_open " "SIGNAL purge_open " "WAIT_FOR select_open"; SET @saved_dbug= @@GLOBAL.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_index_callback"; +set global debug_dbug= "d,ib_purge_virtual_index_callback"; connect purge_waiter,localhost,root; SET debug_sync= "now WAIT_FOR before_row_allocated"; connection default; diff --git a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test index b1a2f0cbdd6..62017e55fbc 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test @@ -22,7 +22,7 @@ INSERT INTO t VALUES (REPEAT('a', 16000), REPEAT('b', 16000), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 16000) WHERE a like "aaa%"; --source ../../innodb/include/wait_all_purged.inc SET global debug_dbug=@old_dbug; @@ -41,7 +41,7 @@ INSERT INTO t VALUES (REPEAT('a', 100), REPEAT('b', 100), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 100) WHERE a like "aaa%"; --source ../../innodb/include/wait_all_purged.inc SET global debug_dbug=@old_dbug; @@ -68,7 +68,7 @@ insert into t1 values(4, 18, default); CREATE INDEX idx ON t1(x); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t1 SET id = 10 WHERE id = 1; --source ../../innodb/include/wait_all_purged.inc SET global debug_dbug=@old_dbug; @@ -179,7 +179,7 @@ DROP TABLE t0, t1; create table t (a blob, b blob, c blob as (concat(a,b)), h varchar(10), index (c(100))); insert t(a,b,h) values (repeat('g', 16000), repeat('x', 16000), "kk"); insert t(a,b,h) values (repeat('a', 16000), repeat('b', 16000), "mm"); -set global debug_dbug="+d,ib_purge_virtual_index_callback"; +set global debug_dbug="d,ib_purge_virtual_index_callback"; connect(prevent_purge, localhost, root); start transaction with consistent snapshot; connection default; @@ -228,7 +228,7 @@ ENGINE=InnoDB; INSERT INTO t1 (pk,y) VALUES (1,2022); CREATE TABLE t2(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; -SET GLOBAL debug_dbug = '+d,ib_purge_virtual_index_callback'; +SET GLOBAL debug_dbug = 'd,ib_purge_virtual_index_callback'; BEGIN; INSERT INTO t2(f1) VALUES(1); @@ -266,7 +266,7 @@ DROP TABLE t1, t2; --let $datadir= `select @@datadir` SET @saved_dbug= @@GLOBAL.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; +set global debug_dbug= "d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; create table t1 ( pk serial, vb tinyblob as (b) virtual, b tinyblob, @@ -288,7 +288,7 @@ load data infile 'load.data' replace into table t1; --disable_warnings set debug_sync= "now WAIT_FOR latch_released TIMEOUT 1"; --enable_warnings -set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; +set global debug_dbug= @saved_dbug; drop table t1; --remove_file $datadir/test/load.data @@ -350,7 +350,7 @@ SET GLOBAL innodb_debug_sync = "ib_open_after_dict_open " # In 10.2 trx_undo_roll_ptr_is_insert(t_roll_ptr) condition never pass in purge, # so this condition is forced to pass in row_vers_old_has_index_entry SET @saved_dbug= @@GLOBAL.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_index_callback"; +set global debug_dbug= "d,ib_purge_virtual_index_callback"; # The purge starts from REPLACE command. To avoid possible race, separate # connection is used. diff --git a/mysql-test/suite/rpl/disabled.def b/mysql-test/suite/rpl/disabled.def index bdefb1660bd..62320ad027c 100644 --- a/mysql-test/suite/rpl/disabled.def +++ b/mysql-test/suite/rpl/disabled.def @@ -11,7 +11,7 @@ ############################################################################## rpl_spec_variables : BUG#11755836 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux -rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock +#rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock rpl_partition_archive : MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table rpl_row_binlog_max_cache_size : MDEV-11092 rpl_row_index_choice : MDEV-11666 diff --git a/mysql-test/suite/rpl/r/circular_serverid0.result b/mysql-test/suite/rpl/r/circular_serverid0.result index 928a0a48888..19c800cf01b 100644 --- a/mysql-test/suite/rpl/r/circular_serverid0.result +++ b/mysql-test/suite/rpl/r/circular_serverid0.result @@ -3,8 +3,8 @@ include/rpl_connect.inc [creating M4] include/rpl_connect.inc [creating M2] connection M2; STOP SLAVE; -SET @old_debug= @@global.debug; -SET GLOBAL debug_dbug= "+d,dbug.rows_events_to_delay_relay_logging"; +SET @old_debug= @@global.debug_dbug; +SET GLOBAL debug_dbug= "d,dbug.rows_events_to_delay_relay_logging"; START SLAVE IO_THREAD; include/wait_for_slave_io_to_start.inc connection M2; diff --git a/mysql-test/suite/rpl/r/rpl_binlog_errors.result b/mysql-test/suite/rpl/r/rpl_binlog_errors.result index 06be72d523b..32b158e7041 100644 --- a/mysql-test/suite/rpl/r/rpl_binlog_errors.result +++ b/mysql-test/suite/rpl/r/rpl_binlog_errors.result @@ -22,7 +22,7 @@ master-bin.000001 # master-bin.000002 # ###################### TEST #2 RESET MASTER; -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; FLUSH LOGS; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -30,7 +30,7 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) show binary logs; Log_name File_size master-bin.000001 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ###################### TEST #3 CREATE TABLE t1 (a INT); @@ -44,11 +44,11 @@ show binary logs; Log_name File_size master-bin.000001 # master-bin.000002 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #4 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -56,21 +56,21 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #5 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166-2.data' INTO TABLE t2; # assert: must show one entry SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #6 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET AUTOCOMMIT=0; INSERT INTO t2 VALUES ('muse'); LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; @@ -83,11 +83,11 @@ SELECT count(*) FROM t2; count(*) 3 SET AUTOCOMMIT= 1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #7 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET @@binlog_annotate_row_events= 0; SELECT count(*) FROM t4; count(*) @@ -100,14 +100,14 @@ SELECT count(*) FROM t4; count(*) 1 ### check that the incident event is written to the current log -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Incident # # #1 (LOST_EVENTS) DELETE FROM t4; RESET MASTER; ###################### TEST #8 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; # must show 0 entries SELECT count(*) FROM t4; count(*) @@ -147,9 +147,9 @@ count(*) SELECT count(*) FROM t2; count(*) 0 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #9 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET SQL_LOG_BIN=0; INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'); INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh'); @@ -170,17 +170,17 @@ SELECT count(*) FROM t4; count(*) 0 SET SQL_LOG_BIN=1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #10 call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Could not open .*"); RESET MASTER; SHOW WARNINGS; Level Code Message -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.000002' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; SHOW BINARY LOGS; ERROR HY000: You are not using binary logging CREATE TABLE t5 (a INT); @@ -192,10 +192,10 @@ DROP TABLE t5; flush tables; ###################### TEST #11 include/rpl_restart_server.inc [server_number=1] -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.index' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -207,10 +207,10 @@ DROP TABLE t5; flush tables; include/rpl_restart_server.inc [server_number=1] ###################### TEST #12 -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin' (errno: 2 "No such file or directory") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -237,44 +237,40 @@ call mtr.add_suppression("Could not open .*"); call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Can't generate a unique log-filename .*"); ###################### TEST #13 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,error_unique_log_filename"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #14 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_new_file_rotate_event"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #15 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_registering_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #16 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_openning_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] include/stop_slave_sql.inc Warnings: diff --git a/mysql-test/suite/rpl/r/rpl_corruption.result b/mysql-test/suite/rpl/r/rpl_corruption.result index f32b7c58ad1..73bb373d6be 100644 --- a/mysql-test/suite/rpl/r/rpl_corruption.result +++ b/mysql-test/suite/rpl/r/rpl_corruption.result @@ -13,42 +13,40 @@ connection master; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100)); include/stop_slave.inc # 2. Corruption in master binlog and SHOW BINLOG EVENTS -set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @saved_dbug = @@global.debug_dbug; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; SHOW BINLOG EVENTS; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; +SET @@global.debug_dbug=@saved_dbug; # 3. Master read a corrupted event from binlog and send the error to slave -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1236] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug=@saved_dbug; # 4. Master read a corrupted event from binlog and send it to slave connection master; SET GLOBAL master_verify_checksum=0; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; -SET GLOBAL debug_dbug=@saved_dbug; +SET @@global.debug_dbug=@saved_dbug; SET GLOBAL master_verify_checksum=1; # 5. Slave. Corruption in network connection slave; SET @saved_dbug_slave = @@GLOBAL.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_queue_event"; +SET @@global.debug_dbug="d,corrupt_queue_event"; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] -SET GLOBAL debug_dbug="-d,corrupt_queue_event"; +SET @@global.debug_dbug=@saved_dbug_slave; # 6. Slave. Corruption in relay log -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; START SLAVE SQL_THREAD; include/wait_for_slave_sql_error.inc [errno=1593] -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; -SET GLOBAL debug_dbug=@saved_dbug_slave; +SET @@global.debug_dbug=@saved_dbug_slave; # 7. Seek diff for tables on master and slave connection slave; include/start_slave.inc diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result index b8415977154..feef82a57fc 100644 --- a/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result +++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result @@ -27,7 +27,7 @@ include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : SET @saved_dbug = @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; START TRANSACTION; INSERT INTO t1 VALUES(2); @@ -43,7 +43,7 @@ include/wait_for_slave_io_error.inc [errno=1595] SELECT * FROM t1; i 1 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; include/wait_for_slave_io_to_start.inc SELECT * FROM t1; @@ -61,7 +61,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : 1 -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; START TRANSACTION; INSERT INTO t1 VALUES(4); @@ -81,7 +81,7 @@ i 1 2 3 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; include/wait_for_slave_io_to_start.inc SELECT * FROM t1; @@ -99,7 +99,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; START TRANSACTION; INSERT INTO t1 VALUES(6); @@ -134,7 +134,7 @@ i 1 2 3 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : @@ -159,7 +159,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : 1 -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; SET @@session.gtid_domain_id= 1; START TRANSACTION; @@ -203,7 +203,7 @@ i 3 10 11 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : 1 @@ -232,7 +232,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : 1 -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; SET @@session.gtid_domain_id= 1; START TRANSACTION; @@ -286,7 +286,7 @@ i 15 16 17 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : 1 @@ -319,7 +319,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; SET @@session.gtid_domain_id= 1; START TRANSACTION; @@ -383,7 +383,7 @@ i 21 22 23 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : diff --git a/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result index e7f4e566566..deea7caa12a 100644 --- a/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result +++ b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result @@ -1,33 +1,42 @@ include/master-slave.inc [connection master] +connection slave; call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: .*"); call mtr.add_suppression("Slave I/O: .* failed with error: Lost connection to MySQL server at 'reading initial communication packet'"); call mtr.add_suppression("Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; .*"); call mtr.add_suppression("Slave I/O thread .* register on master"); +SET @saved_dbug = @@GLOBAL.debug_dbug; +connection slave; include/stop_slave.inc -SET @@global.debug= "+d,'debug_lock.before_get_UNIX_TIMESTAMP'"; +SET @old_dbug = @@global.debug_dbug; +SET @@global.debug_dbug= "d,'debug_lock.before_get_UNIX_TIMESTAMP'"; include/start_slave.inc slave is going to hang in get_master_version_and_clock include/rpl_stop_server.inc [server_number=1] slave is unblocked SET DEBUG_SYNC='now SIGNAL signal.get_unix_timestamp'; +connection slave; Check network error happened here include/wait_for_slave_io_error.inc [errno=1053, 2002, 2003, 2006, 2013] -set @@global.debug = "-d,'debug_lock.before_get_UNIX_TIMESTAMP'"; +set @@global.debug_dbug= @old_dbug; include/rpl_start_server.inc [server_number=1] include/wait_for_slave_param.inc [Slave_IO_Running] +connection slave; +connection slave; include/stop_slave.inc -SET @@global.debug= "+d,'debug_lock.before_get_SERVER_ID'"; +SET @old_dbug = @@global.debug_dbug; +SET @@global.debug_dbug= "d,'debug_lock.before_get_SERVER_ID'"; include/start_slave.inc slave is going to hang in get_master_version_and_clock include/rpl_stop_server.inc [server_number=1] slave is unblocked SET DEBUG_SYNC='now SIGNAL signal.get_server_id'; +connection slave; Check network error happened here include/wait_for_slave_io_error.inc [errno=1053, 2002, 2003, 2006, 2013] -set @@global.debug = "-d,'debug_lock.before_get_SERVER_ID'"; +set @@global.debug_dbug= @old_dbug; include/rpl_start_server.inc [server_number=1] include/wait_for_slave_param.inc [Slave_IO_Running] -set global debug= ''; +SET @@GLOBAL.debug_dbug = @saved_dbug; SET DEBUG_SYNC= 'RESET'; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_gtid_strict.result b/mysql-test/suite/rpl/r/rpl_gtid_strict.result index 528c4c5b5c1..27e7d105125 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_strict.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_strict.result @@ -27,16 +27,17 @@ master-bin.000001 # Xid # # COMMIT /* XID */ SET server_id= 3; SET gtid_seq_no= 3; ERROR HY000: An attempt was made to binlog GTID 0-3-3 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET @old_dbug = @@session.debug_dbug; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 3; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; INSERT INTO t1 VALUES (2); ERROR HY000: An attempt was made to binlog GTID 0-3-3 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled SET gtid_seq_no= 2; ERROR HY000: An attempt was made to binlog GTID 0-3-2 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 2; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; INSERT INTO t1 VALUES (3); ERROR HY000: An attempt was made to binlog GTID 0-3-2 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled SET server_id= 1; @@ -62,9 +63,9 @@ master-bin.000001 # Xid # # COMMIT /* XID */ SET server_id= 3; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled SET sql_log_bin= 0; @@ -73,9 +74,9 @@ SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-3-5, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; INSERT INTO t2 VALUES (1); ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-3-5, and gtid strict mode is enabled SET server_id= 1; diff --git a/mysql-test/suite/rpl/r/rpl_row_corruption.result b/mysql-test/suite/rpl/r/rpl_row_corruption.result index b5bdc32200a..24535460418 100644 --- a/mysql-test/suite/rpl/r/rpl_row_corruption.result +++ b/mysql-test/suite/rpl/r/rpl_row_corruption.result @@ -7,15 +7,15 @@ INSERT INTO t2_11753004 VALUES (2); connection slave; call mtr.add_suppression(".*Found table map event mapping table id 0 which was already mapped but with different settings.*"); include/stop_slave.inc -SET @save_debug= @@global.debug; -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @saved_debug= @@global.debug_dbug; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; include/start_slave.inc connection master; UPDATE t1_11753004, t2_11753004 SET t1_11753004.c1=3, t2_11753004.c1=4 WHERE t1_11753004.c1=1 OR t2_11753004.c1=2; connection slave; include/wait_for_slave_sql_error.inc [errno=1593 ] include/stop_slave.inc -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; include/start_slave.inc connection master; include/rpl_reset.inc @@ -23,7 +23,7 @@ DROP TABLE t1_11753004, t2_11753004; connection slave; connection slave; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; include/start_slave.inc include/rpl_reset.inc connection master; @@ -41,7 +41,7 @@ BINLOG ' SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8= '/*!*/; -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; BINLOG ' SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE= SOgWThMBAAAAKQAAAC8DAAAAAEMAAAAAAAEABHRlc3QAAnQyAAEDAAE= @@ -51,10 +51,10 @@ SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA== ERROR HY000: Fatal error: Found table map event mapping table id 0 which was already mapped but with different settings. DROP TABLE t1,t2; connection slave; -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; connection master; DROP TABLE t1_11753004; DROP TABLE t2_11753004_ign; connection slave; -SET GLOBAL debug_dbug= @save_debug; +SET @@global.debug_dbug= @save_debug; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result b/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result index b670a16bfcd..0afe1992fb9 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result +++ b/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result @@ -7,7 +7,7 @@ create table tm (a int auto_increment primary key) engine=myisam; create table ti (a int auto_increment primary key) engine=innodb; connection slave; SET @saved_dbug = @@GLOBAL.debug_dbug; -set @@global.debug_dbug="+d,stop_slave_middle_group"; +set @@global.debug_dbug="d,stop_slave_middle_group"; connection master; begin; insert into ti set a=null; @@ -28,14 +28,13 @@ one select count(*) as one from ti; one 1 -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; include/start_slave.inc connection master; truncate table tm; truncate table ti; connection slave; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; begin; insert into ti set a=null; @@ -54,14 +53,13 @@ one select count(*) as zero from ti; zero 0 -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; stop slave; truncate table tm; include/start_slave.inc connection master; connection slave; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2; connection slave; diff --git a/mysql-test/suite/rpl/t/circular_serverid0.test b/mysql-test/suite/rpl/t/circular_serverid0.test index 097a2932404..64cf231c2c2 100644 --- a/mysql-test/suite/rpl/t/circular_serverid0.test +++ b/mysql-test/suite/rpl/t/circular_serverid0.test @@ -24,8 +24,8 @@ --connection M2 STOP SLAVE; -SET @old_debug= @@global.debug; -SET GLOBAL debug_dbug= "+d,dbug.rows_events_to_delay_relay_logging"; +SET @old_debug= @@global.debug_dbug; +SET GLOBAL debug_dbug= "d,dbug.rows_events_to_delay_relay_logging"; START SLAVE IO_THREAD; --source include/wait_for_slave_io_to_start.inc diff --git a/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt b/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt deleted file mode 100644 index 37fc56036fb..00000000000 --- a/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=-d,simulate_find_log_pos_error diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test index f3ba39fb330..a949da0cc25 100644 --- a/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test +++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test @@ -36,7 +36,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after SET @saved_dbug = @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -51,7 +51,7 @@ connection slave; --let $slave_io_errno= 1595 --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; --source include/wait_for_slave_io_to_start.inc @@ -77,7 +77,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -93,7 +93,7 @@ connection slave; --let $slave_io_errno= 1595 --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; --source include/wait_for_slave_io_to_start.inc @@ -119,7 +119,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -148,7 +148,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); @@ -186,7 +186,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -216,7 +216,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); @@ -254,7 +254,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; @@ -284,7 +284,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); @@ -322,7 +322,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; @@ -352,7 +352,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); diff --git a/mysql-test/suite/rpl/t/rpl_gtid_strict.test b/mysql-test/suite/rpl/t/rpl_gtid_strict.test index afcb179da78..56ebba824c4 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_strict.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_strict.test @@ -29,17 +29,18 @@ INSERT INTO t1 VALUES (1); SET server_id= 3; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 3; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET @old_dbug = @@session.debug_dbug; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 3; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER INSERT INTO t1 VALUES (2); --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 2; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 2; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER INSERT INTO t1 VALUES (3); SET server_id= 1; @@ -52,9 +53,9 @@ SELECT * FROM t1 ORDER BY 1; SET server_id= 3; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 1; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; # The table is still created, DDL cannot be rolled back. @@ -66,9 +67,9 @@ CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 1; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER INSERT INTO t2 VALUES (1); # The value is still inserted, cannot be rolled back. diff --git a/mysql-test/suite/rpl/t/rpl_row_corruption.test b/mysql-test/suite/rpl/t/rpl_row_corruption.test index acf3964f0c5..d78df905ccb 100644 --- a/mysql-test/suite/rpl/t/rpl_row_corruption.test +++ b/mysql-test/suite/rpl/t/rpl_row_corruption.test @@ -27,8 +27,8 @@ call mtr.add_suppression(".*Found table map event mapping table id 0 which was a # stop the slave and inject corruption --source include/stop_slave.inc -SET @save_debug= @@global.debug; -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @saved_debug= @@global.debug_dbug; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; --source include/start_slave.inc --connection master # both tables get mapped to 0 (in a way, simulating scenario @@ -42,7 +42,7 @@ SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; --source include/stop_slave.inc # clean up -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; --source include/start_slave.inc --connection master --source include/rpl_reset.inc @@ -55,7 +55,7 @@ SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; --connection slave --source include/stop_slave.inc -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; --source include/start_slave.inc --source include/rpl_reset.inc --connection master @@ -92,7 +92,7 @@ AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8= #110708 12:21:44 server id 1 end_log_pos 855 Update_rows: table id 66 # at 855 #110708 12:21:44 server id 1 end_log_pos 895 Update_rows: table id 67 flags: STMT_END_F -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; --error ER_SLAVE_FATAL_ERROR BINLOG ' SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE= @@ -105,11 +105,11 @@ SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA== # clean up DROP TABLE t1,t2; --connection slave -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; --connection master --eval DROP TABLE $t1 --eval DROP TABLE $t2_ign --sync_slave_with_master -SET GLOBAL debug_dbug= @save_debug; +SET @@global.debug_dbug= @save_debug; --source include/rpl_end.inc From 82b3f1a80fed2df9d46f12978bbded2bca0e758d Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 19 Mar 2020 00:29:44 +0100 Subject: [PATCH 11/18] MDEV-21930 RocksDB does not compile anymore, with Visual Studio Update submodule, change the source file list rename CACHE_LINE_SIZE in ut0counter, so it does not conflics with rocksdb sources, which also defines this constant now. --- storage/rocksdb/build_rocksdb.cmake | 89 +++++++++++++++++------------ storage/rocksdb/rdb_sst_info.cc | 2 +- storage/rocksdb/rocksdb | 2 +- storage/rocksdb/ut0counter.h | 12 ++-- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake index 70b7c97f69c..115af45fec3 100644 --- a/storage/rocksdb/build_rocksdb.cmake +++ b/storage/rocksdb/build_rocksdb.cmake @@ -60,10 +60,10 @@ if(BZIP2_FOUND AND (NOT WITH_ROCKSDB_BZIP2 STREQUAL "OFF")) list(APPEND THIRDPARTY_LIBS ${BZIP2_LIBRARIES}) endif() -if(SNAPPY_FOUND AND (NOT WITH_ROCKSDB_SNAPPY STREQUAL "OFF")) +if(snappy_FOUND AND (NOT WITH_ROCKSDB_SNAPPY STREQUAL "OFF")) add_definitions(-DSNAPPY) - include_directories(${SNAPPY_INCLUDE_DIR}) - list(APPEND THIRDPARTY_LIBS ${SNAPPY_LIBRARIES}) + include_directories(${snappy_INCLUDE_DIR}) + list(APPEND THIRDPARTY_LIBS ${snappy_LIBRARIES}) endif() include(CheckFunctionExists) @@ -189,31 +189,32 @@ set(ROCKSDB_SOURCES cache/clock_cache.cc cache/lru_cache.cc cache/sharded_cache.cc + db/arena_wrapped_db_iter.cc db/builder.cc db/c.cc db/column_family.cc db/compacted_db_impl.cc db/compaction/compaction.cc db/compaction/compaction_iterator.cc - db/compaction/compaction_job.cc db/compaction/compaction_picker.cc + db/compaction/compaction_job.cc db/compaction/compaction_picker_fifo.cc db/compaction/compaction_picker_level.cc db/compaction/compaction_picker_universal.cc db/convenience.cc db/db_filesnapshot.cc - db/dbformat.cc db/db_impl/db_impl.cc + db/db_impl/db_impl_write.cc db/db_impl/db_impl_compaction_flush.cc - db/db_impl/db_impl_debug.cc - db/db_impl/db_impl_experimental.cc db/db_impl/db_impl_files.cc db/db_impl/db_impl_open.cc + db/db_impl/db_impl_debug.cc + db/db_impl/db_impl_experimental.cc db/db_impl/db_impl_readonly.cc db/db_impl/db_impl_secondary.cc - db/db_impl/db_impl_write.cc db/db_info_dumper.cc db/db_iter.cc + db/dbformat.cc db/error_handler.cc db/event_helpers.cc db/experimental.cc @@ -222,9 +223,10 @@ set(ROCKSDB_SOURCES db/flush_job.cc db/flush_scheduler.cc db/forward_iterator.cc + db/import_column_family_job.cc db/internal_stats.cc - db/log_reader.cc db/logs_with_prep_tracker.cc + db/log_reader.cc db/log_writer.cc db/malloc_stats.cc db/memtable.cc @@ -238,22 +240,31 @@ set(ROCKSDB_SOURCES db/table_cache.cc db/table_properties_collector.cc db/transaction_log_impl.cc + db/trim_history_scheduler.cc db/version_builder.cc db/version_edit.cc db/version_set.cc db/wal_manager.cc - db/write_batch_base.cc db/write_batch.cc + db/write_batch_base.cc db/write_controller.cc db/write_thread.cc env/env.cc env/env_chroot.cc + env/env_encryption.cc env/env_hdfs.cc + env/file_system.cc env/mock_env.cc file/delete_scheduler.cc - file/filename.cc + file/file_prefetch_buffer.cc file/file_util.cc + file/filename.cc + file/random_access_file_reader.cc + file/read_write_util.cc + file/readahead_raf.cc + file/sequence_file_reader.cc file/sst_file_manager_impl.cc + file/writable_file_writer.cc logging/auto_roll_logger.cc logging/event_logger.cc logging/log_buffer.cc @@ -268,8 +279,8 @@ set(ROCKSDB_SOURCES memtable/write_buffer_manager.cc monitoring/histogram.cc monitoring/histogram_windowing.cc - monitoring/instrumented_mutex.cc monitoring/in_memory_stats_history.cc + monitoring/instrumented_mutex.cc monitoring/iostats_context.cc monitoring/perf_context.cc monitoring/perf_level.cc @@ -277,7 +288,6 @@ set(ROCKSDB_SOURCES monitoring/statistics.cc monitoring/thread_status_impl.cc monitoring/thread_status_updater.cc - monitoring/thread_status_updater_debug.cc monitoring/thread_status_util.cc monitoring/thread_status_util_debug.cc options/cf_options.cc @@ -288,21 +298,24 @@ set(ROCKSDB_SOURCES options/options_sanity_check.cc port/stack_trace.cc table/adaptive/adaptive_table_factory.cc + table/block_based/block.cc table/block_based/block_based_filter_block.cc table/block_based/block_based_table_builder.cc table/block_based/block_based_table_factory.cc table/block_based/block_based_table_reader.cc table/block_based/block_builder.cc - table/block_based/block.cc table/block_based/block_prefix_index.cc - table/block_based/data_block_footer.cc table/block_based/data_block_hash_index.cc + table/block_based/data_block_footer.cc + table/block_based/filter_block_reader_common.cc + table/block_based/filter_policy.cc table/block_based/flush_block_policy.cc table/block_based/full_filter_block.cc table/block_based/index_builder.cc + table/block_based/parsed_full_filter_block.cc table/block_based/partitioned_filter_block.cc + table/block_based/uncompression_dict_reader.cc table/block_fetcher.cc - table/bloom_block.cc table/cuckoo/cuckoo_table_builder.cc table/cuckoo/cuckoo_table_factory.cc table/cuckoo/cuckoo_table_reader.cc @@ -312,6 +325,7 @@ set(ROCKSDB_SOURCES table/merging_iterator.cc table/meta_blocks.cc table/persistent_cache_helper.cc + table/plain/plain_table_bloom.cc table/plain/plain_table_builder.cc table/plain/plain_table_factory.cc table/plain/plain_table_index.cc @@ -323,23 +337,34 @@ set(ROCKSDB_SOURCES table/two_level_iterator.cc test_util/sync_point.cc test_util/sync_point_impl.cc + test_util/testutil.cc + test_util/transaction_test_util.cc + tools/block_cache_analyzer/block_cache_trace_analyzer.cc + tools/dump/db_dump_tool.cc tools/ldb_cmd.cc tools/ldb_tool.cc tools/sst_dump_tool.cc - trace_replay/block_cache_tracer.cc + tools/trace_analyzer_tool.cc trace_replay/trace_replay.cc - util/bloom.cc + trace_replay/block_cache_tracer.cc util/coding.cc util/compaction_job_stats_impl.cc util/comparator.cc util/compression_context_cache.cc util/concurrent_task_limiter_impl.cc - util/crc32c_arm64.cc util/crc32c.cc util/dynamic_bloom.cc - util/file_reader_writer.cc - util/filter_policy.cc util/hash.cc + util/murmurhash.cc + util/random.cc + util/rate_limiter.cc + util/slice.cc + util/file_checksum_helper.cc + util/status.cc + util/string_util.cc + util/thread_local.cc + util/threadpool_imp.cc + util/xxhash.cc utilities/backupable/backupable_db.cc utilities/blob_db/blob_compaction_filter.cc utilities/blob_db/blob_db.cc @@ -347,12 +372,11 @@ set(ROCKSDB_SOURCES utilities/blob_db/blob_db_impl_filesnapshot.cc utilities/blob_db/blob_dump_tool.cc utilities/blob_db/blob_file.cc - utilities/blob_db/blob_log_format.cc utilities/blob_db/blob_log_reader.cc utilities/blob_db/blob_log_writer.cc + utilities/blob_db/blob_log_format.cc utilities/checkpoint/checkpoint_impl.cc utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc - utilities/convenience/info_log_finder.cc utilities/debug.cc utilities/env_mirror.cc utilities/env_timed.cc @@ -361,9 +385,11 @@ set(ROCKSDB_SOURCES utilities/merge_operators/bytesxor.cc utilities/merge_operators/max.cc utilities/merge_operators/put.cc - utilities/merge_operators/string_append/stringappend2.cc + utilities/merge_operators/sortlist.cc utilities/merge_operators/string_append/stringappend.cc + utilities/merge_operators/string_append/stringappend2.cc utilities/merge_operators/uint64add.cc + utilities/object_registry.cc utilities/option_change_migration/option_change_migration.cc utilities/options/options_util.cc utilities/persistent_cache/block_cache_tier.cc @@ -371,11 +397,12 @@ set(ROCKSDB_SOURCES utilities/persistent_cache/block_cache_tier_metadata.cc utilities/persistent_cache/persistent_cache_tier.cc utilities/persistent_cache/volatile_tier_impl.cc + utilities/simulator_cache/cache_simulator.cc utilities/simulator_cache/sim_cache.cc utilities/table_properties_collectors/compact_on_deletion_collector.cc utilities/trace/file_trace_reader_writer.cc - utilities/transactions/optimistic_transaction.cc utilities/transactions/optimistic_transaction_db_impl.cc + utilities/transactions/optimistic_transaction.cc utilities/transactions/pessimistic_transaction.cc utilities/transactions/pessimistic_transaction_db.cc utilities/transactions/snapshot_checker.cc @@ -390,15 +417,6 @@ set(ROCKSDB_SOURCES utilities/ttl/db_ttl_impl.cc utilities/write_batch_with_index/write_batch_with_index.cc utilities/write_batch_with_index/write_batch_with_index_internal.cc - util/murmurhash.cc - util/random.cc - util/rate_limiter.cc - util/slice.cc - util/status.cc - util/string_util.cc - util/thread_local.cc - util/threadpool_imp.cc - util/xxhash.cc ) @@ -415,7 +433,8 @@ else() list(APPEND ROCKSDB_SOURCES port/port_posix.cc env/env_posix.cc - env/io_posix.cc) + env/io_posix.cc + env/fs_posix.cc) # ppc64 or ppc64le if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64") enable_language(ASM) diff --git a/storage/rocksdb/rdb_sst_info.cc b/storage/rocksdb/rdb_sst_info.cc index 8b7886667eb..f7e944c2e39 100644 --- a/storage/rocksdb/rdb_sst_info.cc +++ b/storage/rocksdb/rdb_sst_info.cc @@ -507,7 +507,7 @@ void Rdb_sst_info::set_error_msg(const std::string &sst_file_name, void Rdb_sst_info::report_error_msg(const rocksdb::Status &s, const char *sst_file_name) { if (s.IsInvalidArgument() && - strcmp(s.getState(), "Keys must be added in order") == 0) { + strcmp(s.getState(), "Keys must be added in strict ascending order.") == 0) { my_printf_error(ER_KEYS_OUT_OF_ORDER, "Rows must be inserted in primary key order " "during bulk load operation", diff --git a/storage/rocksdb/rocksdb b/storage/rocksdb/rocksdb index e731f440225..bba5e7bc210 160000 --- a/storage/rocksdb/rocksdb +++ b/storage/rocksdb/rocksdb @@ -1 +1 @@ -Subproject commit e731f4402258554812c46334dc0d9483e6cc769b +Subproject commit bba5e7bc21093d7cfa765e1280a7c4fdcd284288 diff --git a/storage/rocksdb/ut0counter.h b/storage/rocksdb/ut0counter.h index cfa474e7a99..3a7ee85d01c 100644 --- a/storage/rocksdb/ut0counter.h +++ b/storage/rocksdb/ut0counter.h @@ -23,7 +23,7 @@ Created 2012/04/12 by Sunny Bains #include /** CPU cache line size */ -#define CACHE_LINE_SIZE 64 +#define UT_CACHE_LINE_SIZE 64 /** Default number of slots to use in ib_counter_t */ #define IB_N_SLOTS 64 @@ -43,7 +43,7 @@ struct generic_indexer_t { /** @return offset within m_counter */ size_t offset(size_t index) const { - return(((index % N) + 1) * (CACHE_LINE_SIZE / sizeof(Type))); + return(((index % N) + 1) * (UT_CACHE_LINE_SIZE / sizeof(Type))); } }; @@ -90,7 +90,7 @@ struct single_indexer_t { /** @return offset within m_counter */ size_t offset(size_t index) const { DBUG_ASSERT(N == 1); - return((CACHE_LINE_SIZE / sizeof(Type))); + return((UT_CACHE_LINE_SIZE / sizeof(Type))); } /* @return 1 */ @@ -103,7 +103,7 @@ struct single_indexer_t { /** Class for using fuzzy counters. The counter is not protected by any mutex and the results are not guaranteed to be 100% accurate but close enough. Creates an array of counters and separates each element by the -CACHE_LINE_SIZE bytes */ +UT_CACHE_LINE_SIZE bytes */ template < typename Type, int N = IB_N_SLOTS, @@ -119,7 +119,7 @@ public: bool validate() { #ifdef UNIV_DEBUG - size_t n = (CACHE_LINE_SIZE / sizeof(Type)); + size_t n = (UT_CACHE_LINE_SIZE / sizeof(Type)); /* Check that we aren't writing outside our defined bounds. */ for (size_t i = 0; i < UT_ARRAY_SIZE(m_counter); i += n) { @@ -197,7 +197,7 @@ private: Indexerm_policy; /** Slot 0 is unused. */ - Type m_counter[(N + 1) * (CACHE_LINE_SIZE / sizeof(Type))]; + Type m_counter[(N + 1) * (UT_CACHE_LINE_SIZE / sizeof(Type))]; }; #endif /* UT0COUNTER_H */ From 1e6be6938059d230903029fa99ad6504c53d90ea Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 23 Mar 2020 01:38:11 +0300 Subject: [PATCH 12/18] MDEV-19658 UBSAN: runtime error: load of value 2779096485, which is not a valid value for type 'enum_binlog_format' This is an uninitialized read. THD::THD: initialize current_stmt_binlog_format member --- sql/sql_class.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 5cb788296c4..97d609d6f1f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2018, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -604,6 +604,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) m_current_stage_key(0), in_sub_stmt(0), log_all_errors(0), binlog_unsafe_warning_flags(0), + current_stmt_binlog_format(BINLOG_FORMAT_MIXED), binlog_table_maps(0), bulk_param(0), table_map_for_update(0), From 6697135c6d03935118c3dfa1c97faea7fa76afa6 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 23 Mar 2020 16:37:44 +0530 Subject: [PATCH 13/18] MDEV-21572 buf_page_get_gen() should apply buffered page initialized redo log during recovery - InnoDB unnecessarily reads the page even though it has fully initialized buffered redo log records. Allow the page initialization redo log to apply for the page in buf_page_get_gen() during recovery. - Renamed buf_page_get_gen() to buf_page_get_low() - Newly added buf_page_get_gen() will check for buffered redo log for the particular page id during recovery - Added new function buf_page_mtr_lock() which basically latches the page for the given latch type. - recv_recovery_create_page() is inline function which creates a page if it has page initialization redo log records. --- .../innodb/r/corrupted_during_recovery.result | 16 ++ .../innodb/t/corrupted_during_recovery.test | 28 +++ storage/innobase/buf/buf0buf.cc | 108 +++++++---- storage/innobase/include/buf0buf.h | 24 +++ storage/innobase/include/log0recv.h | 18 ++ storage/innobase/log/log0recv.cc | 171 ++++++++++-------- 6 files changed, 261 insertions(+), 104 deletions(-) diff --git a/mysql-test/suite/innodb/r/corrupted_during_recovery.result b/mysql-test/suite/innodb/r/corrupted_during_recovery.result index ee4db08fc85..951233ced3c 100644 --- a/mysql-test/suite/innodb/r/corrupted_during_recovery.result +++ b/mysql-test/suite/innodb/r/corrupted_during_recovery.result @@ -17,3 +17,19 @@ CHECK TABLE t2; Table Op Msg_type Msg_text test.t2 check status OK DROP TABLE t1, t2; +CREATE TABLE t1(pk SERIAL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); +connect con1,localhost,root,,; +BEGIN; +DELETE FROM t1 WHERE pk=1; +connection default; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +DELETE FROM t1 WHERE pk=3; +# Kill the server +disconnect con1; +# Corrupt the pages +SELECT * FROM t1; +pk +1 +2 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/corrupted_during_recovery.test b/mysql-test/suite/innodb/t/corrupted_during_recovery.test index dad08645085..67f2f2dde40 100644 --- a/mysql-test/suite/innodb/t/corrupted_during_recovery.test +++ b/mysql-test/suite/innodb/t/corrupted_during_recovery.test @@ -62,3 +62,31 @@ SELECT * FROM t2; CHECK TABLE t2; DROP TABLE t1, t2; + +# MDEV-21572 buf_page_get_gen() should apply buffered page +# initialized redo log during recovery +--source ../include/no_checkpoint_start.inc +CREATE TABLE t1(pk SERIAL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); +connect (con1,localhost,root,,); +BEGIN; +DELETE FROM t1 WHERE pk=1; +connection default; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +DELETE FROM t1 WHERE pk=3; +--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1; +--source ../include/no_checkpoint_end.inc +disconnect con1; + +--echo # Corrupt the pages +perl; +my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; +open(FILE, "+<$file") || die "Unable to open $file"; +binmode FILE; +seek (FILE, $ENV{INNODB_PAGE_SIZE} * 3, SEEK_SET) or die "seek"; +print FILE "junk"; +close FILE or die "close"; +EOF +--source include/start_mysqld.inc +SELECT * FROM t1; +DROP TABLE t1; diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index ad0f40ce67e..954b16eb2d2 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -4190,7 +4190,45 @@ buf_wait_for_read( } } -/** This is the general function used to get access to a database page. +/** Lock the page with the given latch type. +@param[in,out] block block to be locked +@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] mtr mini-transaction +@param[in] file file name +@param[in] line line where called +@return pointer to locked block */ +static buf_block_t* buf_page_mtr_lock(buf_block_t *block, + ulint rw_latch, + mtr_t* mtr, + const char *file, + unsigned line) +{ + mtr_memo_type_t fix_type; + switch (rw_latch) + { + case RW_NO_LATCH: + fix_type= MTR_MEMO_BUF_FIX; + break; + case RW_S_LATCH: + rw_lock_s_lock_inline(&block->lock, 0, file, line); + fix_type= MTR_MEMO_PAGE_S_FIX; + break; + case RW_SX_LATCH: + rw_lock_sx_lock_inline(&block->lock, 0, file, line); + fix_type= MTR_MEMO_PAGE_SX_FIX; + break; + default: + ut_ad(rw_latch == RW_X_LATCH); + rw_lock_x_lock_inline(&block->lock, 0, file, line); + fix_type= MTR_MEMO_PAGE_X_FIX; + break; + } + + mtr_memo_push(mtr, block, fix_type); + return block; +} + +/** This is the low level function used to get access to a database page. @param[in] page_id page id @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @@ -4201,7 +4239,7 @@ BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH @param[in] mtr mini-transaction @return pointer to the block or NULL */ buf_block_t* -buf_page_get_gen( +buf_page_get_low( const page_id_t page_id, const page_size_t& page_size, ulint rw_latch, @@ -4844,35 +4882,7 @@ evict_from_pool: return NULL; } - mtr_memo_type_t fix_type; - - switch (rw_latch) { - case RW_NO_LATCH: - - fix_type = MTR_MEMO_BUF_FIX; - break; - - case RW_S_LATCH: - rw_lock_s_lock_inline(&fix_block->lock, 0, file, line); - - fix_type = MTR_MEMO_PAGE_S_FIX; - break; - - case RW_SX_LATCH: - rw_lock_sx_lock_inline(&fix_block->lock, 0, file, line); - - fix_type = MTR_MEMO_PAGE_SX_FIX; - break; - - default: - ut_ad(rw_latch == RW_X_LATCH); - rw_lock_x_lock_inline(&fix_block->lock, 0, file, line); - - fix_type = MTR_MEMO_PAGE_X_FIX; - break; - } - - mtr_memo_push(mtr, fix_block, fix_type); + fix_block = buf_page_mtr_lock(fix_block, rw_latch, mtr, file, line); if (mode != BUF_PEEK_IF_IN_POOL && !access_time) { /* In the case of a first access, try to apply linear @@ -4887,6 +4897,42 @@ evict_from_pool: return(fix_block); } +/** This is the general function used to get access to a database page. +It does page initialization and applies the buffered redo logs. +@param[in] page_id page id +@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] guess guessed block or NULL +@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, +BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH +@param[in] file file name +@param[in] line line where called +@param[in] mtr mini-transaction +@param[out] err DB_SUCCESS or error code +@return pointer to the block or NULL */ +buf_block_t* +buf_page_get_gen( + const page_id_t page_id, + const page_size_t& page_size, + ulint rw_latch, + buf_block_t* guess, + ulint mode, + const char* file, + unsigned line, + mtr_t* mtr, + dberr_t* err) +{ + if (buf_block_t *block = recv_recovery_create_page(page_id)) + { + buf_block_fix(block); + ut_ad(rw_lock_s_lock_nowait(&block->debug_latch, file, line)); + block= buf_page_mtr_lock(block, rw_latch, mtr, file, line); + return block; + } + + return buf_page_get_low(page_id, page_size, rw_latch, + guess, mode, file, line, mtr, err); +} + /********************************************************************//** This is the general function used to get optimistic access to a database page. diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index a04936a19cf..d120dc36091 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -436,6 +436,7 @@ buf_page_get_zip( const page_size_t& page_size); /** This is the general function used to get access to a database page. +It does page initialization and applies the buffered redo logs. @param[in] page_id page id @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @@ -458,6 +459,29 @@ buf_page_get_gen( mtr_t* mtr, dberr_t* err); +/** This is the low level function used to get access to a database page. +@param[in] page_id page id +@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] guess guessed block or NULL +@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, +BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH +@param[in] file file name +@param[in] line line where called +@param[in] mtr mini-transaction +@param[out] err DB_SUCCESS or error code +@return pointer to the block or NULL */ +buf_block_t* +buf_page_get_low( + const page_id_t page_id, + const page_size_t& page_size, + ulint rw_latch, + buf_block_t* guess, + ulint mode, + const char* file, + unsigned line, + mtr_t* mtr, + dberr_t* err); + /** Initializes a page to the buffer buf_pool. The page is usually not read from a file even if it cannot be found in the buffer buf_pool. This is one of the functions which perform to a block a state transition NOT_USED => diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 068d7813c20..b91312e81e2 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -342,4 +342,22 @@ times! */ roll-forward */ #define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE) +/** This is a low level function for the recovery system +to create a page which has buffered intialized redo log records. +@param[in] page_id page to be created using redo logs +@return whether the page creation successfully */ +buf_block_t* recv_recovery_create_page_low(const page_id_t page_id); + +/** Recovery system creates a page which has buffered intialized +redo log records. +@param[in] page_id page to be created using redo logs +@return block which contains page was initialized */ +inline buf_block_t* recv_recovery_create_page(const page_id_t page_id) +{ + if (UNIV_LIKELY(!recv_recovery_on)) + return NULL; + + return recv_recovery_create_page_low(page_id); +} + #endif diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 01f8e3636bc..73230def4a1 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -313,7 +313,7 @@ public: if (!i->second.created) { continue; } - if (buf_block_t* block = buf_page_get_gen( + if (buf_block_t* block = buf_page_get_low( i->first, univ_page_size, RW_X_LATCH, NULL, BUF_GET_IF_IN_POOL, __FILE__, __LINE__, &mtr, NULL)) { @@ -2293,6 +2293,99 @@ static void recv_read_in_area(const page_id_t page_id) mutex_enter(&recv_sys->mutex); } +/** This is another low level function for the recovery system +to create a page which has buffered page intialization redo log records. +@param[in] page_id page to be created using redo logs +@param[in,out] recv_addr Hashed redo logs for the given page id +@return whether the page creation successfully */ +static buf_block_t* recv_recovery_create_page_low(const page_id_t page_id, + recv_addr_t* recv_addr) +{ + mtr_t mtr; + mlog_init_t::init& i = mlog_init.last(page_id); + const lsn_t end_lsn = UT_LIST_GET_LAST(recv_addr->rec_list)->end_lsn; + + if (end_lsn < i.lsn) + { + DBUG_LOG("ib_log", "skip log for page " + << page_id + << " LSN " << end_lsn + << " < " << i.lsn); + recv_addr->state = RECV_PROCESSED; +ignore: + ut_a(recv_sys->n_addrs); + recv_sys->n_addrs--; + return NULL; + } + + fil_space_t* space = fil_space_acquire(recv_addr->space); + if (!space) + { + recv_addr->state = RECV_PROCESSED; + goto ignore; + } + + if (space->enable_lsn) + { +init_fail: + fil_space_release(space); + recv_addr->state = RECV_NOT_PROCESSED; + return NULL; + } + + /* Determine if a tablespace could be for an internal table + for FULLTEXT INDEX. For those tables, no MLOG_INDEX_LOAD record + used to be written when redo logging was disabled. Hence, we + cannot optimize away page reads, because all the redo + log records for initializing and modifying the page in the + past could be older than the page in the data file. + + The check is too broad, causing all + tables whose names start with FTS_ to skip the optimization. */ + + if (strstr(space->name, "/FTS_")) + goto init_fail; + + mtr.start(); + mtr.set_log_mode(MTR_LOG_NONE); + buf_block_t* block = buf_page_create(page_id, page_size_t(space->flags), + &mtr); + if (recv_addr->state == RECV_PROCESSED) + /* The page happened to exist in the buffer pool, or it was + just being read in. Before buf_page_get_with_no_latch() returned, + all changes must have been applied to the page already. */ + mtr.commit(); + else + { + i.created = true; + buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); + mtr.x_latch_at_savepoint(0, block); + recv_recover_page(block, mtr, recv_addr, i.lsn); + ut_ad(mtr.has_committed()); + } + + fil_space_release(space); + return block; +} + +/** This is a low level function for the recovery system +to create a page which has buffered intialized redo log records. +@param[in] page_id page to be created using redo logs +@return whether the page creation successfully */ +buf_block_t* recv_recovery_create_page_low(const page_id_t page_id) +{ + buf_block_t* block= NULL; + mutex_enter(&recv_sys->mutex); + recv_addr_t* recv_addr= recv_get_fil_addr_struct(page_id.space(), + page_id.page_no()); + if (recv_addr && recv_addr->state == RECV_WILL_NOT_READ) + { + block= recv_recovery_create_page_low(page_id, recv_addr); + } + mutex_exit(&recv_sys->mutex); + return block; +} + /** Apply the hash table of stored log records to persistent data pages. @param[in] last_batch whether the change buffer merge will be performed as part of the operation */ @@ -2384,7 +2477,7 @@ ignore: apply: mtr.start(); mtr.set_log_mode(MTR_LOG_NONE); - if (buf_block_t* block = buf_page_get_gen( + if (buf_block_t* block = buf_page_get_low( page_id, univ_page_size, RW_X_LATCH, NULL, BUF_GET_IF_IN_POOL, @@ -2398,77 +2491,9 @@ apply: mtr.commit(); recv_read_in_area(page_id); } - } else { - mlog_init_t::init& i = mlog_init.last(page_id); - const lsn_t end_lsn = UT_LIST_GET_LAST( - recv_addr->rec_list)->end_lsn; - - if (end_lsn < i.lsn) { - DBUG_LOG("ib_log", "skip log for page " - << page_id - << " LSN " << end_lsn - << " < " << i.lsn); -skip: - recv_addr->state = RECV_PROCESSED; - goto ignore; - } - - fil_space_t* space = fil_space_acquire( - recv_addr->space); - if (!space) { - goto skip; - } - - if (space->enable_lsn) { -do_read: - fil_space_release(space); - recv_addr->state = RECV_NOT_PROCESSED; - goto apply; - } - - /* Determine if a tablespace could be - for an internal table for FULLTEXT INDEX. - For those tables, no MLOG_INDEX_LOAD record - used to be written when redo logging was - disabled. Hence, we cannot optimize - away page reads, because all the redo - log records for initializing and - modifying the page in the past could - be older than the page in the data - file. - - The check is too broad, causing all - tables whose names start with FTS_ to - skip the optimization. */ - - if (strstr(space->name, "/FTS_")) { - goto do_read; - } - - mtr.start(); - mtr.set_log_mode(MTR_LOG_NONE); - buf_block_t* block = buf_page_create( - page_id, page_size_t(space->flags), - &mtr); - if (recv_addr->state == RECV_PROCESSED) { - /* The page happened to exist - in the buffer pool, or it was - just being read in. Before - buf_page_get_with_no_latch() - returned, all changes must have - been applied to the page already. */ - mtr.commit(); - } else { - i.created = true; - buf_block_dbg_add_level( - block, SYNC_NO_ORDER_CHECK); - mtr.x_latch_at_savepoint(0, block); - recv_recover_page(block, mtr, - recv_addr, i.lsn); - ut_ad(mtr.has_committed()); - } - - fil_space_release(space); + } else if (!recv_recovery_create_page_low( + page_id, recv_addr)) { + goto apply; } } } From fb74de97287c1a3db718226a73c01f6334bf2877 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 23 Mar 2020 02:36:15 +0300 Subject: [PATCH 14/18] MDEV-22006 runtime error: null pointer passed as argument 2, which is declared to never be null in JOIN::copy_ref_ptr_array() Do not memcpy() a zero-length buffer --- sql/sql_select.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.h b/sql/sql_select.h index ffc9eba1186..0e011c9267a 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2,7 +2,7 @@ #define SQL_SELECT_INCLUDED /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2017, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1554,6 +1554,9 @@ public: void copy_ref_ptr_array(Ref_ptr_array dst_arr, Ref_ptr_array src_arr) { DBUG_ASSERT(dst_arr.size() >= src_arr.size()); + if (src_arr.size() == 0) + return; + void *dest= dst_arr.array(); const void *src= src_arr.array(); memcpy(dest, src, src_arr.size() * src_arr.element_size()); From a7cbce06d432cbcb88e071731089aacfd41750fd Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 23 Mar 2020 16:47:43 +0300 Subject: [PATCH 15/18] unoptimized -fsanitize=undefined build on clang requires more stack space --- CMakeLists.txt | 2 +- include/my_pthread.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bb12f89751..d16252973fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,7 +216,7 @@ ENDIF() OPTION(WITH_UBSAN "Enable undefined behavior sanitizer" OFF) IF (WITH_UBSAN) - MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined -fno-sanitize=alignment -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO) + MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined -fno-sanitize=alignment -U_FORTIFY_SOURCE -DWITH_UBSAN" DEBUG RELWITHDEBINFO) ENDIF() OPTION(WITH_MSAN "Enable memory sanitizer" OFF) diff --git a/include/my_pthread.h b/include/my_pthread.h index 2b3f4f14ea3..72647b6c9f7 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -693,7 +693,7 @@ extern void my_mutex_end(void); We need to have at least 256K stack to handle calls to myisamchk_init() with the current number of keys and key parts. */ -#ifdef __SANITIZE_ADDRESS__ +#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN) #define DEFAULT_THREAD_STACK (364*1024L) #else #define DEFAULT_THREAD_STACK (292*1024L) From 5918b17004674f425f2cd1d4f0bac29b3bcecb35 Mon Sep 17 00:00:00 2001 From: seppo Date: Tue, 24 Mar 2020 11:01:42 +0200 Subject: [PATCH 16/18] MDEV-21473 conflicts with async slave BF aborting (#1475) If async slave thread (slave SQL handler), becomes a BF victim, it may occasionally happen that rollbacker thread is used to carry out the rollback instead of the async slave thread. This can happen, if async slave thread has flagged "idle" state when BF thread tries to figure out how to kill the victim. The issue was possible to test by using a galera cluster as slave for external master, and issuing high load of conflicting writes through async replication and directly against galera cluster nodes. However, a deterministic mtr test for the "conflict window" has not yet been worked on. The fix, in this patch makes sure that async slave thread state is never set to IDLE. This prevents the rollbacker thread to intervene. The wsrep_query_state change was refactored to happen by dedicated function to make controlling the idle state change in one place. --- sql/slave.cc | 1 + sql/sql_class.cc | 2 +- sql/sql_connect.cc | 2 +- sql/sql_parse.cc | 6 +++--- sql/wsrep_applier.cc | 4 ++-- sql/wsrep_hton.cc | 8 ++++---- sql/wsrep_mysqld.cc | 11 +++++++++++ 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 3f8c1ce546b..47cfd7412a9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5050,6 +5050,7 @@ pthread_handler_t handle_slave_sql(void *arg) #ifdef WITH_WSREP thd->wsrep_exec_mode= LOCAL_STATE; + wsrep_thd_set_query_state(thd, QUERY_EXEC); /* synchronize with wsrep replication */ if (WSREP_ON) wsrep_ready_wait(); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 97d609d6f1f..494498cad55 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1207,7 +1207,7 @@ void THD::init(void) #ifdef WITH_WSREP wsrep_exec_mode= wsrep_applier ? REPL_RECV : LOCAL_STATE; wsrep_conflict_state= NO_CONFLICT; - wsrep_query_state= QUERY_IDLE; + wsrep_thd_set_query_state(this, QUERY_IDLE); wsrep_last_query_id= 0; wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED; wsrep_trx_meta.depends_on= WSREP_SEQNO_UNDEFINED; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 3491796ba85..b2900a20b28 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1342,7 +1342,7 @@ void do_handle_one_connection(CONNECT *connect) if (WSREP(thd)) { mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_EXITING; + wsrep_thd_set_query_state(thd, QUERY_EXITING); mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 35b6667a25c..56aca365dac 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1210,7 +1210,7 @@ bool do_command(THD *thd) if (WSREP(thd)) { mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_IDLE; + wsrep_thd_set_query_state(thd, QUERY_IDLE); if (thd->wsrep_conflict_state==MUST_ABORT) { wsrep_client_rollback(thd); @@ -1278,7 +1278,7 @@ bool do_command(THD *thd) thd->store_globals(); } - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ @@ -1575,7 +1575,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); if (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT) { thd->wsrep_conflict_state= NO_CONFLICT; diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index f7bab7c5fc8..66335c412e2 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -98,7 +98,7 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, } mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); if (thd->wsrep_conflict_state!= REPLAYING) thd->wsrep_conflict_state= NO_CONFLICT; mysql_mutex_unlock(&thd->LOCK_thd_data); @@ -197,7 +197,7 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, error: mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_IDLE; + wsrep_thd_set_query_state(thd, QUERY_IDLE); mysql_mutex_unlock(&thd->LOCK_thd_data); assert(thd->wsrep_exec_mode== REPL_RECV); diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 6cf29c43447..7c154d6ce6f 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -439,7 +439,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) DBUG_RETURN(WSREP_TRX_CERT_FAIL); } - thd->wsrep_query_state = QUERY_COMMITTING; + wsrep_thd_set_query_state(thd, QUERY_COMMITTING); mysql_mutex_unlock(&thd->LOCK_thd_data); cache = get_trans_log(thd); @@ -473,7 +473,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) { WSREP_DEBUG("empty rbr buffer, query: %s", thd->query()); } - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); DBUG_RETURN(WSREP_TRX_OK); } @@ -581,7 +581,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) WSREP_DEBUG("commit failed for reason: %d", rcode); DBUG_PRINT("wsrep", ("replicating commit fail")); - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); if (thd->wsrep_conflict_state == MUST_ABORT) { thd->wsrep_conflict_state= ABORTED; @@ -613,7 +613,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) DBUG_RETURN(WSREP_TRX_ERROR); } - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(WSREP_TRX_OK); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index ba6c2d24f77..a2666591660 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2586,6 +2586,17 @@ extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode) extern "C" void wsrep_thd_set_query_state( THD *thd, enum wsrep_query_state state) { + /* async slave thread should never flag IDLE state, as it may + give rollbacker thread chance to interfere and rollback async slave + transaction. + in fact, async slave thread is never idle as it reads complete + transactions from relay log and applies them, as a whole. + BF abort happens voluntarily by async slave thread. + */ + if (thd->slave_thread && state == QUERY_IDLE) { + WSREP_DEBUG("Skipping IDLE state change for slave SQL"); + return; + } thd->wsrep_query_state= state; } From 0b00c1a22f7861e6a5be5041a915ccafceb0669c Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 23 Mar 2020 02:08:01 +0300 Subject: [PATCH 17/18] MDEV-22005 UBSAN: applying non-zero offset 2 to null pointer in my_charpos_mb() Empty comment has a correct length. --- sql/sql_string.h | 6 +++++- sql/sql_table.cc | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sql/sql_string.h b/sql/sql_string.h index e1d64722898..63404587404 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -3,7 +3,7 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2017, MariaDB Corporation. + Copyright (c) 2008, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -79,6 +79,10 @@ public: Well_formed_prefix(CHARSET_INFO *cs, const char *str, size_t length) :Well_formed_prefix_status(cs, str, str + length, length), m_str(str) { } + Well_formed_prefix(CHARSET_INFO *cs, LEX_STRING str, size_t nchars) + :Well_formed_prefix_status(cs, str.str, str.str + str.length, nchars), + m_str(str.str) + { } size_t length() const { return m_source_end_pos - m_str; } }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 878c09286b5..1845aec5ce2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB + Copyright (c) 2010, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4286,8 +4286,12 @@ bool validate_comment_length(THD *thd, LEX_STRING *comment, size_t max_len, uint err_code, const char *name) { DBUG_ENTER("validate_comment_length"); - uint tmp_len= my_charpos(system_charset_info, comment->str, - comment->str + comment->length, max_len); + + if (comment->length == 0) + DBUG_RETURN(false); + + size_t tmp_len= + Well_formed_prefix(system_charset_info, *comment, max_len).length(); if (tmp_len < comment->length) { if (thd->is_strict_mode()) From b11ff3d49581d9e7b6f8b990f08e85e4d6384418 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Mon, 30 Mar 2020 08:03:54 +0530 Subject: [PATCH 18/18] MDEV-22019: Sig 11 in next_breadth_first_tab | max_sort_length setting + double GROUP BY leads to crash No need to create a temp table for aggregation if we have encountered some error. --- mysql-test/r/group_by.result | 14 ++++++++++++++ mysql-test/t/group_by.test | 17 +++++++++++++++++ sql/sql_select.cc | 8 ++++++-- sql/sql_show.cc | 7 +++---- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index cbce6340c47..c996627486c 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2861,3 +2861,17 @@ SELECT 1 FROM t1 GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ; 1 drop table t1; +# +# MDEV-22019: Sig 11 in next_breadth_first_tab | max_sort_length setting + double +# GROUP BY leads to crash +# +CALL mtr.add_suppression("Out of sort memory"); +CALL mtr.add_suppression("Sort aborted"); +SET @save_max_sort_length= @@max_sort_length; +SET max_sort_length=2000000; +SELECT * FROM information_schema.tables t JOIN information_schema.columns c +ON t.table_schema=c.table_schema +WHERE c.table_schema=(SELECT COUNT(*) FROM INFORMATION_SCHEMA.columns GROUP BY column_type) +GROUP BY t.table_name; +ERROR HY001: Out of sort memory, consider increasing server sort buffer size +SET max_sort_length= @save_max_sort_length; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 0436cd16e7c..324b41ce23c 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1979,3 +1979,20 @@ GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAV SELECT 1 FROM t1 GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAVING LOAD_FILE('a') ; drop table t1; + +--echo # +--echo # MDEV-22019: Sig 11 in next_breadth_first_tab | max_sort_length setting + double +--echo # GROUP BY leads to crash +--echo # + + +CALL mtr.add_suppression("Out of sort memory"); +CALL mtr.add_suppression("Sort aborted"); +SET @save_max_sort_length= @@max_sort_length; +SET max_sort_length=2000000; +--error ER_OUT_OF_SORTMEMORY +SELECT * FROM information_schema.tables t JOIN information_schema.columns c +ON t.table_schema=c.table_schema +WHERE c.table_schema=(SELECT COUNT(*) FROM INFORMATION_SCHEMA.columns GROUP BY column_type) +GROUP BY t.table_name; +SET max_sort_length= @save_max_sort_length; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 97002ef071f..c601946cfa0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2210,8 +2210,12 @@ JOIN::optimize_inner() having_is_correlated= MY_TEST(having->used_tables() & OUTER_REF_TABLE_BIT); tmp_having= having; - if ((select_lex->options & OPTION_SCHEMA_TABLE)) - optimize_schema_tables_reads(this); + if ((select_lex->options & OPTION_SCHEMA_TABLE) && + optimize_schema_tables_reads(this)) + DBUG_RETURN(TRUE); + + if (unlikely(thd->is_error())) + DBUG_RETURN(TRUE); /* The loose index scan access method guarantees that all grouping or diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 78ca1d09e7a..4e37b53b87e 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8299,7 +8299,6 @@ end: bool optimize_schema_tables_reads(JOIN *join) { THD *thd= join->thd; - bool result= 0; DBUG_ENTER("optimize_schema_tables_reads"); JOIN_TAB *tab; @@ -8334,11 +8333,11 @@ bool optimize_schema_tables_reads(JOIN *join) */ cond= tab->cache_select->cond; } - - optimize_for_get_all_tables(thd, table_list, cond); + if (optimize_for_get_all_tables(thd, table_list, cond)) + DBUG_RETURN(TRUE); // Handle OOM } } - DBUG_RETURN(result); + DBUG_RETURN(FALSE); }