From d072a29601834cd61252158c95f068aa13eb55fa Mon Sep 17 00:00:00 2001 From: Galina Shalygina Date: Wed, 24 Jul 2024 13:55:55 +0200 Subject: [PATCH 01/17] MDEV-23983: Crash caused by query containing constant having clause Before this patch the crash occured when a single row dataset is used and Item::remove_eq_conds() is called for HAVING. This function is not supposed to be called after the elimination of multiple equalities. To fix this problem instead of Item::remove_eq_conds() Item::val_int() is used. In this case the optimizer tries to evaluate the condition for the single row dataset and discovers impossible HAVING immediately. So, the execution phase is skipped. Approved by Igor Babaev --- mysql-test/main/having.result | 44 ++++++++++++++++++++++++++++++++++ mysql-test/main/having.test | 45 +++++++++++++++++++++++++++++++++++ sql/sql_select.cc | 19 ++++++++------- 3 files changed, 100 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/having.result b/mysql-test/main/having.result index 95497a59c20..9f8a1c6e73c 100644 --- a/mysql-test/main/having.result +++ b/mysql-test/main/having.result @@ -955,3 +955,47 @@ DROP TABLE t; # # End of 10.4 tests # +# +# MDEV-23983: Crash caused by query containing constant having clause +# +CREATE TABLE t1 (id INT PRIMARY KEY, a INT, b TEXT, c INT); +INSERT INTO t1 VALUES (3, 7, 'b', 1), (4, 7, 'b', 1); +SELECT * FROM t1 +WHERE t1.id = 3 +GROUP BY t1.a +HAVING t1.b = 'b' and t1.c = 1; +id a b c +3 7 b 1 +SELECT * FROM t1 +WHERE t1.id = 3 +GROUP BY t1.a +HAVING t1.b = 'b' and t1.c = 2; +id a b c +explain SELECT * FROM t1 +WHERE t1.id = 3 +GROUP BY t1.a +HAVING t1.b = 'b' and t1.c = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables +DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +CREATE TABLE t2 (id INT, b TEXT, c INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (3, 'b', 1); +SELECT t2.* FROM t2 LEFT JOIN t1 ON t2.id = t1.a +GROUP BY t2.id +HAVING t2.b = 'b' and t2.c = 1; +id b c +3 b 1 +SELECT t2.* FROM t2 LEFT JOIN t1 ON t2.id = t1.a +GROUP BY t2.id +HAVING t2.b = 'b' and t2.c = 2; +id b c +explain SELECT t2.* FROM t2 LEFT JOIN t1 ON t2.id = t1.a +GROUP BY t2.id +HAVING t2.b = 'b' and t2.c = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING noticed after reading const tables +DROP TABLE t1,t2; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/having.test b/mysql-test/main/having.test index b114070c60f..812038b2d60 100644 --- a/mysql-test/main/having.test +++ b/mysql-test/main/having.test @@ -1011,3 +1011,48 @@ DROP TABLE t; --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # MDEV-23983: Crash caused by query containing constant having clause +--echo # + +CREATE TABLE t1 (id INT PRIMARY KEY, a INT, b TEXT, c INT); +INSERT INTO t1 VALUES (3, 7, 'b', 1), (4, 7, 'b', 1); + +SELECT * FROM t1 +WHERE t1.id = 3 +GROUP BY t1.a +HAVING t1.b = 'b' and t1.c = 1; + +let $q= +SELECT * FROM t1 +WHERE t1.id = 3 +GROUP BY t1.a +HAVING t1.b = 'b' and t1.c = 2; + +eval $q; +eval explain $q; + +DROP TABLE t1; + +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +CREATE TABLE t2 (id INT, b TEXT, c INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (3, 'b', 1); + +SELECT t2.* FROM t2 LEFT JOIN t1 ON t2.id = t1.a +GROUP BY t2.id +HAVING t2.b = 'b' and t2.c = 1; + +let $q= +SELECT t2.* FROM t2 LEFT JOIN t1 ON t2.id = t1.a +GROUP BY t2.id +HAVING t2.b = 'b' and t2.c = 2; + +eval $q; +eval explain $q; + +DROP TABLE t1,t2; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b86ffed8619..93b53699c9a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2971,19 +2971,22 @@ int JOIN::optimize_stage2() which do not use aggregate functions. In such case temporary table may not be used and const condition elements may be lost during further having - condition transformation in JOIN::exec. + condition transformation. */ if (having && const_table_map && !having->with_sum_func()) { having->update_used_tables(); - having= having->remove_eq_conds(thd, &select_lex->having_value, true); - if (select_lex->having_value == Item::COND_FALSE) + if (having->const_item() && !having->is_expensive()) { - having= new (thd->mem_root) Item_bool(thd, false); - zero_result_cause= "Impossible HAVING noticed after reading const tables"; - error= 0; - select_lex->mark_const_derived(zero_result_cause); - goto setup_subq_exit; + bool having_value= having->val_int(); + having= new (thd->mem_root) Item_bool(thd, having_value); + if (!having_value) + { + zero_result_cause= "Impossible HAVING noticed after reading const tables"; + error= 0; + select_lex->mark_const_derived(zero_result_cause); + goto setup_subq_exit; + } } } From 37119cd2567cdc710e3d0fd097a10b6bb9def3c8 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 1 Aug 2024 17:44:54 +0530 Subject: [PATCH 02/17] MDEV-29010 Table cannot be loaded after instant ALTER Reason: ====== - InnoDB fails to load the instant alter table metadata from clustered index while loading the table definition. The reason is that InnoDB metadata blob has the column length exceeds maximum fixed length column size. Fix: === - InnoDB should treat the long fixed length column as variable length fields that needs external storage while initializing the field map for instant alter operation --- mysql-test/suite/innodb/r/instant_alter_bugs.result | 9 +++++++++ mysql-test/suite/innodb/t/instant_alter_bugs.test | 11 +++++++++++ storage/innobase/handler/handler0alter.cc | 7 +++++++ 3 files changed, 27 insertions(+) diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result index dc64a041c3c..c74730599d3 100644 --- a/mysql-test/suite/innodb/r/instant_alter_bugs.result +++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result @@ -521,3 +521,12 @@ COUNT(*) 1 DROP TABLE t1; # End of 10.4 tests +# +# MDEV-29010 Table cannot be loaded after instant ALTER +# +CREATE TABLE t1 (a CHAR(255), b INT, +c INT as (b) VIRTUAL)ENGINE=InnoDB CHARACTER SET utf32; +ALTER TABLE t1 DROP COLUMN a; +ALTER TABLE t1 DROP COLUMN c; +DROP TABLE t1; +# End of 10.5 tests diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test index db04ac711b2..c1b999dbc74 100644 --- a/mysql-test/suite/innodb/t/instant_alter_bugs.test +++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test @@ -553,3 +553,14 @@ SELECT COUNT(*) FROM t1; DROP TABLE t1; --echo # End of 10.4 tests + +--echo # +--echo # MDEV-29010 Table cannot be loaded after instant ALTER +--echo # +CREATE TABLE t1 (a CHAR(255), b INT, + c INT as (b) VIRTUAL)ENGINE=InnoDB CHARACTER SET utf32; +ALTER TABLE t1 DROP COLUMN a; +ALTER TABLE t1 DROP COLUMN c; +DROP TABLE t1; + +--echo # End of 10.5 tests diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index b5a76bfcdc2..d3a7e3d3749 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -181,6 +181,13 @@ inline void dict_table_t::init_instant(const dict_table_t& table) auto fixed_len = dict_col_get_fixed_size( f.col, not_redundant()); + + /* Long fixed length can be treated as variable + length fields that needs external storage */ + if (fixed_len > DICT_MAX_FIXED_COL_LEN) { + fixed_len = 0; + } + field_map_it->set_dropped(); if (!f.col->is_nullable()) { field_map_it->set_not_null(); From cf202decde475933dfa6b0aadfa5e04e667bfab7 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Fri, 2 Aug 2024 18:48:29 +0700 Subject: [PATCH 03/17] MDEV-34683 Types mismatch when cloning items causes debug assertion New runtime type diagnostic (MDEV-34490) has detected that classes Item_func_eq, Item_default_value and Item_date_literal_for_invalid_dates incorrectly return an instance of its ancestor classes when being cloned. This commit fixes that. Additionally, it fixes a bug at Item_func_case_simple::do_build_clone() which led to an endless loop of cloning functions calls. Reviewer: Oleksandr Byelkin --- mysql-test/main/item_types.result | 14 ++++++++++++++ mysql-test/main/item_types.test | 18 ++++++++++++++++++ sql/item.h | 7 ++++++- sql/item_cmpfunc.cc | 10 ++++++++++ sql/item_cmpfunc.h | 3 ++- 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/item_types.result b/mysql-test/main/item_types.result index 865b4f612ae..40db01f2609 100644 --- a/mysql-test/main/item_types.result +++ b/mysql-test/main/item_types.result @@ -14,3 +14,17 @@ SELECT * FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.c<=>5; c c DROP TABLE t1, t2; SET optimizer_switch=default; +# +# MDEV-34683 Types mismatch when cloning items causes debug assertion +# +CREATE TABLE t1 (a date); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +SELECT a FROM v1 WHERE a IN ('a', 'b', 'c'); +a +CREATE VIEW v2 AS SELECT '' as a; +SELECT * FROM v2 WHERE a='' AND CASE '' WHEN '' THEN '' ELSE a END=''; +a + +DROP TABLE t1; +DROP VIEW v1, v2; +# End of 10.5 tests diff --git a/mysql-test/main/item_types.test b/mysql-test/main/item_types.test index f43bfe1a8ac..6f10d6bf71a 100644 --- a/mysql-test/main/item_types.test +++ b/mysql-test/main/item_types.test @@ -13,3 +13,21 @@ SELECT * FROM t1 JOIN t2 ON t1.c=t2.c WHERE t1.c<=>5; DROP TABLE t1, t2; SET optimizer_switch=default; + +--echo # +--echo # MDEV-34683 Types mismatch when cloning items causes debug assertion +--echo # + +CREATE TABLE t1 (a date); +CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; +--disable_warnings +SELECT a FROM v1 WHERE a IN ('a', 'b', 'c'); +--enable_warnings + +CREATE VIEW v2 AS SELECT '' as a; +SELECT * FROM v2 WHERE a='' AND CASE '' WHEN '' THEN '' ELSE a END=''; + +DROP TABLE t1; +DROP VIEW v1, v2; + +--echo # End of 10.5 tests diff --git a/sql/item.h b/sql/item.h index b531647e8bf..796b2ec9eee 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5225,6 +5225,9 @@ public: cached_time.copy_to_mysql_time(ltime); return (null_value= false); } + Item *do_get_copy(THD *thd) const override + { return get_item_copy(thd, this); } + Item *do_build_clone(THD *thd) const override { return get_copy(thd); } }; @@ -6699,7 +6702,9 @@ public: description */ bool associate_with_target_field(THD *thd, Item_field *field) override; - + Item *do_get_copy(THD *thd) const override + { return get_item_copy(thd, this); } + Item* do_build_clone(THD *thd) const override { return get_copy(thd); } private: bool tie_field(THD *thd); }; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 2f9da57cdba..c4c96f6f7ae 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1814,6 +1814,16 @@ longlong Item_func_eq::val_int() } +Item *Item_func_eq::do_build_clone(THD *thd) const +{ + /* + Clone the parent and cast to the child class since there is nothing + specific for Item_func_eq + */ + return (Item_func_eq*) Item_bool_rowready_func2::do_build_clone(thd); +} + + /** Same as Item_func_eq, but NULL = NULL. */ bool Item_func_equal::fix_length_and_dec() diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index d394d932adf..adbb00147dc 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -765,6 +765,7 @@ public: friend class Arg_comparator; Item *do_get_copy(THD *thd) const override { return get_item_copy(thd, this); } + Item *do_build_clone(THD *thd) const override; }; class Item_func_equal final :public Item_bool_rowready_func2 @@ -2324,7 +2325,7 @@ public: Item *do_build_clone(THD *thd) const override { Item_func_case_simple *clone= (Item_func_case_simple *) - Item_func_case::build_clone(thd); + Item_func_case::do_build_clone(thd); uint ncases= when_count(); if (clone && clone->Predicant_to_list_comparator::init_clone(thd, ncases)) return NULL; From 83040474dcb6e9468bb0a7e42f3a31dc6e156d1a Mon Sep 17 00:00:00 2001 From: Andre F de Miranda Date: Fri, 24 May 2024 22:51:01 +1000 Subject: [PATCH 04/17] MDEV-34234: make lsof optional on RPM Signed-off-by: Julius Goryavsky --- cmake/cpack_rpm.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 65a739dc03e..66645a6676d 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -220,8 +220,9 @@ SETA(CPACK_RPM_server_PACKAGE_REQUIRES IF(WITH_WSREP) SETA(CPACK_RPM_server_PACKAGE_REQUIRES - "galera-4" "rsync" "lsof" "grep" "gawk" "iproute" + "galera-4" "rsync" "grep" "gawk" "iproute" "coreutils" "findutils" "tar") + SETA(CPACK_RPM_server_PACKAGE_RECOMMENDS "lsof") ENDIF() SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh) From 0ba6068a82bbce0abf2540dfc0c6954cb281250f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 1 Aug 2024 08:28:28 +0300 Subject: [PATCH 05/17] MDEV-32782 : galera_sst_mysqldump_with_key test failed Modified test configuration file to use wsrep_sync_wait to make sure committed transactions are replicated before next operation. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/disabled.def | 1 - mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf | 5 +++++ mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 4f3f9884997..1fdde67fd3d 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -16,5 +16,4 @@ galera_sequences : MDEV-32561 WSREP FSM failure: no such a transition REPLICATIN galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the galera::ReplicatorSMM::finish_cert() galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() -galera_sst_mysqldump_with_key : MDEV-32782 galera_sst_mysqldump_with_key test failed galera_var_ignore_apply_errors : MENT-1997 galera_var_ignore_apply_errors test freezes diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf index 52ec6af7e74..da04a605291 100644 --- a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.cnf @@ -3,6 +3,11 @@ # We do not set mysqldump-related SST options here because doing so on startup # causes the first MTR connection to be forefully dropped by Galera, which in turn confuses MTR +[mysqld] +wsrep-debug=1 +wsrep-sync_wait=15 +loose-galera_sst_mysqldump_with_key=1 + [mysqld.1] wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' diff --git a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test index 3e0e944b0df..31a88777150 100644 --- a/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test +++ b/mysql-test/suite/galera/t/galera_sst_mysqldump_with_key.test @@ -6,6 +6,7 @@ --source include/galera_cluster.inc --source include/have_innodb.inc --source include/have_ssl_communication.inc +--source include/force_restart.inc --source suite/galera/include/galera_sst_set_mysqldump.inc --let $node_1=node_1 From cb80ef93a9b0a7b4f80fde519629f3ad93fcea15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 31 Jul 2024 14:45:32 +0300 Subject: [PATCH 06/17] MDEV-32778 : galera_ssl_reload failed with warning message Fixed used configuration and added suppression for warning message. Test case changes only. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera_3nodes/disabled.def | 1 - .../galera_3nodes/r/galera_ssl_reload.result | 6 ++++++ .../galera_3nodes/t/galera_ssl_reload.cnf | 10 +++++++--- .../galera_3nodes/t/galera_ssl_reload.test | 20 +++++++++++++------ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index bcd0fb03478..cbadf6dd5c1 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -11,7 +11,6 @@ ############################################################################## galera_2_cluster : MDEV-32631 galera_2_cluster: before_rollback(): Assertion `0' failed -galera_ssl_reload : MDEV-32778 galera_ssl_reload failed with warning message galera_pc_bootstrap : temporarily disabled at the request of Codership galera_ipv6_mariabackup_section : temporarily disabled at the request of Codership GCF-354 : MDEV-25614 Galera test failure on GCF-354 diff --git a/mysql-test/suite/galera_3nodes/r/galera_ssl_reload.result b/mysql-test/suite/galera_3nodes/r/galera_ssl_reload.result index 1daf3bedf4f..fffc4f3f5b5 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_ssl_reload.result +++ b/mysql-test/suite/galera_3nodes/r/galera_ssl_reload.result @@ -14,3 +14,9 @@ connection node_3; # restart: with restart_parameters connection node_2; FLUSH SSL; +connection node_3; +call mtr.add_suppression("WSREP: Handshake failed: unexpected eof while reading"); +connection node_2; +call mtr.add_suppression("WSREP: Handshake failed: unexpected eof while reading"); +connection node_1; +call mtr.add_suppression("WSREP: Handshake failed: unexpected eof while reading"); diff --git a/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.cnf b/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.cnf index 65d1599268d..d4c654e2bf8 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.cnf +++ b/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.cnf @@ -1,10 +1,14 @@ !include ../galera_3nodes.cnf +[mysqld] +wsrep-debug=1 +loose-galera-ssl-reload=1 + [mysqld.1] -wsrep_provider_options='base_port=@mysqld.1.#galera_port;socket.ssl=yes;socket.ssl_ca=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.root.crt;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.1.crt;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.1.key' +wsrep_provider_options='base_port=@mysqld.1.#galera_port;socket.ssl=yes;socket.ssl_ca=@ENV.MYSQL_TEST_DIR/std_data/cacert.pem;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/client-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/client-key.pem' [mysqld.2] -wsrep_provider_options='base_port=@mysqld.2.#galera_port;socket.ssl=yes;socket.ssl_ca=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.root.crt;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.1.crt;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.1.key' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;socket.ssl=yes;socket.ssl_ca=@ENV.MYSQL_TEST_DIR/std_data/cacert.pem;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/client-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/client-key.pem' [mysqld.3] -wsrep_provider_options='base_port=@mysqld.3.#galera_port;socket.ssl=yes;socket.ssl_ca=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.root.crt;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.1.crt;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/galera_certs/galera.1.key' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;socket.ssl=yes;socket.ssl_ca=@ENV.MYSQL_TEST_DIR/std_data/cacert.pem;socket.ssl_cert=@ENV.MYSQL_TEST_DIR/std_data/client-cert.pem;socket.ssl_key=@ENV.MYSQL_TEST_DIR/std_data/client-key.pem' diff --git a/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.test b/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.test index 714d4b3f75c..f7bed23294d 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ssl_reload.test @@ -5,6 +5,7 @@ --source include/galera_cluster.inc --source include/have_openssl.inc --source include/have_ssl_communication.inc +--source include/force_restart.inc --let $galera_version=26.4.8 source ../../wsrep/include/check_galera_version.inc; @@ -31,22 +32,22 @@ let $ssl_cert = $MYSQLTEST_VARDIR/tmp/ssl_cert.pem; let $ssl_key = $MYSQLTEST_VARDIR/tmp/ssl_key.pem; let $ssl_ca = $MYSQLTEST_VARDIR/tmp/ssl_ca.pem; -copy_file std_data/galera_certs/galera.root.crt $ssl_ca; -copy_file std_data/galera_certs/galera.1.crt $ssl_cert; -copy_file std_data/galera_certs/galera.1.key $ssl_key; +copy_file std_data/cacert.pem $ssl_ca; +copy_file std_data/client-cert.pem $ssl_cert; +copy_file std_data/client-key.pem $ssl_key; --connection node_2 --source include/shutdown_mysqld.inc --let $restart_noprint=1 ---let $restart_parameters = --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1 --wsrep_provider_options=base_port=$NODE_GALERAPORT_2;socket.ssl=yes;socket.ssl_ca=$MYSQL_TEST_DIR/std_data/galera_certs/galera.root.crt;socket.ssl_cert=$MYSQLTEST_VARDIR/tmp/ssl_cert.pem;socket.ssl_key=$MYSQLTEST_VARDIR/tmp/ssl_key.pem +--let $restart_parameters = --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1 --wsrep_provider_options=base_port=$NODE_GALERAPORT_2;socket.ssl=yes;socket.ssl_ca=$MYSQL_TEST_DIR/std_data/cacert.pem;socket.ssl_cert=$MYSQLTEST_VARDIR/tmp/ssl_cert.pem;socket.ssl_key=$MYSQLTEST_VARDIR/tmp/ssl_key.pem --source include/start_mysqld.inc --source include/galera_wait_ready.inc # Set certificate and key and reload by setting directly `wsrep_provider_options` remove_file $ssl_cert; remove_file $ssl_key; -copy_file std_data/galera_certs/galera.2.crt $ssl_cert; -copy_file std_data/galera_certs/galera.2.key $ssl_key; +copy_file std_data/client-cert.pem $ssl_cert; +copy_file std_data/client-key.pem $ssl_key; SET GLOBAL wsrep_provider_options = 'socket.ssl_reload=1'; --connection node_3 @@ -67,5 +68,12 @@ remove_file $ssl_ca; remove_file $ssl_cert; remove_file $ssl_key; +--connection node_3 +call mtr.add_suppression("WSREP: Handshake failed: unexpected eof while reading"); +--connection node_2 +call mtr.add_suppression("WSREP: Handshake failed: unexpected eof while reading"); +--connection node_1 +call mtr.add_suppression("WSREP: Handshake failed: unexpected eof while reading"); + # Restore original auto_increment_offset values. --source ../galera/include/auto_increment_offset_restore.inc From eb30a9d63391359e686cfffb36b4c0e4a7e2f5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 26 Jul 2024 09:04:30 +0300 Subject: [PATCH 07/17] MDEV-34647 : 'INSERT...SELECT' on MyISAM table suddenly replicated by Galera Replication of MyISAM and Aria DML is experimental and best effort only. Earlier change make INSERT SELECT on both MyISAM and Aria to replicate using TOI and STATEMENT replication. Replication should happen only if user has set needed wsrep_mode setting. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/MDEV-34647.result | 100 ++++++++++++++++++++ mysql-test/suite/galera/r/mdev-22063.result | 16 ++-- mysql-test/suite/galera/t/MDEV-34647.test | 53 +++++++++++ mysql-test/suite/galera/t/mdev-22063.test | 8 +- sql/sql_parse.cc | 8 +- 5 files changed, 172 insertions(+), 13 deletions(-) create mode 100644 mysql-test/suite/galera/r/MDEV-34647.result create mode 100644 mysql-test/suite/galera/t/MDEV-34647.test diff --git a/mysql-test/suite/galera/r/MDEV-34647.result b/mysql-test/suite/galera/r/MDEV-34647.result new file mode 100644 index 00000000000..5a1d4530e52 --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-34647.result @@ -0,0 +1,100 @@ +connection node_2; +connection node_1; +create table t1(id serial, val varchar(100)) engine=myisam; +insert into t1 values(null, 'a'); +insert into t1 values(null, 'b'); +insert into t1 select null, 'c'; +insert into t1 select null, 'd' from t1; +select * from t1; +id val +1 a +3 b +5 c +7 d +9 d +11 d +create table t2(id serial, val varchar(100)) engine=aria; +insert into t2 values(null, 'a'); +insert into t2 values(null, 'b'); +insert into t2 select null, 'c'; +insert into t2 select null, 'd' from t2; +select * from t2; +id val +1 a +3 b +5 c +7 d +9 d +11 d +create table t3(id serial, val varchar(100)) engine=innodb; +insert into t3 values(null, 'a'); +insert into t3 values(null, 'b'); +insert into t3 select null, 'c'; +insert into t3 select null, 'd' from t3; +select * from t3; +id val +1 a +3 b +5 c +7 d +9 d +11 d +set global wsrep_replicate_myisam=ON; +create table t4(id serial, val varchar(100)) engine=myisam; +insert into t4 values(null, 'a'); +insert into t4 values(null, 'b'); +insert into t4 select null, 'c'; +insert into t4 select null, 'd' from t4; +select * from t4; +id val +1 a +2 b +3 c +4 d +5 d +6 d +create table t5(id serial, val varchar(100)) engine=myisam; +insert into t5 values(null, 'a'); +insert into t5 values(null, 'b'); +insert into t5 select null, 'c'; +insert into t5 select null, 'd' from t5; +select * from t2; +id val +1 a +3 b +5 c +7 d +9 d +11 d +connection node_2; +select * from t1; +id val +select * from t2; +id val +select * from t3; +id val +1 a +3 b +5 c +7 d +9 d +11 d +select * from t4; +id val +1 a +2 b +3 c +4 d +5 d +6 d +select * from t5; +id val +1 a +2 b +3 c +4 d +5 d +6 d +connection node_1; +drop table t1,t2,t3,t4,t5; +set global wsrep_replicate_myisam=default; diff --git a/mysql-test/suite/galera/r/mdev-22063.result b/mysql-test/suite/galera/r/mdev-22063.result index 5773e70cc9d..f5007b2656c 100644 --- a/mysql-test/suite/galera/r/mdev-22063.result +++ b/mysql-test/suite/galera/r/mdev-22063.result @@ -114,7 +114,7 @@ EXPECT_1000 1000 SELECT COUNT(*) AS EXPECT_1000 FROM t3; EXPECT_1000 -1000 +0 SELECT COUNT(*) AS EXPECT_1000 FROM t4; EXPECT_1000 1000 @@ -127,9 +127,9 @@ EXPECT_1000 SELECT COUNT(*) AS EXPECT_1000 FROM t7; EXPECT_1000 1000 -SELECT COUNT(*) AS EXPECT_1000 FROM t8; -EXPECT_1000 -1000 +SELECT COUNT(*) AS EXPECT_0 FROM t8; +EXPECT_0 +0 connection node_1; DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; # Bigger INSERT INTO ... SELECT test @@ -182,7 +182,7 @@ EXPECT_1000 1000 SELECT COUNT(*) AS EXPECT_1000 FROM t3; EXPECT_1000 -1000 +0 SELECT COUNT(*) AS EXPECT_1000 FROM t4; EXPECT_1000 1000 @@ -195,9 +195,9 @@ EXPECT_1000 SELECT COUNT(*) AS EXPECT_1000 FROM t7; EXPECT_1000 1000 -SELECT COUNT(*) AS EXPECT_1000 FROM t8; -EXPECT_1000 -1000 +SELECT COUNT(*) AS EXPECT_0 FROM t8; +EXPECT_0 +0 connection node_1; DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; CREATE TABLE t1(pk int not null primary key) engine=innodb; diff --git a/mysql-test/suite/galera/t/MDEV-34647.test b/mysql-test/suite/galera/t/MDEV-34647.test new file mode 100644 index 00000000000..1697bf05f28 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-34647.test @@ -0,0 +1,53 @@ +--source include/galera_cluster.inc +--source include/have_aria.inc + +create table t1(id serial, val varchar(100)) engine=myisam; +insert into t1 values(null, 'a'); +insert into t1 values(null, 'b'); +insert into t1 select null, 'c'; +insert into t1 select null, 'd' from t1; +select * from t1; + +create table t2(id serial, val varchar(100)) engine=aria; +insert into t2 values(null, 'a'); +insert into t2 values(null, 'b'); +insert into t2 select null, 'c'; +insert into t2 select null, 'd' from t2; +select * from t2; + +create table t3(id serial, val varchar(100)) engine=innodb; +insert into t3 values(null, 'a'); +insert into t3 values(null, 'b'); +insert into t3 select null, 'c'; +insert into t3 select null, 'd' from t3; +select * from t3; + +set global wsrep_replicate_myisam=ON; + +create table t4(id serial, val varchar(100)) engine=myisam; +insert into t4 values(null, 'a'); +insert into t4 values(null, 'b'); +insert into t4 select null, 'c'; +insert into t4 select null, 'd' from t4; +select * from t4; + +create table t5(id serial, val varchar(100)) engine=myisam; +insert into t5 values(null, 'a'); +insert into t5 values(null, 'b'); +insert into t5 select null, 'c'; +insert into t5 select null, 'd' from t5; +select * from t2; + + +--connection node_2 +select * from t1; +select * from t2; +select * from t3; +select * from t4; +select * from t5; + + +--connection node_1 +drop table t1,t2,t3,t4,t5; +set global wsrep_replicate_myisam=default; + diff --git a/mysql-test/suite/galera/t/mdev-22063.test b/mysql-test/suite/galera/t/mdev-22063.test index ef16c0c8716..c3a7af7e0bb 100644 --- a/mysql-test/suite/galera/t/mdev-22063.test +++ b/mysql-test/suite/galera/t/mdev-22063.test @@ -97,7 +97,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t8; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 8 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't_' --source include/wait_condition.inc ---let $wait_condition = SELECT COUNT(*) = 1000 FROM test.t8; +--let $wait_condition = SELECT COUNT(*) = 1000 FROM test.t7; --source include/wait_condition.inc SELECT COUNT(*) AS EXPECT_1000 FROM t1; @@ -107,7 +107,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t4; SELECT COUNT(*) AS EXPECT_1000 FROM t5; SELECT COUNT(*) AS EXPECT_1000 FROM t6; SELECT COUNT(*) AS EXPECT_1000 FROM t7; -SELECT COUNT(*) AS EXPECT_1000 FROM t8; +SELECT COUNT(*) AS EXPECT_0 FROM t8; --connection node_1 DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; @@ -145,7 +145,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t8; --connection node_2 --let $wait_condition = SELECT COUNT(*) = 8 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't_' --source include/wait_condition.inc ---let $wait_condition = SELECT COUNT(*) = 1000 FROM test.t8; +--let $wait_condition = SELECT COUNT(*) = 1000 FROM test.t7; --source include/wait_condition.inc SELECT COUNT(*) AS EXPECT_1000 FROM t1; @@ -155,7 +155,7 @@ SELECT COUNT(*) AS EXPECT_1000 FROM t4; SELECT COUNT(*) AS EXPECT_1000 FROM t5; SELECT COUNT(*) AS EXPECT_1000 FROM t6; SELECT COUNT(*) AS EXPECT_1000 FROM t7; -SELECT COUNT(*) AS EXPECT_1000 FROM t8; +SELECT COUNT(*) AS EXPECT_0 FROM t8; --connection node_1 DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8a218290114..2d6c7621f7b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4761,7 +4761,13 @@ mysql_execute_command(THD *thd) // For !InnoDB we start TOI if it is not yet started and hope for the best if (!is_innodb && !wsrep_toi) - WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL); + { + const legacy_db_type db_type= first_table->table->file->partition_ht()->db_type; + + /* Currently we support TOI for MyISAM only. */ + if (db_type == DB_TYPE_MYISAM && wsrep_replicate_myisam) + WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL); + } } #endif /* WITH_WSREP */ /* From 71f289e5d1691a060148d7063c663730f580f26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 30 Jul 2024 12:30:39 +0300 Subject: [PATCH 08/17] MDEV-25614 : Galera test failure on GCF-354 Modified node config with longer timeouts for suspect, inactive, install and wait_prim timeout. Increased node_1 weight to keep it primary component when other nodes are voted out. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera_3nodes/disabled.def | 1 - mysql-test/suite/galera_3nodes/r/GCF-354.result | 9 ++++++--- mysql-test/suite/galera_3nodes/t/GCF-354.cnf | 11 +++++++++++ mysql-test/suite/galera_3nodes/t/GCF-354.test | 10 ++++------ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/galera_3nodes/disabled.def b/mysql-test/suite/galera_3nodes/disabled.def index cbadf6dd5c1..b7f0d8da8c1 100644 --- a/mysql-test/suite/galera_3nodes/disabled.def +++ b/mysql-test/suite/galera_3nodes/disabled.def @@ -13,4 +13,3 @@ galera_2_cluster : MDEV-32631 galera_2_cluster: before_rollback(): Assertion `0' failed galera_pc_bootstrap : temporarily disabled at the request of Codership galera_ipv6_mariabackup_section : temporarily disabled at the request of Codership -GCF-354 : MDEV-25614 Galera test failure on GCF-354 diff --git a/mysql-test/suite/galera_3nodes/r/GCF-354.result b/mysql-test/suite/galera_3nodes/r/GCF-354.result index 3fdd44fe9d3..c69de54747f 100644 --- a/mysql-test/suite/galera_3nodes/r/GCF-354.result +++ b/mysql-test/suite/galera_3nodes/r/GCF-354.result @@ -1,17 +1,20 @@ connection node_2; connection node_1; +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; connection node_1; connection node_2; connection node_3; connection node_2; -SET SESSION wsrep_on=OFF; +SET wsrep_on=OFF; DROP SCHEMA test; connection node_3; -SET SESSION wsrep_on=OFF; +SET wsrep_on=OFF; CREATE TABLE test.t1 (f1 INTEGER NOT NULL PRIMARY KEY) engine=innodb; connection node_1; CREATE TABLE test.t1 (f1 INTEGER NOT NULL PRIMARY KEY) engine=innodb; -INSERT INTO test.t1 values (1); +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE +1 SHOW STATUS LIKE 'wsrep_cluster_status'; Variable_name Value wsrep_cluster_status Primary diff --git a/mysql-test/suite/galera_3nodes/t/GCF-354.cnf b/mysql-test/suite/galera_3nodes/t/GCF-354.cnf index 4c5e4854606..e87e65ca58c 100644 --- a/mysql-test/suite/galera_3nodes/t/GCF-354.cnf +++ b/mysql-test/suite/galera_3nodes/t/GCF-354.cnf @@ -3,3 +3,14 @@ [mysqld] wsrep-ignore-apply-errors=0 wsrep_sync_wait=0 +loose-gcf-354=0 +wsrep-debug=1 + +[mysqld.1] +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.wait_prim_timeout=PT60S;gcache.size=1G;pc.weight=4' + +[mysqld.2] +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.wait_prim_timeout=PT60S;gcache.size=1G' + +[mysqld.3] +wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.wait_prim_timeout=PT60S;gcache.size=1G' diff --git a/mysql-test/suite/galera_3nodes/t/GCF-354.test b/mysql-test/suite/galera_3nodes/t/GCF-354.test index 44dfa3deeb7..372f6329e8e 100644 --- a/mysql-test/suite/galera_3nodes/t/GCF-354.test +++ b/mysql-test/suite/galera_3nodes/t/GCF-354.test @@ -2,9 +2,7 @@ --source include/have_innodb.inc --source include/force_restart.inc ---let $galera_connection_name = node_3 ---let $galera_server_number = 3 ---source include/galera_connect.inc +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 # Save original auto_increment_offset values. --let $node_1=node_1 @@ -16,11 +14,11 @@ # 1. Create different inconsistencies on nodes 2 and 3 # --connection node_2 -SET SESSION wsrep_on=OFF; +SET wsrep_on=OFF; DROP SCHEMA test; --connection node_3 -SET SESSION wsrep_on=OFF; +SET wsrep_on=OFF; CREATE TABLE test.t1 (f1 INTEGER NOT NULL PRIMARY KEY) engine=innodb; # # 2. The following should generate different errors on nodes 2 and 3 and @@ -29,10 +27,10 @@ CREATE TABLE test.t1 (f1 INTEGER NOT NULL PRIMARY KEY) engine=innodb; # --connection node_1 CREATE TABLE test.t1 (f1 INTEGER NOT NULL PRIMARY KEY) engine=innodb; -INSERT INTO test.t1 values (1); --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' --source include/wait_condition.inc +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status' --source include/wait_condition.inc SHOW STATUS LIKE 'wsrep_cluster_status'; From 8b51d34462370b96af420587fdc07934abcea8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 23 Jul 2024 11:57:01 +0300 Subject: [PATCH 09/17] MDEV-34640 : galera_var_ignore_apply_errors test freezes Test improvements only to make test more robust. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/disabled.def | 1 - .../r/galera_var_ignore_apply_errors.result | 83 +++++++++---- .../t/galera_var_ignore_apply_errors.cnf | 7 +- .../t/galera_var_ignore_apply_errors.test | 116 +++++++----------- 4 files changed, 104 insertions(+), 103 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 1fdde67fd3d..e00bdbf85c0 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -16,4 +16,3 @@ galera_sequences : MDEV-32561 WSREP FSM failure: no such a transition REPLICATIN galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the galera::ReplicatorSMM::finish_cert() galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() galera_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() -galera_var_ignore_apply_errors : MENT-1997 galera_var_ignore_apply_errors test freezes diff --git a/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result b/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result index 0b32f43704f..ea8510581bb 100644 --- a/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result +++ b/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result @@ -7,27 +7,60 @@ SET GLOBAL wsrep_on = OFF; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = ON; DROP TABLE t1; +connection node_2; +SHOW TABLES; +Tables_in_test +connection node_1; SET GLOBAL wsrep_on = OFF; CREATE SCHEMA s1; SET GLOBAL wsrep_on = ON; DROP SCHEMA s1; +connection node_2; +SHOW SCHEMAS; +Database +information_schema +mtr +mysql +performance_schema +test +connection node_1; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; CREATE INDEX idx1 ON t1 (f1); SET GLOBAL wsrep_on = ON; DROP INDEX idx1 ON t1; +connection node_2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; CREATE INDEX idx1 ON t1 (f1); SET GLOBAL wsrep_on = ON; ALTER TABLE t1 DROP INDEX idx1; +connection node_2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; +connection node_1; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; ALTER TABLE t1 ADD COLUMN f2 INTEGER; SET GLOBAL wsrep_on = ON; ALTER TABLE t1 DROP COLUMN f2; +connection node_2; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; connection node_2; SET GLOBAL wsrep_ignore_apply_errors = 2; @@ -37,12 +70,11 @@ SET GLOBAL wsrep_on = OFF; INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_on = ON; DELETE FROM t1 WHERE f1 = 1; -connection node_1; -SELECT COUNT(*) as expect_0 FROM t1; +SELECT COUNT(*) AS expect_0 FROM t1; expect_0 0 connection node_2; -SELECT COUNT(*) as expect_0 FROM t1; +SELECT COUNT(*) AS expect_0 FROM t1; expect_0 0 DROP TABLE t1; @@ -57,12 +89,11 @@ INSERT INTO t1 VALUES (3); DELETE FROM t1 WHERE f1 = 1; DELETE FROM t1 WHERE f1 = 2; COMMIT; -connection node_1; -SELECT COUNT(*) as expect_1 FROM t1; +SELECT COUNT(*) AS expect_1 FROM t1; expect_1 1 connection node_2; -SELECT COUNT(*) as expect_1 FROM t1; +SELECT COUNT(*) AS expect_1 FROM t1; expect_1 1 DROP TABLE t1; @@ -75,14 +106,14 @@ DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; connection node_1; DELETE FROM t1; -SELECT COUNT(*) as expect_0 FROM t1; +SELECT COUNT(*) AS expect_0 FROM t1; expect_0 0 connection node_2; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -VARIABLE_VALUE = 'Primary' -1 -SELECT COUNT(*) as expect_0 FROM t1; +SELECT VARIABLE_VALUE expect_Primary FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +expect_Primary +Primary +SELECT COUNT(*) AS expect_0 FROM t1; expect_0 0 DROP TABLE t1; @@ -103,14 +134,14 @@ DELETE FROM t1 WHERE f1 = 4; DELETE FROM t1 WHERE f1 = 5; COMMIT; SET AUTOCOMMIT=ON; -SELECT COUNT(*) as expect_0 FROM t1; +SELECT COUNT(*) AS expect_0 FROM t1; expect_0 0 connection node_2; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -VARIABLE_VALUE = 'Primary' -1 -SELECT COUNT(*) as expect_0 FROM t1; +SELECT VARIABLE_VALUE expect_Primary FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +expect_Primary +Primary +SELECT COUNT(*) AS expect_0 FROM t1; expect_0 0 DROP TABLE t1; @@ -126,14 +157,14 @@ DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; connection node_1; DELETE t1, t2 FROM t1 JOIN t2 WHERE t1.f1 = t2.f1; -SELECT COUNT(*) as expect_0 FROM t1; +SELECT COUNT(*) expect_0 FROM t1; expect_0 0 connection node_2; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 'Primary' FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; VARIABLE_VALUE = 'Primary' 1 -SELECT COUNT(*) as expect_0 FROM t1; +SELECT COUNT(*) expect_0 FROM t1; expect_0 0 DROP TABLE t1,t2; @@ -148,20 +179,20 @@ DELETE FROM child WHERE parent_id = 2; SET SESSION wsrep_on = ON; connection node_1; DELETE FROM parent; -SELECT COUNT(*) as expect_0 FROM parent; +SELECT COUNT(*) AS expect_0 FROM parent; expect_0 0 -SELECT COUNT(*) as expect_0 FROM child; +SELECT COUNT(*) AS expect_0 FROM child; expect_0 0 connection node_2; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT VARIABLE_VALUE = 'Primary' FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; VARIABLE_VALUE = 'Primary' 1 -SELECT COUNT(*) as expect_0 FROM parent; +SELECT COUNT(*) AS expect_0 FROM parent; expect_0 0 -SELECT COUNT(*) as expect_0 FROM child; +SELECT COUNT(*) AS expect_0 FROM child; expect_0 0 DROP TABLE child, parent; @@ -175,8 +206,10 @@ connection node_1; CREATE TABLE t1 (f1 INTEGER, f2 INTEGER); DROP TABLE t1; connection node_2; +SELECT * FROM t1; +ERROR 42S02: Table 'test.t1' doesn't exist SET GLOBAL wsrep_ignore_apply_errors = 7; -CALL mtr.add_suppression("Can't find record in 't.*'"); +CALL mtr.add_suppression("Can't find record in "); CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows event"); CALL mtr.add_suppression("Slave SQL: Error 'Unknown table 'test\\.t1'' on query\\. Default database: 'test'\\. Query: 'DROP TABLE t1', Error_code: 1051"); CALL mtr.add_suppression("Slave SQL: Error 'Can't drop database 's1'; database doesn't exist' on query\\. Default database: 'test'\\. Query: 'DROP SCHEMA s1', Error_code: 1008"); diff --git a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf index 545cc8147e0..1d02401decc 100644 --- a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf +++ b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf @@ -1,7 +1,6 @@ !include ../galera_2nodes.cnf -[mysqld.1] -wsrep_debug=1 - -[mysqld.2] +[mysqld] wsrep_debug=1 +wsrep_sync_wait=15 +loose-galera-var-ignore-apply-errors=1 diff --git a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test index e5bff5d8dc4..d5c6521add4 100644 --- a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test +++ b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test @@ -3,7 +3,7 @@ # --source include/galera_cluster.inc - +--source include/force_restart.inc # # Ignore reconciling DDL errors on node_2 @@ -17,41 +17,55 @@ SET GLOBAL wsrep_ignore_apply_errors = 1; SET GLOBAL wsrep_on = OFF; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc DROP TABLE t1; +--connection node_2 +SHOW TABLES; + # Drop schema that does not exist +--connection node_1 SET GLOBAL wsrep_on = OFF; CREATE SCHEMA s1; SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc DROP SCHEMA s1; +--connection node_2 +SHOW SCHEMAS; + # Drop index that does not exist using DROP INDEX +--connection node_1 CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; CREATE INDEX idx1 ON t1 (f1); SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc DROP INDEX idx1 ON t1; + +--connection node_2 +SHOW CREATE TABLE t1; DROP TABLE t1; # Drop index that does not exist using ALTER TABLE +--connection node_1 CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; CREATE INDEX idx1 ON t1 (f1); SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc ALTER TABLE t1 DROP INDEX idx1; + +--connection node_2 +SHOW CREATE TABLE t1; DROP TABLE t1; # Drop column that does not exist +--connection node_1 CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; ALTER TABLE t1 ADD COLUMN f2 INTEGER; SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc ALTER TABLE t1 DROP COLUMN f2; + +--connection node_2 +SHOW CREATE TABLE t1; DROP TABLE t1; @@ -68,21 +82,11 @@ CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc DELETE FROM t1 WHERE f1 = 1; +SELECT COUNT(*) AS expect_0 FROM t1; ---connection node_1 ---let $wait_condition = SELECT COUNT(*) = 0 FROM t1; ---source include/wait_condition.inc -SELECT COUNT(*) as expect_0 FROM t1; --connection node_2 ---source include/galera_wait_ready.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc ---let $wait_condition = SELECT COUNT(*) = 0 FROM t1; ---source include/wait_condition.inc -SELECT COUNT(*) as expect_0 FROM t1; - +SELECT COUNT(*) AS expect_0 FROM t1; DROP TABLE t1; # Delete row that does not exist in a multi statement transaction @@ -92,25 +96,15 @@ INSERT INTO t1 VALUES (2); SET GLOBAL wsrep_on = OFF; INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc START TRANSACTION; INSERT INTO t1 VALUES (3); DELETE FROM t1 WHERE f1 = 1; DELETE FROM t1 WHERE f1 = 2; COMMIT; +SELECT COUNT(*) AS expect_1 FROM t1; ---connection node_1 ---let $wait_condition = SELECT COUNT(*) = 1 FROM t1; ---source include/wait_condition.inc -SELECT COUNT(*) as expect_1 FROM t1; --connection node_2 ---source include/galera_wait_ready.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc ---let $wait_condition = SELECT COUNT(*) = 1 FROM t1; ---source include/wait_condition.inc -SELECT COUNT(*) as expect_1 FROM t1; - +SELECT COUNT(*) AS expect_1 FROM t1; DROP TABLE t1; # @@ -127,21 +121,16 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5); SET SESSION wsrep_on = OFF; DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; ---source include/galera_wait_ready.inc + --connection node_1 DELETE FROM t1; +SELECT COUNT(*) AS expect_0 FROM t1; -SELECT COUNT(*) as expect_0 FROM t1; --connection node_2 ---source include/galera_wait_ready.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; ---source include/wait_condition.inc -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --let $wait_condition = SELECT COUNT(*) = 0 FROM t1; --source include/wait_condition.inc -SELECT COUNT(*) as expect_0 FROM t1; +SELECT VARIABLE_VALUE expect_Primary FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT COUNT(*) AS expect_0 FROM t1; DROP TABLE t1; # @@ -158,10 +147,8 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5); SET SESSION wsrep_on = OFF; DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; ---source include/galera_wait_ready.inc --connection node_1 - SET AUTOCOMMIT=OFF; START TRANSACTION; DELETE FROM t1 WHERE f1 = 1; @@ -171,18 +158,13 @@ DELETE FROM t1 WHERE f1 = 4; DELETE FROM t1 WHERE f1 = 5; COMMIT; SET AUTOCOMMIT=ON; +SELECT COUNT(*) AS expect_0 FROM t1; -SELECT COUNT(*) as expect_0 FROM t1; --connection node_2 ---source include/galera_wait_ready.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; ---source include/wait_condition.inc -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --let $wait_condition = SELECT COUNT(*) = 0 FROM t1; --source include/wait_condition.inc -SELECT COUNT(*) as expect_0 FROM t1; +SELECT VARIABLE_VALUE expect_Primary FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT COUNT(*) AS expect_0 FROM t1; DROP TABLE t1; # @@ -203,22 +185,16 @@ SET SESSION wsrep_on = OFF; DELETE FROM t2 WHERE f1 = 2; DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; ---source include/galera_wait_ready.inc --connection node_1 DELETE t1, t2 FROM t1 JOIN t2 WHERE t1.f1 = t2.f1; -SELECT COUNT(*) as expect_0 FROM t1; +SELECT COUNT(*) expect_0 FROM t1; --connection node_2 ---source include/galera_wait_ready.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; ---source include/wait_condition.inc -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; --let $wait_condition = SELECT COUNT(*) = 0 FROM t1; --source include/wait_condition.inc -SELECT COUNT(*) as expect_0 FROM t1; +SELECT VARIABLE_VALUE = 'Primary' FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT COUNT(*) expect_0 FROM t1; DROP TABLE t1,t2; # @@ -238,26 +214,18 @@ INSERT INTO child VALUES (1,1),(2,2),(3,3); SET SESSION wsrep_on = OFF; DELETE FROM child WHERE parent_id = 2; SET SESSION wsrep_on = ON; ---source include/galera_wait_ready.inc --connection node_1 DELETE FROM parent; -SELECT COUNT(*) as expect_0 FROM parent; -SELECT COUNT(*) as expect_0 FROM child; +SELECT COUNT(*) AS expect_0 FROM parent; +SELECT COUNT(*) AS expect_0 FROM child; --connection node_2 ---source include/galera_wait_ready.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; ---source include/wait_condition.inc -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; ---let $wait_condition = SELECT COUNT(*) = 0 FROM parent; ---source include/wait_condition.inc --let $wait_condition = SELECT COUNT(*) = 0 FROM child; --source include/wait_condition.inc -SELECT COUNT(*) as expect_0 FROM parent; -SELECT COUNT(*) as expect_0 FROM child; +SELECT VARIABLE_VALUE = 'Primary' FROM performance_schema.global_status WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +SELECT COUNT(*) AS expect_0 FROM parent; +SELECT COUNT(*) AS expect_0 FROM child; DROP TABLE child, parent; # @@ -272,15 +240,17 @@ SET GLOBAL wsrep_ignore_apply_errors = 4; SET GLOBAL wsrep_on = OFF; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = ON; ---source include/galera_wait_ready.inc + --connection node_1 CREATE TABLE t1 (f1 INTEGER, f2 INTEGER); DROP TABLE t1; --connection node_2 +--error ER_NO_SUCH_TABLE +SELECT * FROM t1; SET GLOBAL wsrep_ignore_apply_errors = 7; -CALL mtr.add_suppression("Can't find record in 't.*'"); +CALL mtr.add_suppression("Can't find record in "); CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows event"); CALL mtr.add_suppression("Slave SQL: Error 'Unknown table 'test\\.t1'' on query\\. Default database: 'test'\\. Query: 'DROP TABLE t1', Error_code: 1051"); CALL mtr.add_suppression("Slave SQL: Error 'Can't drop database 's1'; database doesn't exist' on query\\. Default database: 'test'\\. Query: 'DROP SCHEMA s1', Error_code: 1008"); From bce3f3f6287f706e90e067b16f9a8203f64a30a7 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 2 Aug 2024 10:29:08 +1000 Subject: [PATCH 10/17] MDEV-34682 Reset spider_hton_ptr in error mode of spider_db_init() --- .../spider/bugfix/r/mdev_34682.result | 19 +++++++++++++++++++ .../spider/bugfix/t/mdev_34682.test | 14 ++++++++++++++ .../spider/include/clean_up_spider.inc | 10 +++++----- storage/spider/spd_table.cc | 1 + 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_34682.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_34682.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_34682.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_34682.result new file mode 100644 index 00000000000..7253e136488 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_34682.result @@ -0,0 +1,19 @@ +set @old_aria_encrypt_tables=@@global.aria_encrypt_tables; +set global aria_encrypt_tables=ON; +CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; +call mtr.add_suppression(".*\\[ERROR\\] SPIDER plugin initialization failed at.* by 'Initialization of encryption failed for"); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed."); +INSTALL PLUGIN spider SONAME 'ha_spider.so'; +ERROR HY000: Can't initialize function 'spider'; Plugin initialization function failed. +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); +ERROR HY000: Can't initialize function 'spider_direct_sql'; Plugin 'SPIDER' is not loaded +Warnings: +Note 1305 FUNCTION test.spider_flush_table_mon_cache does not exist +Warnings: +Note 1305 FUNCTION test.spider_copy_tables does not exist +Warnings: +Note 1305 FUNCTION test.spider_ping_table does not exist +Warnings: +Note 1305 FUNCTION test.spider_bg_direct_sql does not exist +Warnings: +Note 1305 SONAME ha_spider.so does not exist diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_34682.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_34682.test new file mode 100644 index 00000000000..d61f7db4330 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_34682.test @@ -0,0 +1,14 @@ +set @old_aria_encrypt_tables=@@global.aria_encrypt_tables; +set global aria_encrypt_tables=ON; + +CREATE FUNCTION spider_direct_sql RETURNS INT SONAME 'ha_spider.so'; +call mtr.add_suppression(".*\\[ERROR\\] SPIDER plugin initialization failed at.* by 'Initialization of encryption failed for"); +call mtr.add_suppression(".*\\[ERROR\\] Plugin 'SPIDER' registration as a STORAGE ENGINE failed."); +--error ER_CANT_INITIALIZE_UDF +INSTALL PLUGIN spider SONAME 'ha_spider.so'; +--error ER_CANT_INITIALIZE_UDF +SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); + +--disable_query_log +--source ../../include/clean_up_spider.inc +set global aria_encrypt_tables=@old_aria_encrypt_tables; diff --git a/storage/spider/mysql-test/spider/include/clean_up_spider.inc b/storage/spider/mysql-test/spider/include/clean_up_spider.inc index 249606ec774..5b016e731d9 100644 --- a/storage/spider/mysql-test/spider/include/clean_up_spider.inc +++ b/storage/spider/mysql-test/spider/include/clean_up_spider.inc @@ -1,8 +1,8 @@ -DROP FUNCTION spider_flush_table_mon_cache; -DROP FUNCTION spider_copy_tables; -DROP FUNCTION spider_ping_table; -DROP FUNCTION spider_bg_direct_sql; -DROP FUNCTION spider_direct_sql; +DROP FUNCTION IF EXISTS spider_flush_table_mon_cache; +DROP FUNCTION IF EXISTS spider_copy_tables; +DROP FUNCTION IF EXISTS spider_ping_table; +DROP FUNCTION IF EXISTS spider_bg_direct_sql; +DROP FUNCTION IF EXISTS spider_direct_sql; UNINSTALL SONAME IF EXISTS 'ha_spider'; DROP TABLE IF EXISTS mysql.spider_xa; DROP TABLE IF EXISTS mysql.spider_xa_member; diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 461e47dd012..c1166c4e7d5 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -6805,6 +6805,7 @@ error_pt_attr_setstate: pthread_attr_destroy(&spider_pt_attr); error_pt_attr_init: #endif + spider_hton_ptr= NULL; DBUG_RETURN(error_num); } From 25e2d0a6bbd64e9b509f4a2d00a9d8736367965e Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Tue, 6 Aug 2024 15:26:55 +0200 Subject: [PATCH 11/17] MDEV-34632 Assertion failed in handler::assert_icp_limitations Assertion `table->field[0]->ptr >= table->record[0] && table->field[0]->ptr <= table->record[0] + table->s->reclength' failed in handler::assert_icp_limitations. table->move_fields has some limitations: 1. It cannot be used in cascade 2. It should always have a restoring pair. Rule 1 is covered by assertions in handler::assert_icp_limitations and handler::ptr_in_record (commit 30894fe9a9). Rule 2 should be manually maintained with care. Hopefully, the rule 1 assertions may sometimes help as well. In ha_myisam::repair, both rules are broken. table->move_fields is used asymmetrically there: it is set on every param->fix_record call (i.e. in compute_vcols) but is restored only once, in the end of repair. The reason to updating field ptr's for every call is that compute_vcols can (supposedly) be called in parallel, that is, with the same table, but different records. The condition to "unmove" the pointers in ha_myisam::restore_vcos_after_repair is incorrect, when stored vcols are available, and myisam stores a VIRTUAL field if it's the only field in the table (the record cannot be of zero length). This patch solves the problem by "unmoving" the pointers symmetrically, in compute_vcols. That is, both rules will be preserved maintained. --- mysql-test/suite/vcol/inc/vcol_keys.inc | 17 +++++++ .../suite/vcol/r/vcol_keys_innodb.result | 19 ++++++++ .../suite/vcol/r/vcol_keys_myisam.result | 19 ++++++++ storage/myisam/ha_myisam.cc | 47 ++++++------------- storage/myisam/ha_myisam.h | 1 - 5 files changed, 70 insertions(+), 33 deletions(-) diff --git a/mysql-test/suite/vcol/inc/vcol_keys.inc b/mysql-test/suite/vcol/inc/vcol_keys.inc index 8ec89daff0b..d209e24811b 100644 --- a/mysql-test/suite/vcol/inc/vcol_keys.inc +++ b/mysql-test/suite/vcol/inc/vcol_keys.inc @@ -15,6 +15,8 @@ ################################################################################ +--source include/have_sequence.inc + --echo # - UNIQUE KEY --echo # - INDEX --echo # - FULLTEXT INDEX @@ -231,3 +233,18 @@ CREATE TABLE t1 ( DELETE FROM t1 WHERE vc IS NULL ORDER BY pk; DROP TABLE t1; +# +# MDEV-34632 Assertion `table->field[0]->ptr >= table->record[0] && +# table->field[0]->ptr <= table->record[0] + table->s->reclength' failed in +# void handler::assert_icp_limitations(uchar*) +# +SET sql_mode=''; +CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL,KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 SELECT 1 FROM seq_1_to_2 ; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL,KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 SELECT 1 UNION SELECT 1; +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/suite/vcol/r/vcol_keys_innodb.result b/mysql-test/suite/vcol/r/vcol_keys_innodb.result index c07e00a5e20..51e97864a25 100644 --- a/mysql-test/suite/vcol/r/vcol_keys_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_keys_innodb.result @@ -215,6 +215,25 @@ INDEX(vc(32)) ); DELETE FROM t1 WHERE vc IS NULL ORDER BY pk; DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL,KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 SELECT 1 FROM seq_1_to_2 ; +Warnings: +Warning 1906 The value specified for generated column 'a' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'a' in table 't1' has been ignored +SELECT * FROM t1; +a +1 +1 +DROP TABLE t1; +CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL,KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 SELECT 1 UNION SELECT 1; +Warnings: +Warning 1906 The value specified for generated column 'a' in table 't1' has been ignored +SELECT * FROM t1; +a +1 +DROP TABLE t1; # # MDEV-11737 Failing assertion: block->magic_n == MEM_BLOCK_MAGIC_N # diff --git a/mysql-test/suite/vcol/r/vcol_keys_myisam.result b/mysql-test/suite/vcol/r/vcol_keys_myisam.result index 0112c3986e8..2a05464846a 100644 --- a/mysql-test/suite/vcol/r/vcol_keys_myisam.result +++ b/mysql-test/suite/vcol/r/vcol_keys_myisam.result @@ -209,6 +209,25 @@ INDEX(vc(32)) ); DELETE FROM t1 WHERE vc IS NULL ORDER BY pk; DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL,KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 SELECT 1 FROM seq_1_to_2 ; +Warnings: +Warning 1906 The value specified for generated column 'a' in table 't1' has been ignored +Warning 1906 The value specified for generated column 'a' in table 't1' has been ignored +SELECT * FROM t1; +a +1 +1 +DROP TABLE t1; +CREATE TABLE t1 (a INT GENERATED ALWAYS AS (1) VIRTUAL,KEY(a)) ENGINE=MyISAM; +INSERT INTO t1 SELECT 1 UNION SELECT 1; +Warnings: +Warning 1906 The value specified for generated column 'a' in table 't1' has been ignored +SELECT * FROM t1; +a +1 +DROP TABLE t1; # # Original test # diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 022a7bb6819..c5d13273b23 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -721,29 +721,32 @@ static void init_compute_vcols(void *table) static int compute_vcols(MI_INFO *info, uchar *record, int keynum) { + int error= 0; /* This mutex is needed for parallel repair */ mysql_mutex_lock(&info->s->intern_lock); TABLE *table= (TABLE*)(info->external_ref); - table->move_fields(table->field, record, table->field[0]->record_ptr()); + table->move_fields(table->field, record, table->record[0]); if (keynum == -1) // update all vcols { - int error= table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_READ); + error= table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_READ); if (table->update_virtual_fields(table->file, VCOL_UPDATE_INDEXED)) error= 1; - mysql_mutex_unlock(&info->s->intern_lock); - return error; } - // update only one key - KEY *key= table->key_info + keynum; - KEY_PART_INFO *kp= key->key_part, *end= kp + key->ext_key_parts; - for (; kp < end; kp++) + else { - Field *f= table->field[kp->fieldnr - 1]; - if (f->vcol_info && !f->vcol_info->stored_in_db) - table->update_virtual_field(f, false); + // update only one key + KEY *key= table->key_info + keynum; + KEY_PART_INFO *kp= key->key_part, *end= kp + key->ext_key_parts; + for (; kp < end; kp++) + { + Field *f= table->field[kp->fieldnr - 1]; + if (f->vcol_info && !f->vcol_info->stored_in_db) + table->update_virtual_field(f, false); + } } + table->move_fields(table->field, table->record[0], record); mysql_mutex_unlock(&info->s->intern_lock); - return 0; + return error; } } @@ -1025,16 +1028,6 @@ void ha_myisam::setup_vcols_for_repair(HA_CHECK *param) table->use_all_columns(); } -void ha_myisam::restore_vcos_after_repair() -{ - if (file->s->base.reclength < file->s->vreclength) - { - table->move_fields(table->field, table->record[0], - table->field[0]->record_ptr()); - table->default_column_bitmaps(); - } -} - int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) { if (!file) return HA_ADMIN_INTERNAL_ERROR; @@ -1131,8 +1124,6 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt) file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED; } - restore_vcos_after_repair(); - thd_proc_info(thd, old_proc_info); return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; } @@ -1178,8 +1169,6 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt) else if (!mi_is_crashed(file) && !thd->killed) mi_mark_crashed(file); - restore_vcos_after_repair(); - return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK; } @@ -1229,8 +1218,6 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) break; } - restore_vcos_after_repair(); - if (!error && start_records != file->state->records && !(check_opt->flags & T_VERY_SILENT)) { @@ -1268,8 +1255,6 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) error= repair(thd,*param,1); } - restore_vcos_after_repair(); - return error; } @@ -1707,8 +1692,6 @@ int ha_myisam::enable_indexes(key_map map, bool persist) } info(HA_STATUS_CONST); thd_proc_info(thd, save_proc_info); - - restore_vcos_after_repair(); } DBUG_RETURN(error); } diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 46202468475..e72636e9e22 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -49,7 +49,6 @@ class ha_myisam final : public handler bool can_enable_indexes; int repair(THD *thd, HA_CHECK ¶m, bool optimize); void setup_vcols_for_repair(HA_CHECK *param); - void restore_vcos_after_repair(); public: ha_myisam(handlerton *hton, TABLE_SHARE *table_arg); From 56fb04aa7c78c11649805df0a8ad9d7de08f374d Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Thu, 8 Aug 2024 17:56:56 -0400 Subject: [PATCH 12/17] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 05e6832c930..da85fbe02b8 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=26 +MYSQL_VERSION_PATCH=27 SERVER_MATURITY=stable From d1713666b06ae5525f85afe5a5c3e46ab2c26a0a Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 19 Jul 2024 21:44:34 +0200 Subject: [PATCH 13/17] Fix incorrect setting of opt_local_file in mysqlimport, for named pipe For named pipe, server and client are on the same machine, and opt_local_infile just adds unnecessary copying via "load data local infile" --- client/mysqlimport.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 3a9f9005cb6..405eda8cc10 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -249,7 +249,6 @@ get_one_option(const struct my_option *opt, const char *argument, #ifdef __WIN__ case 'W': opt_protocol = MYSQL_PROTOCOL_PIPE; - opt_local_file=1; break; #endif case OPT_MYSQL_PROTOCOL: From b619be35693b531bf34cdb00cf41318975cbf87b Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 29 Jul 2024 01:03:17 +0200 Subject: [PATCH 14/17] Support -DCONC_WITH_SSL parameter passed to CMake Usually it is not needed, but sometimes we need to testing interoperability, e.g OpenSSL server / SCHANNEL client, or WolfSSL server / OpenSSL client. --- cmake/mariadb_connector_c.cmake | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake index b4f56597775..9b4f25498fd 100644 --- a/cmake/mariadb_connector_c.cmake +++ b/cmake/mariadb_connector_c.cmake @@ -8,15 +8,17 @@ SET(CONC_WITH_SIGNCODE ${SIGNCODE}) SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS}) SET(CONC_WITH_EXTERNAL_ZLIB ON) -IF(SSL_DEFINES MATCHES "WOLFSSL") - IF(WIN32) - SET(CONC_WITH_SSL "SCHANNEL") +IF(NOT CONC_WITH_SSL) + IF(SSL_DEFINES MATCHES "WOLFSSL") + IF(WIN32) + SET(CONC_WITH_SSL "SCHANNEL") + ELSE() + SET(CONC_WITH_SSL "GNUTLS") # that's what debian wants, right? + ENDIF() ELSE() - SET(CONC_WITH_SSL "GNUTLS") # that's what debian wants, right? + SET(CONC_WITH_SSL "OPENSSL") + SET(OPENSSL_FOUND TRUE) ENDIF() -ELSE() - SET(CONC_WITH_SSL "OPENSSL") - SET(OPENSSL_FOUND TRUE) ENDIF() SET(CONC_WITH_CURL OFF) From 62fd7b4cd2cd0a8527c30e3661fc917b7e07522b Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 29 Jul 2024 01:10:32 +0200 Subject: [PATCH 15/17] OpenSSL - set all heap functions in CRYPTO_set_mem_functions. The reason is that on Windows, OpenSSL can be built with different C runtime than the server (e.g Debug runtime in debug vcpkg build). Overwriting only malloc(), with CRT that server is using can cause mixup of incompatible malloc() and free() inside openssl. To fix, overwrite all memory functions. --- mysys_ssl/openssl.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mysys_ssl/openssl.c b/mysys_ssl/openssl.c index 8adaeae4069..e0271817309 100644 --- a/mysys_ssl/openssl.c +++ b/mysys_ssl/openssl.c @@ -47,12 +47,25 @@ static void *coc_malloc(size_t size, const char *f __attribute__((unused)), return malloc(size); } +static void *coc_realloc(void *addr, size_t num, + const char *file __attribute__((unused)), + int line __attribute__((unused))) +{ + return realloc(addr, num); +} + +static void coc_free(void *addr, const char *file __attribute__((unused)), + int line __attribute__((unused))) +{ + free(addr); +} + int check_openssl_compatibility() { EVP_CIPHER_CTX *evp_ctx; EVP_MD_CTX *md5_ctx; - if (!CRYPTO_set_mem_functions(coc_malloc, NULL, NULL)) + if (!CRYPTO_set_mem_functions(coc_malloc, coc_realloc, coc_free)) return 0; testing= 1; From 4a67bd5105188d10de45521ef19ea11772eed1dc Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 8 Aug 2024 11:13:41 +0200 Subject: [PATCH 16/17] Fix server on windows, so it does not write to error log byte-by-byte fprintf() on Windows, when used on unbuffered FILE*, writes bytewise. This can make crash handler messages harder to read, if they are mixed up with other error log output. Fixed , on Windows, by using a small buffer for formatting, and fwrite instead of fprintf, if buffer is large enough for message. --- sql/log.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sql/log.cc b/sql/log.cc index 01700cc048d..4f74900e59a 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -9215,6 +9215,25 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, #ifndef EMBEDDED_LIBRARY +#ifndef _WIN32 +#define fprintf_stderr(format, ...) fprintf(stderr, format, __VA_ARGS__) +#else +/* + On Windows, if FILE* is unbuffered, fprintf() writes output byte by byte. + This is suboptimal for printing to error log, we want full message at once. +*/ +#define fprintf_stderr(format, ...) \ + do \ + { \ + char buf[256]; \ + size_t len= snprintf(buf, sizeof(buf), format, __VA_ARGS__); \ + if (len >= sizeof(buf)) \ + fprintf(stderr, format, __VA_ARGS__); \ + else \ + fwrite(buf, len, 1, stderr); \ + } while (0) +#endif + static void print_buffer_to_file(enum loglevel level, const char *buffer, size_t length) { @@ -9248,7 +9267,7 @@ static void print_buffer_to_file(enum loglevel level, const char *buffer, localtime_r(&skr, &tm_tmp); start=&tm_tmp; - fprintf(stderr, "%d-%02d-%02d %2d:%02d:%02d %lu [%s] %.*s%.*s\n", + fprintf_stderr( "%d-%02d-%02d %2d:%02d:%02d %lu [%s] %.*s%.*s\n", start->tm_year + 1900, start->tm_mon+1, start->tm_mday, From e997bf58fbefa06d47403001482ab81502f764dd Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 6 Aug 2024 14:35:39 +0200 Subject: [PATCH 17/17] MDEV-34714 perror-win test failure on localized Windows Let perror produce OS error messages in English --- extra/perror.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/perror.c b/extra/perror.c index d678d46d1be..4710b28035a 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -206,7 +206,8 @@ static my_bool print_win_error_msg(DWORD error, my_bool verbose) char *s; if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, 0, (char *)&s, 0, + NULL, error, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), + (char *) &s, 0, NULL)) { char* end = s + strlen(s) - 1;