From 0d7ef4f4785bd0181e6a4c60f4000ecc5deb085d Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 3 Apr 2025 12:19:36 +0530 Subject: [PATCH 01/30] MDEV-36236 Instant alter aborts when InnoDB fails to rollback instant operation Problem: ======== - InnoDB does consecutive instant alter operation, first instant DDL fails, it fails to reset the old instant information in table during rollback. This lead to consecutive instant alter to have wrong assumption about the exisitng instant column information. Fix: ==== dict_table_t::instant_column(): Duplicate the instant information field of the table. By doing this, InnoDB alter retains the old instant information and reset it during rollback operation --- .../innodb/r/instant_alter_debug,redundant.rdiff | 7 ++++--- .../suite/innodb/r/instant_alter_debug.result | 11 +++++++++++ .../suite/innodb/t/instant_alter_debug.test | 12 ++++++++++-- storage/innobase/handler/handler0alter.cc | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff b/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff index cf72c37bde8..ba4aeadaa50 100644 --- a/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff +++ b/mysql-test/suite/innodb/r/instant_alter_debug,redundant.rdiff @@ -1,8 +1,9 @@ -@@ -527,6 +527,6 @@ +@@ -576,7 +576,7 @@ FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; instants -37 +38 - SET GLOBAL innodb_stats_persistent = @save_stats_persistent; - # End of 10.6 tests + CREATE TABLE t1(f1 INT, f2 TEXT)ENGINE=InnoDB; + INSERT INTO t1 VALUES(1, 'a'); + ALTER TABLE t1 ADD COLUMN f3 TEXT FIRST; diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result index 53da7b6f5dc..05211d3b55e 100644 --- a/mysql-test/suite/innodb/r/instant_alter_debug.result +++ b/mysql-test/suite/innodb/r/instant_alter_debug.result @@ -577,5 +577,16 @@ FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; instants 37 +CREATE TABLE t1(f1 INT, f2 TEXT)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 'a'); +ALTER TABLE t1 ADD COLUMN f3 TEXT FIRST; +SET STATEMENT DEBUG_DBUG="+d,instant_insert_fail" FOR +ALTER TABLE t1 DROP COLUMN f1; +ERROR HY000: Internal error: InnoDB: Insert into SYS_COLUMNS failed +ALTER TABLE t1 DROP COLUMN f1; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; SET GLOBAL innodb_stats_persistent = @save_stats_persistent; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/instant_alter_debug.test b/mysql-test/suite/innodb/t/instant_alter_debug.test index dd11e09629c..07118aa2983 100644 --- a/mysql-test/suite/innodb/t/instant_alter_debug.test +++ b/mysql-test/suite/innodb/t/instant_alter_debug.test @@ -657,11 +657,19 @@ DROP TABLE t1; SET DEBUG_SYNC=RESET; --echo # End of 10.5 tests - SELECT variable_value-@old_instant instants FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; -SET GLOBAL innodb_stats_persistent = @save_stats_persistent; +CREATE TABLE t1(f1 INT, f2 TEXT)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 'a'); +ALTER TABLE t1 ADD COLUMN f3 TEXT FIRST; +--error ER_INTERNAL_ERROR +SET STATEMENT DEBUG_DBUG="+d,instant_insert_fail" FOR +ALTER TABLE t1 DROP COLUMN f1; +ALTER TABLE t1 DROP COLUMN f1; +CHECK TABLE t1; +DROP TABLE t1; +SET GLOBAL innodb_stats_persistent = @save_stats_persistent; --echo # End of 10.6 tests diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 3fe02af5beb..3459be3a06d 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -621,6 +621,16 @@ inline bool dict_table_t::instant_column(const dict_table_t& table, } dict_index_t* index = dict_table_get_first_index(this); + if (instant) { + instant->field_map= static_cast( + mem_heap_dup(heap, instant->field_map, + (index->n_fields - + index->first_user_field()) * + sizeof *instant->field_map)); + instant= static_cast( + mem_heap_dup(heap, instant, sizeof *instant)); + } + bool metadata_changed; { const dict_index_t& i = *dict_table_get_first_index(&table); @@ -5515,6 +5525,11 @@ static bool innodb_insert_sys_columns( return false; } + DBUG_EXECUTE_IF("instant_insert_fail", + my_error(ER_INTERNAL_ERROR, MYF(0), + "InnoDB: Insert into SYS_COLUMNS failed"); + return true;); + if (DB_SUCCESS != que_eval_sql( info, "PROCEDURE ADD_COL () IS\n" From b11772d9a54b596d56e071543e34692830068bbd Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 3 Apr 2025 16:43:01 +0530 Subject: [PATCH 02/30] MDEV-33167 ASAN errors in dict_sys_t::load_table / get_foreign_key_info after failing to load a table Problem: ======= - While loading the foreign key constraints for the parent table, if child table wasn't open then InnoDB uses the parent table heap to store the child table name in fk_tables list. If the consecutive foreign key relation for the parent table fails with error, InnoDB evicts the parent table from memory. But InnoDB accesses the evicted table memory again in dict_sys.load_table() Solution: ======== dict_load_table_one(): In case of error, remove the child table names which was added during dict_load_foreigns() --- mysql-test/suite/innodb/r/foreign_key.result | 21 +++++++++++-- mysql-test/suite/innodb/t/foreign_key.test | 32 +++++++++++++++++--- storage/innobase/dict/dict0load.cc | 2 ++ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result index e7d0454df6e..236953795e6 100644 --- a/mysql-test/suite/innodb/r/foreign_key.result +++ b/mysql-test/suite/innodb/r/foreign_key.result @@ -155,7 +155,6 @@ INSERT INTO parent SET a=0; FLUSH TABLES; # restart disconnect incomplete; -SET @save_stats_persistent = @@GLOBAL.innodb_stats_persistent; SET GLOBAL innodb_stats_persistent = 0; INSERT INTO child SET a=0; INSERT INTO child SET a=1; @@ -1182,5 +1181,23 @@ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fail ALTER TABLE t2 ADD KEY(b), ALGORITHM=NOCOPY; DELETE FROM t1; DROP TABLE t2, t1; +# +# MDEV-33167 ASAN errors after failing to load foreign key +# relation for the table +# +call mtr.add_suppression("InnoDB: Load table `test`.`t3` failed, the table has missing foreign key indexes. Turn off 'foreign_key_checks' and try again."); +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t1(f1 VARCHAR(8), +FOREIGN KEY(f1) REFERENCES test.t3(f1))ENGINE=InnoDB; +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t2(f1 VARCHAR(8), +FOREIGN KEY(f1) REFERENCES test.t3(f1)) +ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t3(f1 VARCHAR(8) PRIMARY KEY) +ENGINE=InnoDB DEFAULT CHARSET=latin1; +set GLOBAL innodb_fast_shutdown=0; +# restart +ALTER TABLE t2 FORCE; +DROP TABLE t2, t1, t3; # End of 10.6 tests -SET GLOBAL innodb_stats_persistent = @save_stats_persistent; diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test index 6a65de0e9b0..e7761f3cf4b 100644 --- a/mysql-test/suite/innodb/t/foreign_key.test +++ b/mysql-test/suite/innodb/t/foreign_key.test @@ -133,7 +133,6 @@ FLUSH TABLES; --let $shutdown_timeout= disconnect incomplete; -SET @save_stats_persistent = @@GLOBAL.innodb_stats_persistent; SET GLOBAL innodb_stats_persistent = 0; INSERT INTO child SET a=0; @@ -1245,8 +1244,31 @@ ALTER TABLE t2 ADD KEY(b), ALGORITHM=NOCOPY; DELETE FROM t1; DROP TABLE t2, t1; +--echo # +--echo # MDEV-33167 ASAN errors after failing to load foreign key +--echo # relation for the table +--echo # +call mtr.add_suppression("InnoDB: Load table `test`.`t3` failed, the table has missing foreign key indexes. Turn off 'foreign_key_checks' and try again."); +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t1(f1 VARCHAR(8), + FOREIGN KEY(f1) REFERENCES test.t3(f1))ENGINE=InnoDB; + +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t2(f1 VARCHAR(8), + FOREIGN KEY(f1) REFERENCES test.t3(f1)) + ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; + +SET STATEMENT FOREIGN_KEY_CHECKS = 0 FOR +CREATE TABLE t3(f1 VARCHAR(8) PRIMARY KEY) + ENGINE=InnoDB DEFAULT CHARSET=latin1; + +set GLOBAL innodb_fast_shutdown=0; +--let $shutdown_timeout= +--source include/restart_mysqld.inc +# Error encountered while loading the foreign key +# constraint for t3. t1 wasn't loaded into memory yet +# t2 failed to find index for foreign key relation +ALTER TABLE t2 FORCE; +DROP TABLE t2, t1, t3; + --echo # End of 10.6 tests - -SET GLOBAL innodb_stats_persistent = @save_stats_persistent; - ---source include/wait_until_count_sessions.inc diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 917c4d51ee9..0071e7e8afe 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -2515,10 +2515,12 @@ corrupted: if (!table->is_readable()) { /* Don't attempt to load the indexes from disk. */ } else if (err == DB_SUCCESS) { + auto i = fk_tables.size(); err = dict_load_foreigns(table->name.m_name, nullptr, 0, true, ignore_err, fk_tables); if (err != DB_SUCCESS) { + fk_tables.erase(fk_tables.begin() + i, fk_tables.end()); ib::warn() << "Load table " << table->name << " failed, the table has missing" " foreign key indexes. Turn off" From db4763a0d1d1187d349b3a24d9e13e41dd5b33f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 7 Apr 2025 10:25:34 +0300 Subject: [PATCH 03/30] Fix a slow test When we expect a lock wait timeout, let us override the default innodb_lock_wait_timeout=50 with the minimum timeout of 1 second. --- mysql-test/suite/innodb/r/innodb_bug52663.result | 4 +++- mysql-test/suite/innodb/t/innodb_bug52663.test | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb_bug52663.result b/mysql-test/suite/innodb/r/innodb_bug52663.result index 348a7b21022..a87638d6555 100644 --- a/mysql-test/suite/innodb/r/innodb_bug52663.result +++ b/mysql-test/suite/innodb/r/innodb_bug52663.result @@ -1,10 +1,11 @@ +SET @save_innodb_timeout=@@innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout=1; set session transaction isolation level read committed; create table innodb_bug52663 (what varchar(5), id integer, count integer, primary key (what, id)) engine=innodb; insert into innodb_bug52663 values ('total', 0, 0); begin; connect addconroot, localhost, root,,; -connection addconroot; set session transaction isolation level read committed; begin; connection default; @@ -31,3 +32,4 @@ select * from innodb_bug52663; what id count total 0 2 drop table innodb_bug52663; +SET GLOBAL innodb_lock_wait_timeout=@save_innodb_timeout; diff --git a/mysql-test/suite/innodb/t/innodb_bug52663.test b/mysql-test/suite/innodb/t/innodb_bug52663.test index dd246297d94..1d12fb63ef8 100644 --- a/mysql-test/suite/innodb/t/innodb_bug52663.test +++ b/mysql-test/suite/innodb/t/innodb_bug52663.test @@ -1,6 +1,7 @@ ---source include/long_test.inc --source include/have_innodb.inc +SET @save_innodb_timeout=@@innodb_lock_wait_timeout; +SET GLOBAL innodb_lock_wait_timeout=1; set session transaction isolation level read committed; create table innodb_bug52663 (what varchar(5), id integer, count integer, primary key @@ -9,7 +10,6 @@ insert into innodb_bug52663 values ('total', 0, 0); begin; connect (addconroot, localhost, root,,); -connection addconroot; set session transaction isolation level read committed; begin; @@ -33,3 +33,4 @@ select * from innodb_bug52663; connection default; select * from innodb_bug52663; drop table innodb_bug52663; +SET GLOBAL innodb_lock_wait_timeout=@save_innodb_timeout; From 2ba49bd8048ffea9d2150ca1295d9d256807ae44 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 28 Mar 2025 18:11:09 +1100 Subject: [PATCH 04/30] mroonga: correct offsetof calculation Using a null pointer as a basic for calculation was undefined behaviour. --- storage/mroonga/vendor/groonga/lib/db.c | 4 ++-- storage/mroonga/vendor/groonga/lib/hash.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/storage/mroonga/vendor/groonga/lib/db.c b/storage/mroonga/vendor/groonga/lib/db.c index 65463bdad20..3c2f98e4cde 100644 --- a/storage/mroonga/vendor/groonga/lib/db.c +++ b/storage/mroonga/vendor/groonga/lib/db.c @@ -969,8 +969,8 @@ calc_rec_size(grn_table_flags flags, uint32_t max_n_subrecs, uint32_t range_size *subrec_size = range_size + sizeof(uint32_t) + sizeof(uint32_t); break; } - *value_size = (uintptr_t)GRN_RSET_SUBRECS_NTH((((grn_rset_recinfo *)0)->subrecs), - *subrec_size, max_n_subrecs); + *value_size = (uintptr_t) GRN_RSET_SUBRECS_NTH(offsetof(grn_rset_recinfo, subrecs), + *subrec_size, max_n_subrecs); } else { *value_size = range_size; } diff --git a/storage/mroonga/vendor/groonga/lib/hash.c b/storage/mroonga/vendor/groonga/lib/hash.c index 8cdae7bad5e..a2254d2ea2f 100644 --- a/storage/mroonga/vendor/groonga/lib/hash.c +++ b/storage/mroonga/vendor/groonga/lib/hash.c @@ -1727,15 +1727,15 @@ grn_io_hash_calculate_entry_size(uint32_t key_size, uint32_t value_size, { if (flags & GRN_OBJ_KEY_VAR_SIZE) { if (flags & GRN_OBJ_KEY_LARGE) { - return (uintptr_t)((grn_io_hash_entry_large *)0)->value + value_size; + return offsetof(grn_io_hash_entry_large, value) + value_size; } else { - return (uintptr_t)((grn_io_hash_entry_normal *)0)->value + value_size; + return offsetof(grn_io_hash_entry_normal, value) + value_size; } } else { if (key_size == sizeof(uint32_t)) { - return (uintptr_t)((grn_plain_hash_entry *)0)->value + value_size; + return offsetof(grn_plain_hash_entry, value) + value_size; } else { - return (uintptr_t)((grn_rich_hash_entry *)0)->key_and_value + return offsetof(grn_rich_hash_entry, key_and_value) + key_size + value_size; } } @@ -1865,12 +1865,12 @@ grn_tiny_hash_calculate_entry_size(uint32_t key_size, uint32_t value_size, { uint32_t entry_size; if (flags & GRN_OBJ_KEY_VAR_SIZE) { - entry_size = (uintptr_t)((grn_tiny_hash_entry *)0)->value + value_size; + entry_size = offsetof(grn_tiny_hash_entry, value) + value_size; } else { if (key_size == sizeof(uint32_t)) { - entry_size = (uintptr_t)((grn_plain_hash_entry *)0)->value + value_size; + entry_size = offsetof(grn_plain_hash_entry, value) + value_size; } else { - entry_size = (uintptr_t)((grn_rich_hash_entry *)0)->key_and_value + entry_size = offsetof(grn_rich_hash_entry, key_and_value) + key_size + value_size; } } From b316a7135b146968d78b2c1d81bca61fdb7cbadb Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 28 Mar 2025 18:12:24 +1100 Subject: [PATCH 05/30] mroonga: undefined behaviour fix The value of dv[0].data being null showed up in the mtr tests: mroonga/storage.alter_table_fulltext_add_no_primary_key as: /source/storage/mroonga/vendor/groonga/lib/ii.c:2052:37: runtime error: applying non-zero offset 28 to null pointer Correct this by entrying the if condition on null pointer value. The free is valid, and the data of size is allocated. --- storage/mroonga/vendor/groonga/lib/ii.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/mroonga/vendor/groonga/lib/ii.c b/storage/mroonga/vendor/groonga/lib/ii.c index 3e402e15e7e..8ce4857bfc2 100644 --- a/storage/mroonga/vendor/groonga/lib/ii.c +++ b/storage/mroonga/vendor/groonga/lib/ii.c @@ -2049,7 +2049,7 @@ grn_p_decv(grn_ctx *ctx, uint8_t *data, uint32_t data_size, datavec *dv, uint32_ if ((df & 1)) { df >>= 1; size = nreq == dvlen ? data_size : df * nreq; - if (dv[dvlen].data < dv[0].data + size) { + if (!dv[0].data || dv[dvlen].data < dv[0].data + size) { if (dv[0].data) { GRN_FREE(dv[0].data); } if (!(rp = GRN_MALLOC(size * sizeof(uint32_t)))) { return 0; } dv[dvlen].data = rp + size; @@ -10653,7 +10653,7 @@ grn_ii_builder_options_fix(grn_ii_builder_options *options) } #define GRN_II_BUILDER_TERM_INPLACE_SIZE\ - (sizeof(grn_ii_builder_term) - (uintptr_t)&((grn_ii_builder_term *)0)->dummy) + (sizeof(grn_ii_builder_term) - offsetof(grn_ii_builder_term, dummy)) typedef struct { grn_id rid; /* Last record ID */ From 13dd07374228ba106c59c70b325379ad0db507bb Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 1 Apr 2025 16:11:09 +1100 Subject: [PATCH 06/30] MDEV-31846: enable cursor protocol for test federatedx_create_handlers Per comment it code - it can be removed 10.5+. Not in the comment, is the SELECT INTO ... parts still required cursor protocol exclusion. --- mysql-test/suite/federated/federatedx_create_handlers.test | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index 9cf08a34931..d42e389cd49 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -7,9 +7,6 @@ connection default; set global federated_pushdown=1; -#Enable after fix MDEV-31846 or in v. 10.5 and later ---disable_cursor_protocol - connection slave; DROP TABLE IF EXISTS federated.t1; @@ -165,11 +162,13 @@ insert into federated.t4 select * from federated.t1; --sorted_result select * from federated.t4; +--disable_cursor_protocol select name into @var from federated.t1 where id=3 limit 1 ; select @var; --disable_ps2_protocol select name into outfile 'tmp.txt' from federated.t1; --enable_ps2_protocol +--enable_cursor_protocol let $path=`select concat(@@datadir, 'test/tmp.txt')`; remove_file $path; @@ -436,7 +435,5 @@ DEALLOCATE PREPARE stmt; set global federated_pushdown=0; ---enable_cursor_protocol - source include/federated_cleanup.inc; From 3995de0318be240effb19384e3a8ddc077917dff Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 1 Apr 2025 16:22:05 +1100 Subject: [PATCH 07/30] MDEV-36341 UBSAN: FederatedX fill_server runtime error: applying non-zero offset to null pointer UBSAN is nuanced around null pointer additions, but there is no offset on schema, its the start of the server->key. --- storage/federatedx/ha_federatedx.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 95a63366ac0..ee31ffc0a15 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -1489,20 +1489,20 @@ static void fill_server(MEM_ROOT *mem_root, FEDERATEDX_SERVER *server, sizeof(int) + 8); key.append(scheme); key.q_append('\0'); - server->hostname= (const char *) (intptr) key.length(); + size_t hostname_pos= key.length(); key.append(hostname); key.q_append('\0'); - server->database= (const char *) (intptr) key.length(); + size_t database_pos= key.length(); key.append(database); key.q_append('\0'); key.q_append((uint32) share->port); - server->socket= (const char *) (intptr) key.length(); + size_t socket_pos= key.length(); key.append(socket); key.q_append('\0'); - server->username= (const char *) (intptr) key.length(); + size_t username_pos= key.length(); key.append(username); key.q_append('\0'); - server->password= (const char *) (intptr) key.length(); + size_t password_pos= key.length(); key.append(password); key.c_ptr_safe(); // Ensure we have end \0 @@ -1510,13 +1510,12 @@ static void fill_server(MEM_ROOT *mem_root, FEDERATEDX_SERVER *server, /* Copy and add end \0 */ server->key= (uchar *) strmake_root(mem_root, key.ptr(), key.length()); - /* pointer magic */ - server->scheme+= (intptr) server->key; - server->hostname+= (intptr) server->key; - server->database+= (intptr) server->key; - server->username+= (intptr) server->key; - server->password+= (intptr) server->key; - server->socket+= (intptr) server->key; + server->scheme= (const char *)server->key; + server->hostname= (const char *)server->key + hostname_pos; + server->database= (const char *)server->key + database_pos; + server->username= (const char *)server->key + username_pos; + server->password= (const char *)server->key + password_pos; + server->socket= (const char*)server->key + socket_pos; server->port= share->port; if (!share->socket) From 93ea4f29a4cbacf0e849c320b47c550a874c471a Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 1 Apr 2025 16:40:30 +1100 Subject: [PATCH 08/30] MDEV-36347 UBSAN: plugins.auth_v0100 - runtime error: call to function do_auth_0x0100 through pointer to incorrect function type. Redoing a new plugin interface for an obsolete protocol was too much so we just remove the UBSAN testing on the function. It wasn't possible to just disable funtion-type-mismatch --- plugin/auth_examples/auth_0x0100.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/auth_examples/auth_0x0100.c b/plugin/auth_examples/auth_0x0100.c index e23f495f43b..e0639dddf90 100644 --- a/plugin/auth_examples/auth_0x0100.c +++ b/plugin/auth_examples/auth_0x0100.c @@ -56,6 +56,10 @@ struct st_mysql_auth }; #endif +/* function-type-mismatch ignore */ +#if defined(__clang__) +__attribute__((no_sanitize("undefined"))) +#endif static int do_auth_0x0100(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info) { info->password_used= 1; From 690b2cf776faa2e1a6832077cec2246c86cd00bf Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 20 Mar 2025 09:54:12 +1100 Subject: [PATCH 09/30] test: archive-big test too big for msan archive.archive-big w1 [ fail ] timeout after 900 seconds Test ended at 2025-03-19 22:27:30 Test case timeout after 900 seconds == /build/mysql-test/var/1/log/archive-big.log == CREATE TABLE t1(a BLOB) ENGINE=ARCHIVE; INSERT INTO t1 SELECT * FROM t1; ... == /build/mysql-test/var/1/tmp/analyze-timeout-mysqld.1.err == mysqltest: Could not open connection 'default' after 500 attempts: 2002 Can't connect to local MySQL server through socket '/build/mysql-test/var/tmp/1/mysqld.1.sock' (111) --- mysql-test/suite/archive/archive-big.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/archive/archive-big.test b/mysql-test/suite/archive/archive-big.test index fd59df66b43..8cd19b1d809 100644 --- a/mysql-test/suite/archive/archive-big.test +++ b/mysql-test/suite/archive/archive-big.test @@ -1,6 +1,7 @@ --source include/big_test.inc -# Valgrind is to slow for this test +# Valgrind and msan is to slow for this test --source include/not_valgrind.inc +--source include/not_msan.inc --source include/have_archive.inc CREATE TABLE t1(a BLOB) ENGINE=ARCHIVE; --disable_query_log From b02ad4a6f8ea09c5cdf0a44a9ee57a60f2989f48 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Sat, 5 Apr 2025 21:06:41 +0400 Subject: [PATCH 10/30] MDEV-36427 - FTBFS with libxml2 2.14.0 Connect engine fails to build with libxml2 2.14.0. Connect engine uses "#ifndef BASE_BUFFER_SIZE" to determine if libxml2 is available. If libxml2 is unavailable it did redefine xmlElementType enum of libxml/tree.h. The reasons for this redefinition is vague, most probably some of these constants were used when connect was compiled with MSXML, while libxml2 was disabled. However BASE_BUFFER_SIZE constant was removed from libxml2 recently, as a result connect fails to build due to xmlElementType constants redefinition. Use LIBXML2_SUPPORT instead of BASE_BUFFER_SIZE for libxml2 availability check. --- storage/connect/plgxml.h | 4 ++-- storage/connect/tabxml.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/connect/plgxml.h b/storage/connect/plgxml.h index 82629e4c7db..6b49e6ac527 100644 --- a/storage/connect/plgxml.h +++ b/storage/connect/plgxml.h @@ -5,7 +5,7 @@ /******************************************************************/ /* Dual XML implementation base classes defines. */ /******************************************************************/ -#if !defined(BASE_BUFFER_SIZE) +#ifndef LIBXML2_SUPPORT enum ElementType { // libxml2 XML_ELEMENT_NODE = 1, XML_ATTRIBUTE_NODE = 2, @@ -28,7 +28,7 @@ enum ElementType { // libxml2 XML_XINCLUDE_START = 19, XML_XINCLUDE_END = 20, XML_DOCB_DOCUMENT_NODE = 21}; -#endif // !BASE_BUFFER_SIZE +#endif //#if !defined(NODE_TYPE_LIST) #ifdef NOT_USED diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index fae2375e5a1..461ac6849f8 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -26,6 +26,9 @@ #include #include //#include +#ifdef LIBXML2_SUPPORT +#include +#endif #include "osutil.h" #define _O_RDONLY O_RDONLY #endif // !_WIN32 From 59962ae2b3061dbd3694e005c779d9b2dfbf625c Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 1 Apr 2025 17:38:25 +1100 Subject: [PATCH 11/30] MDEV-36442 MDEV-35452 Fix --view-protocol for spider tests with SELECT arguments of SELECT statements Running mtr --view-protocol transforms SELECT statements to a CREATE OR REPLACE VIEW of the statement, followed by SELECT from the view. When thus when spider tests check the query log for select statements, it often output a different one with --view-protocol compared to without. By adding disable/enable_view_protocol pairs to these statements. Most of these statements are surrounded by existing disable/enable_ps[2]_protocol pairs. Acked-by: Yuchen Pei --- .../t/checksum_table_with_quick_mode_3.test | 2 ++ .../mysql-test/spider/bugfix/t/cp932_column.test | 2 ++ .../spider/bugfix/t/delete_with_float_column.inc | 2 ++ .../spider/bugfix/t/group_by_order_by_limit.test | 4 ++++ .../mysql-test/spider/bugfix/t/insert_select.test | 2 ++ .../mysql-test/spider/bugfix/t/mdev_19866.test | 4 ++++ .../mysql-test/spider/bugfix/t/mdev_20100.test | 2 ++ .../mysql-test/spider/bugfix/t/mdev_20502.test | 2 ++ .../mysql-test/spider/bugfix/t/mdev_21884.test | 2 ++ .../mysql-test/spider/bugfix/t/mdev_27172.test | 2 ++ .../mysql-test/spider/bugfix/t/mdev_29008.test | 2 ++ .../mysql-test/spider/bugfix/t/quick_mode_0.test | 12 ++++++++++++ .../mysql-test/spider/bugfix/t/quick_mode_1.test | 12 ++++++++++++ .../mysql-test/spider/bugfix/t/quick_mode_2.test | 12 ++++++++++++ .../mysql-test/spider/bugfix/t/quick_mode_3.test | 12 ++++++++++++ .../spider/bugfix/t/return_found_rows_insert.test | 6 ++++++ .../spider/bugfix/t/return_found_rows_update.test | 2 ++ .../spider/bugfix/t/select_by_null.test | 2 ++ .../spider/bugfix/t/select_with_backquote.test | 2 ++ .../spider/bugfix/t/slave_trx_isolation.test | 2 ++ .../mysql-test/spider/bugfix/t/sql_mode.inc | 2 ++ .../spider/bugfix/t/strict_group_by.test | 4 ++++ .../spider/bugfix/t/wrapper_mariadb.test | 2 ++ .../spider/mysql-test/spider/bugfix/t/xa_cmd.test | 2 ++ .../spider/feature/t/checksum_table_parallel.inc | 2 ++ .../e1121/t/direct_join_by_pkey_key.test | 2 ++ .../e1121/t/direct_join_by_pkey_pkey.test | 2 ++ .../spider/regression/e1121/t/load_data.inc | 2 ++ .../e112122/t/group_by_order_by_limit_ok.test | 4 ++++ .../regression/e112122/t/load_data_part.inc | 4 ++++ .../mysql-test/spider/t/auto_increment.test | 2 ++ .../t/checksum_table_with_quick_mode_3.test | 2 ++ .../spider/mysql-test/spider/t/direct_join.test | 4 ++++ .../mysql-test/spider/t/direct_join_using.test | 2 ++ .../mysql-test/spider/t/direct_left_join.test | 2 ++ .../spider/t/direct_left_join_nullable.test | 2 ++ .../spider/t/direct_left_right_join_nullable.test | 2 ++ .../t/direct_left_right_left_join_nullable.test | 2 ++ .../mysql-test/spider/t/direct_right_join.test | 2 ++ .../spider/t/direct_right_join_nullable.test | 2 ++ .../spider/t/direct_right_left_join_nullable.test | 2 ++ .../t/direct_right_left_right_join_nullable.test | 2 ++ .../mysql-test/spider/t/partition_cond_push.test | 6 ++++++ .../mysql-test/spider/t/partition_fulltext.test | 6 ++++++ ...tition_join_pushdown_for_single_partition.test | 6 ++++++ .../mysql-test/spider/t/pushdown_not_like.test | 2 ++ .../spider/mysql-test/spider/t/quick_mode_0.test | 10 ++++++++++ .../spider/mysql-test/spider/t/quick_mode_1.test | 12 ++++++++++++ .../spider/mysql-test/spider/t/quick_mode_2.test | 12 ++++++++++++ .../spider/mysql-test/spider/t/quick_mode_3.test | 12 ++++++++++++ .../mysql-test/spider/t/slave_trx_isolation.test | 2 ++ storage/spider/mysql-test/spider/t/timestamp.test | 15 +++++++++++++++ .../spider/mysql-test/spider/t/udf_pushdown.inc | 2 ++ 53 files changed, 225 insertions(+) diff --git a/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test index de2dd90a500..e650ef3bd3a 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test +++ b/storage/spider/mysql-test/spider/bugfix/t/checksum_table_with_quick_mode_3.test @@ -52,9 +52,11 @@ TRUNCATE TABLE mysql.general_log; CHECKSUM TABLE tbl_a EXTENDED; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test b/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test index 119179702ec..a0f70bd9e82 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test +++ b/storage/spider/mysql-test/spider/bugfix/t/cp932_column.test @@ -59,9 +59,11 @@ SET NAMES utf8; --connection child2_1 SET NAMES cp932; +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; SET NAMES utf8; diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc index a4def9b3dc8..6285cf5eae4 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc +++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc @@ -78,9 +78,11 @@ sync_with_master; SET SESSION sql_log_bin= 0; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test b/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test index d694230bf2a..553fb6adeaf 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test +++ b/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test @@ -76,11 +76,15 @@ SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/insert_select.test b/storage/spider/mysql-test/spider/bugfix/t/insert_select.test index c2ac615e2ac..84ebd230849 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/insert_select.test +++ b/storage/spider/mysql-test/spider/bugfix/t/insert_select.test @@ -79,9 +79,11 @@ INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FRO INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 5 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY)); --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test index 0b8ce69cd73..a953a250449 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test @@ -71,11 +71,15 @@ SELECT * FROM tbl_a WHERE pkey = 2; SELECT * FROM tbl_a; --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test index 3d1ccf3ce6a..a440b370077 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test @@ -70,7 +70,9 @@ SELECT a, b, c FROM tbl_a PARTITION (pt2,pt3); --connection child2_1 --disable_ps2_protocol +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol --enable_ps2_protocol --disable_ps_protocol eval $CHILD2_1_SELECT_TABLES; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test index 1cd1c689372..3174ace8bfb 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test @@ -59,7 +59,9 @@ SELECT MAX(id) AS m, 0 AS const, val, (SELECT tbl_a.val+1 FROM tbl_a LIMIT 1) AS FROM tbl_a GROUP BY val; --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test index c1a9aaa4e9d..01a2a1a1171 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test @@ -81,9 +81,11 @@ SELECT STRAIGHT_JOIN b.a, b.b FROM tb_l a, tbl_a b WHERE a.a = b.a; --connection child2_1 SET NAMES utf8; +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol --disable_ps_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test index 0b2e065702d..8374713651a 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test @@ -76,7 +76,9 @@ SELECT * FROM tbl_c WHERE greeting = "Aloha!" AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH --connection child2_1 +--disable_view_protocol SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %'; +--enable_view_protocol --enable_ps2_protocol --connection child2_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test index f36855d8e71..40455916596 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test @@ -38,9 +38,11 @@ SELECT MIN(t2.a) AS f1, t1.b AS f2 FROM tbl_a AS t1 JOIN tbl_a AS t2 GROUP BY f2 --connection master_1 DROP DATABASE IF EXISTS auto_test_local; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol SELECT argument FROM mysql.general_log WHERE argument LIKE 'select %'; --enable_ps2_protocol +--enable_view_protocol set global log_output=@old_log_output; set global general_log=@old_general_log; DROP DATABASE IF EXISTS auto_test_remote; diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test index 3fd9e623887..23bfcb065db 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_0.test @@ -78,13 +78,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -103,13 +107,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -129,12 +137,16 @@ SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test index 940fa61c598..dd56ca135f0 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_1.test @@ -78,13 +78,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -103,13 +107,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -128,13 +136,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test index e9270a2ee93..cedc4b60449 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_2.test @@ -78,13 +78,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -103,13 +107,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -128,13 +136,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test index ad042aadfed..db3a6118743 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test +++ b/storage/spider/mysql-test/spider/bugfix/t/quick_mode_3.test @@ -79,13 +79,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -104,13 +108,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --connection master_1 @@ -129,13 +137,17 @@ TRUNCATE TABLE mysql.general_log; SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; --connection child2_1 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test index d4c0db1e7cc..2921d74b1cc 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test +++ b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_insert.test @@ -56,9 +56,11 @@ exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK - --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; TRUNCATE TABLE mysql.general_log; @@ -69,9 +71,11 @@ exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK - --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; TRUNCATE TABLE mysql.general_log; @@ -82,9 +86,11 @@ exec $MYSQL -v -v -u root -h localhost -P $MASTER_1_MYPORT -S $MASTER_1_MYSOCK - --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test index a5f63978a22..64aa4d7593e 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test +++ b/storage/spider/mysql-test/spider/bugfix/t/return_found_rows_update.test @@ -58,9 +58,11 @@ exec $MYSQL -v -v -u root -h localhost --default-character-set=latin1 -P $MASTER --enable_query_log --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test index feb7df57f02..dfe8b9ec2ef 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test +++ b/storage/spider/mysql-test/spider/bugfix/t/select_by_null.test @@ -52,9 +52,11 @@ TRUNCATE TABLE mysql.general_log; SELECT pkey FROM tbl_a WHERE NULL; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test b/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test index b511b05bf01..53daaf06f68 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test +++ b/storage/spider/mysql-test/spider/bugfix/t/select_with_backquote.test @@ -55,7 +55,9 @@ SELECT `pkey`, LEFT(`txt_utf8`, 4) FROM `auto_test_local`.`tbl_a` ORDER BY LEFT( --connection child2_1 SET NAMES utf8; +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test index 3d4280e35e4..66e044a5a5c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test +++ b/storage/spider/mysql-test/spider/bugfix/t/slave_trx_isolation.test @@ -71,10 +71,12 @@ SET SESSION sql_log_bin= 0; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol --replace_regex /-[0-9a-f]{12}-[0-9a-f]+-/-xxxxxxxxxxxx-xxxxx-/ eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc b/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc index c4b17f6a837..1b3a46590b0 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc +++ b/storage/spider/mysql-test/spider/bugfix/t/sql_mode.inc @@ -49,8 +49,10 @@ TRUNCATE TABLE mysql.general_log; SELECT * FROM tbl_a ORDER BY pkey; --connection child2_1 +--disable_view_protocol --replace_regex /-[0-9a-f]{12}-[0-9a-f]+-/-xxxxxxxxxxxx-xxxxx-/ eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test b/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test index eaf149fa5da..bc9ee2a6833 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test +++ b/storage/spider/mysql-test/spider/bugfix/t/strict_group_by.test @@ -78,15 +78,19 @@ SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_2_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test index d32af31674a..ae7e6643e3b 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test +++ b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test @@ -50,9 +50,11 @@ TRUNCATE TABLE mysql.general_log; SELECT * FROM tbl_a ORDER BY pkey; --connection child2_1 +--disable_view_protocol # in --ps a query is logged differently in a general log replace_regex /order by t0.`pkey`/order by `pkey`/; eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test b/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test index 1e831453e41..690fe3e5b50 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test +++ b/storage/spider/mysql-test/spider/bugfix/t/xa_cmd.test @@ -49,9 +49,11 @@ XA PREPARE 'test'; XA COMMIT 'test'; --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc b/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc index 83c3ffd6c54..79792b2cacf 100644 --- a/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc +++ b/storage/spider/mysql-test/spider/feature/t/checksum_table_parallel.inc @@ -74,10 +74,12 @@ send_eval $MASTER_1_CHECKSUM_TABLE; --connection child2_1_2 SELECT SLEEP(1); +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --connection child2_2_2 eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol --connection child2_1 UNLOCK TABLES; diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test index ec4639ed666..fd61b986cb1 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test +++ b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test @@ -67,7 +67,9 @@ SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; --connection child2_1 --disable_ps_protocol +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps_protocol diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test index 52d9b52ddb5..cc272be51b5 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test +++ b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test @@ -67,7 +67,9 @@ SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; --connection child2_1 --disable_ps_protocol +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --enable_ps_protocol diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc b/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc index 325a7523974..55fff558338 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc +++ b/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc @@ -67,9 +67,11 @@ eval LOAD DATA $OPTION_LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $ --remove_file $MYSQLTEST_VARDIR/tmp/spider_outfile.tsv --connection child2_1 +--disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --echo diff --git a/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test b/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test index e4f3f2155bb..dae5a812888 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test +++ b/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test @@ -76,11 +76,15 @@ SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc b/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc index f52d415a032..7b30cc0865d 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc +++ b/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc @@ -84,11 +84,15 @@ eval LOAD DATA $OPTION_LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $ --disable_ps2_protocol --connection child2_1 +--disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_1_SELECT_TABLES; --connection child2_2 +--disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; +--enable_view_protocol eval $CHILD2_2_SELECT_TABLES; --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/t/auto_increment.test b/storage/spider/mysql-test/spider/t/auto_increment.test index c5f272f5c44..5e3fff3dc55 100644 --- a/storage/spider/mysql-test/spider/t/auto_increment.test +++ b/storage/spider/mysql-test/spider/t/auto_increment.test @@ -156,7 +156,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test b/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test index e0fa7a84674..44d2878cd08 100644 --- a/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test +++ b/storage/spider/mysql-test/spider/t/checksum_table_with_quick_mode_3.test @@ -96,9 +96,11 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --disable_ps2_protocol eval $CHILD2_1_SELECT_ARGUMENT1; --enable_ps2_protocol + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_join.test b/storage/spider/mysql-test/spider/t/direct_join.test index 634b958f9f9..23cfbb197c9 100644 --- a/storage/spider/mysql-test/spider/t/direct_join.test +++ b/storage/spider/mysql-test/spider/t/direct_join.test @@ -168,7 +168,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -315,7 +317,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_CONST_TABLE_JOIN; eval $CHILD2_1_SELECT_CONST_TABLE2_JOIN; diff --git a/storage/spider/mysql-test/spider/t/direct_join_using.test b/storage/spider/mysql-test/spider/t/direct_join_using.test index 3ecfb292c89..61942b1998e 100644 --- a/storage/spider/mysql-test/spider/t/direct_join_using.test +++ b/storage/spider/mysql-test/spider/t/direct_join_using.test @@ -168,7 +168,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_join.test b/storage/spider/mysql-test/spider/t/direct_left_join.test index c9784b047ed..31744aa199d 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_join.test +++ b/storage/spider/mysql-test/spider/t/direct_left_join.test @@ -168,7 +168,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test index 7c69d73d335..949a1ecf5c7 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_left_join_nullable.test @@ -183,7 +183,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test index dd407482713..e81dbbcccad 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_left_right_join_nullable.test @@ -183,7 +183,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test index 3de0c310464..480ac8dcd1c 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_left_right_left_join_nullable.test @@ -183,7 +183,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_join.test b/storage/spider/mysql-test/spider/t/direct_right_join.test index d124f75a230..823d5176f34 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_join.test +++ b/storage/spider/mysql-test/spider/t/direct_right_join.test @@ -168,7 +168,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test index cdb2d4e6e58..0f0f614a03a 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_right_join_nullable.test @@ -183,7 +183,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test index cff40bfdeef..75e1551bcbb 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_right_left_join_nullable.test @@ -183,7 +183,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test b/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test index cd677a4bb8d..017a8174df7 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test +++ b/storage/spider/mysql-test/spider/t/direct_right_left_right_join_nullable.test @@ -183,7 +183,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/partition_cond_push.test b/storage/spider/mysql-test/spider/t/partition_cond_push.test index e47209ef220..b5eceead130 100644 --- a/storage/spider/mysql-test/spider/t/partition_cond_push.test +++ b/storage/spider/mysql-test/spider/t/partition_cond_push.test @@ -166,19 +166,25 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_3_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/partition_fulltext.test b/storage/spider/mysql-test/spider/t/partition_fulltext.test index 1b31fa05534..664617d2451 100644 --- a/storage/spider/mysql-test/spider/t/partition_fulltext.test +++ b/storage/spider/mysql-test/spider/t/partition_fulltext.test @@ -170,19 +170,25 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_3_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test b/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test index 753014d5da7..e1916e1d9b0 100644 --- a/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test +++ b/storage/spider/mysql-test/spider/t/partition_join_pushdown_for_single_partition.test @@ -169,19 +169,25 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_3_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/pushdown_not_like.test b/storage/spider/mysql-test/spider/t/pushdown_not_like.test index b39bb7785f6..5e7de1ff0ed 100644 --- a/storage/spider/mysql-test/spider/t/pushdown_not_like.test +++ b/storage/spider/mysql-test/spider/t/pushdown_not_like.test @@ -111,7 +111,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol SELECT argument FROM mysql.general_log WHERE argument LIKE '%select%'; + --enable_view_protocol } } --enable_ps2_protocol diff --git a/storage/spider/mysql-test/spider/t/quick_mode_0.test b/storage/spider/mysql-test/spider/t/quick_mode_0.test index 070d9e40548..b7f923ac609 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_0.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_0.test @@ -135,15 +135,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -195,15 +199,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -243,6 +251,7 @@ if ($USE_CHILD_GROUP2) } } --connection master_1 +--disable_view_protocol --disable_ps2_protocol SELECT a.pkey FROM tbl_a a, tbl_b b WHERE a.pkey = b.pkey; if ($USE_CHILD_GROUP2) @@ -273,6 +282,7 @@ if ($USE_CHILD_GROUP2) } } --enable_ps2_protocol +--enable_view_protocol --echo --echo deinit diff --git a/storage/spider/mysql-test/spider/t/quick_mode_1.test b/storage/spider/mysql-test/spider/t/quick_mode_1.test index a2c2bf87844..979679249bc 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_1.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_1.test @@ -135,15 +135,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -195,15 +199,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -255,15 +263,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/quick_mode_2.test b/storage/spider/mysql-test/spider/t/quick_mode_2.test index 12a48a904a2..2db2d1415bf 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_2.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_2.test @@ -135,15 +135,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -195,15 +199,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -255,15 +263,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/quick_mode_3.test b/storage/spider/mysql-test/spider/t/quick_mode_3.test index 65851a5bf3e..bb9bc8c6e48 100644 --- a/storage/spider/mysql-test/spider/t/quick_mode_3.test +++ b/storage/spider/mysql-test/spider/t/quick_mode_3.test @@ -135,15 +135,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -195,15 +199,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -255,15 +263,19 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /tmp_spider_bka_0x[0-9a-f]*/tmp_spider_bka_xxxx/ eval $CHILD2_2_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/slave_trx_isolation.test b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test index a3a3fad8677..b88d038de46 100644 --- a/storage/spider/mysql-test/spider/t/slave_trx_isolation.test +++ b/storage/spider/mysql-test/spider/t/slave_trx_isolation.test @@ -109,8 +109,10 @@ if ($USE_CHILD_GROUP2) --disable_ps2_protocol if ($USE_GENERAL_LOG) { + --disable_view_protocol --replace_regex /-[0-9a-f]{12}-[0-9a-f]+-/-xxxxxxxxxxxx-xxxxx-/ eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } --enable_ps2_protocol eval $CHILD2_1_SELECT_TABLES; diff --git a/storage/spider/mysql-test/spider/t/timestamp.test b/storage/spider/mysql-test/spider/t/timestamp.test index 47d637bb0c5..fddfbfd3880 100644 --- a/storage/spider/mysql-test/spider/t/timestamp.test +++ b/storage/spider/mysql-test/spider/t/timestamp.test @@ -183,7 +183,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -216,6 +218,7 @@ if ($USE_CHILD_GROUP2) } --connection master_1 DELETE FROM tbl_a WHERE col_ts='1970-01-01 01:00:01'; +--disable_view_protocol --disable_ps2_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; if ($USE_CHILD_GROUP2) @@ -228,7 +231,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -272,7 +277,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -317,7 +324,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -367,7 +376,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -447,7 +458,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE; if (!$OUTPUT_CHILD_GROUP2) @@ -499,7 +512,9 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { + --disable_view_protocol eval $CHILD2_1_SELECT_ARGUMENT1; + --enable_view_protocol } eval $CHILD2_1_SELECT_TABLE_F; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/udf_pushdown.inc b/storage/spider/mysql-test/spider/t/udf_pushdown.inc index df9742a35b8..93e570a656d 100644 --- a/storage/spider/mysql-test/spider/t/udf_pushdown.inc +++ b/storage/spider/mysql-test/spider/t/udf_pushdown.inc @@ -9,7 +9,9 @@ SELECT * FROM ta_l WHERE id IN (plusone(1), plusone(2)) AND a = plusone(32); if ($USE_CHILD_GROUP2) { --connection child2_1 + --disable_view_protocol SELECT argument FROM mysql.general_log WHERE argument LIKE "%select%" AND argument NOT LIKE "%argument%"; + --enable_view_protocol --disable_query_log TRUNCATE TABLE mysql.general_log; --enable_query_log From 25f1e6f565d5b1effb5cfcd858660e268bb1b1fe Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 2 Apr 2025 15:45:23 +1100 Subject: [PATCH 12/30] MDEV-36307 MDEV-35452 Do not create spider group by handler when dealing with derived tables or view and at least one select item is constant If one of the selected field is a MIN or MAX and it has been optimized into a constant, it is not added to the temp table used by a group by handler (GBH). The GBH therefore cannot store results to this missing field. On the other hand, when SELECTing from a view or a derived table, TMP_TABLE_ALL_COLUMNS is set. If the query has no group by or order by, an Item_temptable_field is created for this MIN/MAX field and added to the JOIN. Since the GBH could not store results to the corresponding field in the temp table, the value of this Item_temptable_field remains NULL. And the NULL value is passed to the record, then the temp row, and finally output as the (wrong) result. To fix this, we opt to not creating a spider GBH when a view or derived table is involved. This fixes spider/bugfix.mdev_26345 for --view-protocol Also fixed a comment: TABLE_LIST::belong_to_derived is NULL if the table belongs to a derived table that has non-MERGE type. --- sql/table.h | 2 +- .../mysql-test/spider/bugfix/r/mdev_26345.result | 3 +++ .../spider/mysql-test/spider/bugfix/t/mdev_26345.test | 1 + .../spider/mysql-test/spider/bugfix/t/mdev_29502.test | 4 ++++ storage/spider/spd_group_by_handler.cc | 10 ++++++++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sql/table.h b/sql/table.h index d46f91ee2dd..981fc5d23c5 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2526,7 +2526,7 @@ struct TABLE_LIST List *view_tables; /* most upper view this table belongs to */ TABLE_LIST *belong_to_view; - /* A derived table this table belongs to */ + /* A merged derived table this table belongs to */ TABLE_LIST *belong_to_derived; /* The view directly referencing this table diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result index 9f569795299..31a2cc452d0 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_26345.result @@ -15,6 +15,9 @@ insert into t1 VALUES (1,4), (1,2), (2,11); SELECT MIN(b), a FROM t1 WHERE a=1; MIN(b) a 2 1 +select * from (SELECT MIN(b), a FROM t1 WHERE a=1) as v; +MIN(b) a +2 1 SELECT MAX(b), a FROM t1 WHERE a<3; MAX(b) a 11 1 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test index b14df3bf332..e3a0631721d 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_26345.test @@ -22,6 +22,7 @@ create table t1 (a int, b int, PRIMARY KEY (a, b)) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; insert into t1 VALUES (1,4), (1,2), (2,11); SELECT MIN(b), a FROM t1 WHERE a=1; +select * from (SELECT MIN(b), a FROM t1 WHERE a=1) as v; SELECT MAX(b), a FROM t1 WHERE a<3; drop table t1, t2; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test index 91a8cad5f8b..7e0bcc61df9 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29502.test @@ -24,10 +24,14 @@ eval CREATE TABLE t1 (a INT KEY) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "$sr SELECT MAX(a) FROM t1; SELECT SUM(a) FROM t1; SELECT COUNT(a) FROM t1; +# Spider does not create a GBH with view protocol in these cases which +# would cause extra direct aggregate counts than without view protocol +--disable_view_protocol SELECT MAX(a), SUM(a) FROM t1; SELECT COUNT(a), MAX(a), SUM(a) FROM t1; SELECT MAX(a), COUNT(a), SUM(a) FROM t1; SELECT MAX(a), MAX(COALESCE(a)) FROM t1; +--enable_view_protocol SHOW STATUS LIKE 'Spider_direct_aggregate'; DROP TABLE t, t1; diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 0c62e6cf7eb..70f9ef3c0b5 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1566,6 +1566,16 @@ group_by_handler *spider_create_group_by_handler( DBUG_PRINT("info",("spider select item=%p", item)); if (item->const_item()) { + /* + Do not create the GBH when a derived table or view is + involved + */ + if (thd->derived_tables != NULL) + { + keep_going= FALSE; + break; + } + /* Do not handle the complex case where there's a const item in the auxiliary fields. It is too unlikely (if at all) to From 0f7c9146cf4c0d93e3970be8f1c45037748a778d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 2 Apr 2025 14:28:10 +1100 Subject: [PATCH 13/30] MDEV-36452 MDEV-35452 Fix udf output temp field name in spider tests with --view-protocol --- .../include/direct_sql_with_comma_pwd_init.inc | 2 +- .../include/direct_sql_with_tmp_table_init.inc | 2 +- .../spider/bugfix/r/direct_sql_with_comma_pwd.result | 4 ++-- .../spider/bugfix/r/direct_sql_with_tmp_table.result | 4 ++-- .../spider/bugfix/r/udf_mysql_func_early.result | 4 ++-- .../bugfix/r/udf_mysql_func_early_init_file.result | 4 ++-- .../spider/bugfix/t/udf_mysql_func_early.test | 2 +- .../mysql-test/spider/feature/r/pushdown_case.result | 12 ++++++------ .../mysql-test/spider/feature/t/pushdown_case.test | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc index c87af2d02e4..5c5a14bf796 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_comma_pwd_init.inc @@ -6,6 +6,6 @@ --enable_query_log --enable_warnings let $DIRECT_SQL_COMMAND= - SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"'); + SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"') as exp; --connection child2_1 GRANT ALL ON *.* TO tu@'%' IDENTIFIED BY 'pass,1234'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc index 7b58bd3e726..bb2c7eb3aba 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/direct_sql_with_tmp_table_init.inc @@ -6,4 +6,4 @@ --enable_query_log --enable_warnings let $DIRECT_SQL_COMMAND= - SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"'); + SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"') as exp; diff --git a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result index b485d645619..7d18527351e 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result +++ b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_comma_pwd.result @@ -15,8 +15,8 @@ CREATE TEMPORARY TABLE tmp_a ( pkey int NOT NULL, PRIMARY KEY (pkey) ) MASTER_1_ENGINE2 -SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"'); -spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"') +SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test", password "pass,1234", user "tu"') as exp; +exp 1 SELECT pkey FROM tmp_a; pkey diff --git a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result index 65beb8a43dd..467bc0ed6cd 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result +++ b/storage/spider/mysql-test/spider/bugfix/r/direct_sql_with_tmp_table.result @@ -13,8 +13,8 @@ CREATE TEMPORARY TABLE tmp_a ( pkey int NOT NULL, PRIMARY KEY (pkey) ) MASTER_1_ENGINE2 -SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"'); -spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"') +SELECT spider_direct_sql('SELECT 22', 'tmp_a', 'srv "s_2_1", database "test"') as exp; +exp 1 SELECT pkey FROM tmp_a; pkey diff --git a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result index b84f60a67fb..2504cda9cd2 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result +++ b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early.result @@ -31,8 +31,8 @@ CREATE TABLE tbl_a ( a INT ) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"'; create temporary table results (a int); -SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"'); -SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') +SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') as exp; +exp 1 select * from results; a diff --git a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result index b84f60a67fb..2504cda9cd2 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result +++ b/storage/spider/mysql-test/spider/bugfix/r/udf_mysql_func_early_init_file.result @@ -31,8 +31,8 @@ CREATE TABLE tbl_a ( a INT ) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"'; create temporary table results (a int); -SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"'); -SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') +SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') as exp; +exp 1 select * from results; a diff --git a/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test b/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test index 4edff9ca784..5a5fffc3940 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test +++ b/storage/spider/mysql-test/spider/bugfix/t/udf_mysql_func_early.test @@ -37,7 +37,7 @@ eval CREATE TABLE tbl_a ( create temporary table results (a int); --disable_ps_protocol -SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"'); +SELECT SPIDER_DIRECT_SQL('select * from tbl_a', 'results', 'srv "s_2_1", database "auto_test_remote"') as exp; --enable_ps_protocol select * from results; diff --git a/storage/spider/mysql-test/spider/feature/r/pushdown_case.result b/storage/spider/mysql-test/spider/feature/r/pushdown_case.result index 613ce377865..67adb4954fb 100644 --- a/storage/spider/mysql-test/spider/feature/r/pushdown_case.result +++ b/storage/spider/mysql-test/spider/feature/r/pushdown_case.result @@ -11,11 +11,11 @@ create table t2 (c int); create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"'; insert into t1 values (42), (3), (848), (100); -explain select case c when 3 then "three" when 42 then "answer" else "other" end from t1; +explain select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY -select case c when 3 then "three" when 42 then "answer" else "other" end from t1; -case c when 3 then "three" when 42 then "answer" else "other" end +select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; +exp answer three other @@ -29,11 +29,11 @@ answer three NULL NULL -explain select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; +explain select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Storage engine handles GROUP BY -select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; -case when c = 3 then "three" when c = 42 then "answer" else "other" end +select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; +exp answer three other diff --git a/storage/spider/mysql-test/spider/feature/t/pushdown_case.test b/storage/spider/mysql-test/spider/feature/t/pushdown_case.test index b86edceb615..9a77183d3d5 100644 --- a/storage/spider/mysql-test/spider/feature/t/pushdown_case.test +++ b/storage/spider/mysql-test/spider/feature/t/pushdown_case.test @@ -16,7 +16,7 @@ insert into t1 values (42), (3), (848), (100); # everything let $query= -select case c when 3 then "three" when 42 then "answer" else "other" end from t1; +select case c when 3 then "three" when 42 then "answer" else "other" end as exp from t1; eval explain $query; eval $query; @@ -28,7 +28,7 @@ eval $query; # no value let $query= -select case when c = 3 then "three" when c = 42 then "answer" else "other" end from t1; +select case when c = 3 then "three" when c = 42 then "answer" else "other" end as exp from t1; eval explain $query; eval $query; From dabd51c3912484b97f92f091b6ab7b20409d9f0c Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 2 Apr 2025 14:47:53 +1100 Subject: [PATCH 14/30] MDEV-36335 MDEV-35452 Disable view protocol when calling spider_copy_tables in tests Spider needs to lock the spider table when executing the udf, but the server layer would have already locked tables in view protocol because it transforms the query: select spider_copy_table('t', 0, 1) to two queries create or replace view mysqltest_tmp_v as select spider_copy_table('t', 0, 1); select * from mysqltest_tmp_v; So spider justifiably errors out in this case by checking on thd->derived_tables and thd->locks in spider_copy_tables_body() --- storage/spider/mysql-test/spider/bg/t/ha.test | 2 ++ storage/spider/mysql-test/spider/bg/t/ha_part.test | 2 ++ storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test | 2 ++ storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test | 4 ++++ storage/spider/mysql-test/spider/handler/t/ha.test | 2 ++ storage/spider/mysql-test/spider/handler/t/ha_part.test | 2 ++ storage/spider/mysql-test/spider/t/ha.test | 2 ++ storage/spider/mysql-test/spider/t/ha_part.test | 2 ++ 8 files changed, 18 insertions(+) diff --git a/storage/spider/mysql-test/spider/bg/t/ha.test b/storage/spider/mysql-test/spider/bg/t/ha.test index 00dcf776836..aca4d47b646 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha.test +++ b/storage/spider/mysql-test/spider/bg/t/ha.test @@ -395,7 +395,9 @@ if ($USE_CHILD_GROUP3) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/bg/t/ha_part.test b/storage/spider/mysql-test/spider/bg/t/ha_part.test index 72ddcfd1f10..b7d27b0d69d 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha_part.test +++ b/storage/spider/mysql-test/spider/bg/t/ha_part.test @@ -460,7 +460,9 @@ if ($HAVE_PARTITION) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test index 02df6032887..8a7141e5248 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30649.test @@ -25,7 +25,9 @@ INSERT INTO dst VALUES (555, '1999-12-12'); # possibly a bug, e.g. an unnecessary requirement. evalp CREATE TABLE t (c INT, d DATE, PRIMARY KEY(c)) ENGINE=SPIDER COMMENT='table "src dst", srv "s_2_1 s_1"'; +--disable_view_protocol SELECT spider_copy_tables('t', '0', '1'); +--enable_view_protocol SELECT * FROM dst; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test index ebd08edce24..294675d2f4c 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_30727.test @@ -7,8 +7,10 @@ CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; SELECT spider_bg_direct_sql ('SELECT * FROM s','a','srv "b"'); CREATE FUNCTION spider_copy_tables RETURNS INT SONAME 'ha_spider.so'; +--disable_view_protocol --error ER_CANT_INITIALIZE_UDF SELECT spider_copy_tables ('t', '0', '0'); +--enable_view_protocol # spider_flush_table_mon_cache does not require spider init to function CREATE FUNCTION spider_flush_table_mon_cache RETURNS INT SONAME 'ha_spider.so'; @@ -21,8 +23,10 @@ install soname 'ha_spider'; SELECT spider_direct_sql ('SELECT * FROM s','a','srv "b"'); call mtr.add_suppression(".*\\[Error\\] (mysqld|mariadbd): Can't find record in 'spider_tables'"); +--disable_view_protocol --error ER_KEY_NOT_FOUND SELECT spider_copy_tables ('t', '0', '0'); +--enable_view_protocol SELECT spider_flush_table_mon_cache (); diff --git a/storage/spider/mysql-test/spider/handler/t/ha.test b/storage/spider/mysql-test/spider/handler/t/ha.test index 00dcf776836..aca4d47b646 100644 --- a/storage/spider/mysql-test/spider/handler/t/ha.test +++ b/storage/spider/mysql-test/spider/handler/t/ha.test @@ -395,7 +395,9 @@ if ($USE_CHILD_GROUP3) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/handler/t/ha_part.test b/storage/spider/mysql-test/spider/handler/t/ha_part.test index 72ddcfd1f10..b7d27b0d69d 100644 --- a/storage/spider/mysql-test/spider/handler/t/ha_part.test +++ b/storage/spider/mysql-test/spider/handler/t/ha_part.test @@ -460,7 +460,9 @@ if ($HAVE_PARTITION) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/t/ha.test b/storage/spider/mysql-test/spider/t/ha.test index 00dcf776836..aca4d47b646 100644 --- a/storage/spider/mysql-test/spider/t/ha.test +++ b/storage/spider/mysql-test/spider/t/ha.test @@ -395,7 +395,9 @@ if ($USE_CHILD_GROUP3) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_2_1; eval $MASTER_1_CHECK_LINK_STATUS; +--disable_view_protocol eval $MASTER_1_COPY_TABLES_2_1; +--enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) diff --git a/storage/spider/mysql-test/spider/t/ha_part.test b/storage/spider/mysql-test/spider/t/ha_part.test index 7e9d6f7715c..123b100a474 100644 --- a/storage/spider/mysql-test/spider/t/ha_part.test +++ b/storage/spider/mysql-test/spider/t/ha_part.test @@ -460,7 +460,9 @@ if ($HAVE_PARTITION) --connection master_1 eval $MASTER_1_SET_RECOVERY_STATUS_P_2_1; eval $MASTER_1_CHECK_LINK_STATUS; + --disable_view_protocol eval $MASTER_1_COPY_TABLES_P_2_1; + --enable_view_protocol if ($USE_CHILD_GROUP3) { if (!$OUTPUT_CHILD_GROUP3) From 8866fba00a03dbdcba479b42071089271cb6c415 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 3 Apr 2025 17:56:56 +1100 Subject: [PATCH 15/30] MDEV-36454 MDEV-35452 Fix spider view protocol test failures caused by different queries constructed without GBH With view protocol, often during optimization, the GBH is not created because join->tables_list is the view mysqltest_tmp_v which has MEMORY as engine which does not have GBH implemented. In such cases, if without view protocol the test takes a path that does create a spider GBH, the resulting queries sent to the data node often differ. Therefore we disable view protocol for these statements. --- .../mysql-test/spider/bugfix/t/mdev_20502.test | 4 ++++ .../mysql-test/spider/bugfix/t/mdev_27172.test | 6 ++++++ .../mysql-test/spider/bugfix/t/mdev_34659.test | 3 +++ .../spider/bugfix/t/wrapper_mariadb.test | 4 ++-- .../mysql-test/spider/t/auto_increment.test | 2 ++ .../mysql-test/spider/t/direct_join_using.test | 2 ++ .../mysql-test/spider/t/direct_left_join.test | 2 ++ .../mysql-test/spider/t/direct_right_join.test | 2 ++ .../mysql-test/spider/t/pushdown_not_like.test | 2 ++ storage/spider/mysql-test/spider/t/timestamp.test | 15 ++++++++++++++- .../spider/mysql-test/spider/t/udf_pushdown.inc | 2 ++ 11 files changed, 41 insertions(+), 3 deletions(-) diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test index 3174ace8bfb..574a13c8e86 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test @@ -49,14 +49,18 @@ TRUNCATE TABLE mysql.general_log; --disable_ps2_protocol --connection master_1 +--disable_view_protocol SELECT id, 0 AS const, val FROM tbl_a; SELECT 1+2, id, 0 AS const, val, val+10, (SELECT tbl_a.val+1 FROM tbl_a) AS sq FROM tbl_a; +--enable_view_protocol INSERT INTO tbl_a (val) VALUES (2), (1); +--disable_view_protocol SELECT val+10, 0 AS const, val, (SELECT tbl_a.val+1 FROM tbl_a LIMIT 1) AS sq FROM tbl_a GROUP BY val; SELECT MAX(id) AS m, 0 AS const, val, (SELECT tbl_a.val+1 FROM tbl_a LIMIT 1) AS sq FROM tbl_a GROUP BY val; +--enable_view_protocol --connection child2_1 --disable_view_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test index 8374713651a..da7a1457a78 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_27172.test @@ -50,8 +50,10 @@ eval CREATE TABLE tbl_a ( --disable_ps2_protocol INSERT INTO tbl_a VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +--disable_view_protocol SELECT * FROM tbl_a WHERE greeting = "Aloha!" AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH +--enable_view_protocol # LIKE eval CREATE TABLE tbl_b ( @@ -61,8 +63,10 @@ eval CREATE TABLE tbl_b ( ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_b", srv "s_2_1"'; INSERT INTO tbl_b VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +--disable_view_protocol SELECT * FROM tbl_b WHERE greeting = "Aloha!" AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH +--enable_view_protocol # LIKE eval CREATE TABLE tbl_c ( @@ -72,8 +76,10 @@ eval CREATE TABLE tbl_c ( ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_c", srv "s_2_1"'; INSERT INTO tbl_c VALUES (1, "Hi!"),(2, "Aloha!"),(3, "Aloha!!!"); +--disable_view_protocol SELECT * FROM tbl_c WHERE greeting = "Aloha!" AND CASE greeting WHEN "Aloha!" THEN "one" ELSE 'more' END = "one"; # hack to disable GBH +--enable_view_protocol --connection child2_1 --disable_view_protocol diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test index 3b1dc206866..330b96db6f9 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_34659.test @@ -12,7 +12,10 @@ CREATE TABLE t1 (c INT) ENGINE=MyISAM; CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t1"'; insert into t2 values (456), (123); SELECT * FROM t2 ORDER BY CAST(c AS char(60)); +# extra warnings with view protocol +--disable_view_protocol SELECT * FROM t2 ORDER BY CAST(c AS INET6); +--enable_view_protocol SELECT * FROM t2 GROUP BY CAST(c AS char(60)); SELECT * FROM t2 GROUP BY CAST(c AS INET6); # Cleanup diff --git a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test index ae7e6643e3b..72502b64f78 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test +++ b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test @@ -47,12 +47,12 @@ TRUNCATE TABLE mysql.general_log; --disable_ps2_protocol --connection master_1 +--disable_view_protocol SELECT * FROM tbl_a ORDER BY pkey; +--enable_view_protocol --connection child2_1 --disable_view_protocol -# in --ps a query is logged differently in a general log -replace_regex /order by t0.`pkey`/order by `pkey`/; eval $CHILD2_1_SELECT_ARGUMENT1; --enable_view_protocol eval $CHILD2_1_SELECT_TABLES; diff --git a/storage/spider/mysql-test/spider/t/auto_increment.test b/storage/spider/mysql-test/spider/t/auto_increment.test index 5e3fff3dc55..b4f0610fa58 100644 --- a/storage/spider/mysql-test/spider/t/auto_increment.test +++ b/storage/spider/mysql-test/spider/t/auto_increment.test @@ -145,7 +145,9 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT * FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_join_using.test b/storage/spider/mysql-test/spider/t/direct_join_using.test index 61942b1998e..44d563b27ca 100644 --- a/storage/spider/mysql-test/spider/t/direct_join_using.test +++ b/storage/spider/mysql-test/spider/t/direct_join_using.test @@ -156,7 +156,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT a.a, c.b, c.c FROM tbl_a a join tbl_b b using(a) join tbl_c c using(a) ORDER BY a.b DESC; +--enable_view_protocol if ($USE_CHILD_GROUP2) { diff --git a/storage/spider/mysql-test/spider/t/direct_left_join.test b/storage/spider/mysql-test/spider/t/direct_left_join.test index 31744aa199d..ed36f580a52 100644 --- a/storage/spider/mysql-test/spider/t/direct_left_join.test +++ b/storage/spider/mysql-test/spider/t/direct_left_join.test @@ -156,7 +156,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT a.a, c.b, c.c FROM tbl_a a left join tbl_b b on a.a = b.a left join tbl_c c on a.a = c.a ORDER BY a.b DESC; +--enable_view_protocol if ($USE_CHILD_GROUP2) { diff --git a/storage/spider/mysql-test/spider/t/direct_right_join.test b/storage/spider/mysql-test/spider/t/direct_right_join.test index 823d5176f34..effa1121c8b 100644 --- a/storage/spider/mysql-test/spider/t/direct_right_join.test +++ b/storage/spider/mysql-test/spider/t/direct_right_join.test @@ -156,7 +156,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT a.a, c.b, c.c FROM tbl_a a right join tbl_b b on a.a = b.a right join tbl_c c on a.a = c.a ORDER BY a.b DESC; +--enable_view_protocol if ($USE_CHILD_GROUP2) { diff --git a/storage/spider/mysql-test/spider/t/pushdown_not_like.test b/storage/spider/mysql-test/spider/t/pushdown_not_like.test index 5e7de1ff0ed..cf2ed838d31 100644 --- a/storage/spider/mysql-test/spider/t/pushdown_not_like.test +++ b/storage/spider/mysql-test/spider/t/pushdown_not_like.test @@ -105,7 +105,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 --disable_ps2_protocol +--disable_view_protocol select * from ta_l where b not like 'a%'; +--enable_view_protocol if ($USE_CHILD_GROUP2) { --connection child2_1 diff --git a/storage/spider/mysql-test/spider/t/timestamp.test b/storage/spider/mysql-test/spider/t/timestamp.test index fddfbfd3880..20fa69a6287 100644 --- a/storage/spider/mysql-test/spider/t/timestamp.test +++ b/storage/spider/mysql-test/spider/t/timestamp.test @@ -172,7 +172,9 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -218,9 +220,10 @@ if ($USE_CHILD_GROUP2) } --connection master_1 DELETE FROM tbl_a WHERE col_ts='1970-01-01 01:00:01'; ---disable_view_protocol --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -266,7 +269,9 @@ SET @@timestamp=1; INSERT INTO tbl_a VALUES (1, now(), now()); SET @@timestamp=0; --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -313,7 +318,9 @@ if ($USE_CHILD_GROUP2) --connection master_1 UPDATE tbl_a SET col_ts=col_dt; --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -359,6 +366,7 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > '2018-01-01'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts < '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE '2018-10-28 02:30:00' > col_ts; @@ -366,6 +374,7 @@ SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts BETWEEN '2018-10-28 01: SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts >= '2018-10-28 01:30:00' AND col_ts <= '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 180325020000; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 19700101010001; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -441,6 +450,7 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > '2018-01-01'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts < '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE '2018-10-28 02:30:00' > col_ts; @@ -448,6 +458,7 @@ SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts BETWEEN '2018-10-28 01: SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts >= '2018-10-28 01:30:00' AND col_ts <= '2018-10-28 02:30:00'; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 180325020000; SELECT *, unix_timestamp(col_ts) FROM tbl_a WHERE col_ts > 19700101010001; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) @@ -497,11 +508,13 @@ if ($USE_CHILD_GROUP2) } --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT * FROM tbl_f; SELECT TIMESTAMP(col_d, col_t) FROM tbl_f; SELECT TIMESTAMP('2018-06-25', col_t) FROM tbl_f; SELECT TIMESTAMP(col_d, '10:43:21') FROM tbl_f; SELECT TIMESTAMP('2018-06-25', '10:43:21') FROM tbl_f; +--enable_view_protocol if ($USE_CHILD_GROUP2) { if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/udf_pushdown.inc b/storage/spider/mysql-test/spider/t/udf_pushdown.inc index 93e570a656d..16f85dfffcd 100644 --- a/storage/spider/mysql-test/spider/t/udf_pushdown.inc +++ b/storage/spider/mysql-test/spider/t/udf_pushdown.inc @@ -2,8 +2,10 @@ --echo ##### test SELECTs ##### --connection master_1 --disable_ps2_protocol +--disable_view_protocol SELECT * FROM ta_l WHERE id = plusone(1); SELECT * FROM ta_l WHERE id IN (plusone(1), plusone(2)) AND a = plusone(32); +--enable_view_protocol --enable_ps2_protocol if ($USE_CHILD_GROUP2) From b6392c292e8dc4539185dba4696e05c65d0f1065 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 3 Apr 2025 17:57:04 +1100 Subject: [PATCH 16/30] MDEV-36454 MDEV-35452 Fix spider view protocol test failures caused by tampering of order by items With view protocol, a SELECT statement is transformed into two statements: 1. CREATE OR REPLACE VIEW mysqltest_tmp_v AS SELECT ... 2. SELECT * FROM mysqltest_tmp_v The first statement reconstructed the query, which is executed in the second statement. The reconstruction often replaces aliases in ORDER BY by the original item. For example, in the test spider/bugfix.mdev_29008 the query SELECT MIN(t2.a) AS f1, t1.b AS f2 FROM tbl_a AS t1 JOIN tbl_a AS t2 GROUP BY f2 ORDER BY f1, f2; is transformed to "select min(`t2`.`a`) AS `f1`,`t1`.`b` AS `f2` from (`auto_test_local`.`tbl_a` `t1` join `auto_test_local`.`tbl_a` `t2`) group by `t1`.`b` order by min(`t2`.`a`),`t1`.`b`" In such cases, spider constructs different queries to execute at the data node. So we disable view protocol for such queries. --- .../mysql-test/spider/bugfix/t/group_by_order_by_limit.test | 2 ++ storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test | 2 ++ .../spider/regression/e112122/t/group_by_order_by_limit_ok.test | 2 ++ 3 files changed, 6 insertions(+) diff --git a/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test b/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test index 553fb6adeaf..d35c25534e9 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test +++ b/storage/spider/mysql-test/spider/bugfix/t/group_by_order_by_limit.test @@ -71,7 +71,9 @@ TRUNCATE TABLE mysql.general_log; set @old_spider_direct_aggregate=@@session.spider_direct_aggregate; set spider_direct_aggregate=1; SHOW STATUS LIKE 'Spider_direct_aggregate'; +--disable_view_protocol SELECT skey, count(*) cnt FROM tbl_a GROUP BY skey ORDER BY cnt DESC, skey DESC LIMIT 5; +--enable_view_protocol SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test index 40455916596..7e5e2ca2fd9 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29008.test @@ -31,8 +31,10 @@ eval CREATE TABLE tbl_a ( ) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"'; --disable_ps2_protocol +--disable_view_protocol SELECT MIN(t2.a) AS f1, t1.b AS f2 FROM tbl_a AS t1 JOIN tbl_a AS t2 GROUP BY f2 ORDER BY f1, f2; SELECT MIN(t2.a) AS f1, t1.b AS f2 FROM tbl_a AS t1 JOIN tbl_a AS t2 GROUP BY f2 ORDER BY MIN(t2.a), MAX(t2.a), f2; +--enable_view_protocol --enable_ps2_protocol --connection master_1 diff --git a/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test b/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test index dae5a812888..007fef77b62 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test +++ b/storage/spider/mysql-test/spider/regression/e112122/t/group_by_order_by_limit_ok.test @@ -71,7 +71,9 @@ TRUNCATE TABLE mysql.general_log; set @old_spider_direct_aggregate=@@session.spider_direct_aggregate; set spider_direct_aggregate=1; SHOW STATUS LIKE 'Spider_direct_aggregate'; +--disable_view_protocol SELECT skey, count(*) cnt FROM tbl_a GROUP BY skey ORDER BY cnt DESC, skey DESC LIMIT 5; +--enable_view_protocol SHOW STATUS LIKE 'Spider_direct_aggregate'; set spider_direct_aggregate=@old_spider_direct_aggregate; From 2a5a12b227845e03575f1b1eb0f6366dccc3e026 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Mon, 7 Apr 2025 19:10:02 +0200 Subject: [PATCH 17/30] MDEV-36506 Build fails with cmake 4.0 Update cmake_minimum_required to 2.8...3.12 in root cmake and mroonga. This will update "Policy Version" to 3.12, which will not prevent the build by even higher cmake versions. There is also a reason to stay on the compatible with windows "policy version", so 3.12 is conservatively chosen. On the other hand, it will require at least version 2.8. --- CMakeLists.txt | 2 +- storage/mroonga/CMakeLists.txt | 2 +- storage/mroonga/vendor/groonga/CMakeLists.txt | 2 +- .../vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1e2719e43..646e4256c97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.12) IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) # Setting build type to RelWithDebInfo as none was specified. diff --git a/storage/mroonga/CMakeLists.txt b/storage/mroonga/CMakeLists.txt index 11eec13d520..e53568bc591 100644 --- a/storage/mroonga/CMakeLists.txt +++ b/storage/mroonga/CMakeLists.txt @@ -17,7 +17,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8...3.12) project(mroonga) if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/storage/mroonga/vendor/groonga/CMakeLists.txt b/storage/mroonga/vendor/groonga/CMakeLists.txt index 5b25ada4f5b..0b03898b913 100644 --- a/storage/mroonga/vendor/groonga/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/CMakeLists.txt @@ -15,7 +15,7 @@ # https://buildbot.askmonty.org/buildbot/builders/work-amd64-valgrind/builds/5263/steps/compile/logs/stdio # says CMake 2.6.2... We want to drop old software support... -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8...3.12) # cmake_minimum_required(VERSION 2.6.4) # CentOS 5 set(GRN_PROJECT_NAME "groonga") set(GRN_PROJECT_LABEL "Groonga") diff --git a/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt b/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt index 96f9b3e6bbf..a555bdf6ac2 100644 --- a/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt +++ b/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/CMakeLists.txt @@ -15,7 +15,7 @@ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1335 USA -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8...3.12) if(NOT DEFINED GROONGA_NORMALIZER_MYSQL_PROJECT_NAME) set(GROONGA_NORMALIZER_MYSQL_PROJECT_NAME "groonga-normalizer-mysql") endif() From 24a4d4ab0c0fbfe64d10d10098431f4cedc1d44a Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Mon, 7 Apr 2025 20:37:36 +0200 Subject: [PATCH 18/30] MDEV-36422 Build fails with cmake 4.0.0 due to wsrep update wsrep-lib --- wsrep-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wsrep-lib b/wsrep-lib index 70cd967f5e2..e55f01ce1ee 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit 70cd967f5e249b53d6cce90e2e4198641c564381 +Subproject commit e55f01ce1eed02e0781bc53bb23456c936667ccf From 4de5161a70d3bfc07fa35fc000db29f6bef446d1 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Mon, 7 Apr 2025 22:02:35 +0200 Subject: [PATCH 19/30] fix build with -fno-elide-constructors Linker is trying to find a copy constructor to injector::transaction::transaction ld.lld: error: undefined symbol: injector::transaction::transaction (injector::transaction const&) >>> referenced by rpl_injector.cc:164 >>> rpl_injector.cc.o:(injector::new_trans(THD*)) This constructor is declared, but is not implemented. Ok if copy elision is enabled, but causes error otherwise. Remove the constructor declaration, so that operator= will be used in reality. --- sql/rpl_injector.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index 6a1c724809a..446b319535c 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -146,7 +146,6 @@ public: }; transaction() : m_thd(NULL) { } - transaction(transaction const&); ~transaction(); /* Clear transaction, i.e., make calls to 'good()' return false. */ From e6ea5d568c0fb972a391a8c64716846ddb7c57ef Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Wed, 5 Mar 2025 15:05:59 +0100 Subject: [PATCH 20/30] MDEV-36507 fix dbug_print_row concurrent access 7544fd4cae had to make use of a static array to avoid memory use-after-free or leak. Instead, let us make a function returning String, this is the only way to automatically manage the memory after the function returned. To make it all correct, move constructor is added. Normally, it is expected, that the constructor will be elided upon return of an object by value, but if something goes different, or -fno-elide-constructors is used, we can have a problem. So this was a move constructor avoids copy elision-related UB. dbug_print_row returning char* is still there for convenient use in a debugger. --- sql/filesort.cc | 46 +++++++++++++++++++++++++++++----------------- sql/handler.cc | 12 ++++++++---- sql/handler.h | 2 +- sql/sql_string.h | 6 ++++++ 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index 442597efe49..93152770cdc 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -637,19 +637,8 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, static char dbug_row_print_buf[4096]; -/* - Print table's current row into a buffer and return a pointer to it. - This is intended to be used from gdb: - - (gdb) p dbug_print_table_row(table) - $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" - (gdb) - - Only columns in table->read_set are printed -*/ - -const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names) +String dbug_format_row(TABLE *table, const uchar *rec, bool print_names) { Field **pfield; char row_buff_tmp[512]; @@ -717,14 +706,37 @@ const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names) output.append(tmp.ptr(), tmp.length()); } } - output.append(")"); - if (output.c_ptr() == dbug_row_print_buf) - return dbug_row_print_buf; - else - return "Couldn't fit into buffer"; + output.append(')'); + + return output; } +/** + A function to display a row in debugger. + Example usage: + (gdb) p dbug_print_row(table, table->record[1]) +*/ +const char *dbug_print_row(TABLE *table, const uchar *rec) +{ + String row= dbug_format_row(table, table->record[0]); + if (row.length() > sizeof dbug_row_print_buf - 1) + return "Couldn't fit into buffer"; + memcpy(dbug_row_print_buf, row.c_ptr(), row.length()); + return dbug_row_print_buf; +} + +/** + Print table's current row into a buffer and return a pointer to it. + + This is intended to be used from gdb: + + (gdb) p dbug_print_table_row(table) + $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" + (gdb) + + Only columns in table->read_set are printed +*/ const char* dbug_print_table_row(TABLE *table) { return dbug_print_row(table, table->record[0]); diff --git a/sql/handler.cc b/sql/handler.cc index d243a2149a8..7970aec0743 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7366,7 +7366,8 @@ int handler::ha_write_row(const uchar *buf) TABLE_IO_WAIT(tracker, PSI_TABLE_WRITE_ROW, MAX_KEY, error, { error= write_row(buf); }) - DBUG_PRINT("dml", ("INSERT: %s = %d", dbug_print_row(table, buf, false), error)); + DBUG_PRINT("dml", ("INSERT: %s = %d", + dbug_format_row(table, buf, false).c_ptr_safe(), error)); MYSQL_INSERT_ROW_DONE(error); if (likely(!error)) @@ -7425,8 +7426,10 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data) TABLE_IO_WAIT(tracker, PSI_TABLE_UPDATE_ROW, active_index, 0, { error= update_row(old_data, new_data);}) - DBUG_PRINT("dml", ("UPDATE: %s => %s = %d", dbug_print_row(table, old_data, false), - dbug_print_row(table, new_data, false), error)); + DBUG_PRINT("dml", ("UPDATE: %s => %s = %d", + dbug_format_row(table, old_data, false).c_ptr_safe(), + dbug_format_row(table, new_data, false).c_ptr_safe(), + error)); MYSQL_UPDATE_ROW_DONE(error); if (likely(!error)) @@ -7506,7 +7509,8 @@ int handler::ha_delete_row(const uchar *buf) TABLE_IO_WAIT(tracker, PSI_TABLE_DELETE_ROW, active_index, error, { error= delete_row(buf);}) - DBUG_PRINT("dml", ("DELETE: %s = %d", dbug_print_row(table, buf, false), error)); + DBUG_PRINT("dml", ("DELETE: %s = %d", + dbug_format_row(table, buf, false).c_ptr_safe(), error)); MYSQL_DELETE_ROW_DONE(error); if (likely(!error)) { diff --git a/sql/handler.h b/sql/handler.h index c06c27b08c9..46b26bc33ac 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -5324,6 +5324,6 @@ int get_select_field_pos(Alter_info *alter_info, int select_field_count, bool versioned); #ifndef DBUG_OFF -const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names= true); +String dbug_format_row(TABLE *table, const uchar *rec, bool print_names= true); #endif /* DBUG_OFF */ #endif /* HANDLER_INCLUDED */ diff --git a/sql/sql_string.h b/sql/sql_string.h index c618990e84e..7fe955e996c 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -512,6 +512,10 @@ public: extra_alloc= 0; alloced= thread_specific= 0; } + Binary_string(Binary_string &&str) noexcept + { + move(str); + } ~Binary_string() { free(); } @@ -856,6 +860,8 @@ public: Binary_string(str, len) { } String(const String &str) = default; + String(String &&str) noexcept + :Charset(std::move(str)), Binary_string(std::move(str)){} void set(String &str,size_t offset,size_t arg_length) { From 14389b69932a83a47e3fdbf1a6e2c40625013288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Apr 2025 09:22:39 +0300 Subject: [PATCH 21/30] MDEV-36510 InnoDB fails to compile with clang++-20 ut_allocator(PSI_memory_key): Remove the explicit keyword, to allow implicit instantiation of purge_sys_t::unordered_map. --- storage/innobase/include/ut0new.h | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innobase/include/ut0new.h b/storage/innobase/include/ut0new.h index 3ff5f8853e0..398dd0dcc9e 100644 --- a/storage/innobase/include/ut0new.h +++ b/storage/innobase/include/ut0new.h @@ -277,7 +277,6 @@ public: #ifdef UNIV_PFS_MEMORY /** Default constructor. */ - explicit ut_allocator(PSI_memory_key key = PSI_NOT_INSTRUMENTED) : m_key(key) { From ba34657cd22fc831bdfd06fd088644b288043652 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 22 Jan 2025 22:08:56 +0100 Subject: [PATCH 22/30] MDEV-35238 (MDEV-34922) Wrong results from a tables with a single record and an aggregate The problem is that copy function was used in field list but never copied in this execution path. So copy should be performed before returning result. Protection against uninitialized copy usage added. --- mysql-test/main/group_by.result | 64 +++++++++++++++++++ mysql-test/main/group_by.test | 22 +++++++ .../type_inet/type_inet6_engines.inc | 13 ++++ .../type_inet/type_inet6_innodb.result | 12 ++++ .../type_inet/type_inet6_memory.result | 12 ++++ .../type_inet/type_inet6_myisam.result | 12 ++++ sql/item.cc | 8 +++ sql/item.h | 22 ++++++- sql/sql_select.cc | 2 + 9 files changed, 166 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index 881febb13a4..27f2c34a6d4 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -2997,5 +2997,69 @@ UPDATE t1 SET c=1 ORDER BY (SELECT c); ERROR 42S22: Reference 'c' not supported (forward reference in item list) DROP TABLE t1; # +# MDEV-35238: Wrong results from a tables with a single record and an aggregate +# +CREATE OR REPLACE TABLE t1 (a int) ENGINE=myisam; +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +1+0 min(1) +1 NULL +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "message": "Impossible WHERE noticed after reading const tables" + } + } +} +INSERT INTO t1 VALUES (NULL); +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +1+0 min(1) +1 NULL +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "pseudo_bits_condition": "if(uuid_short(),NULL,1)", + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } +} +DROP TABLE t1; +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=myisam; +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (a int NOT NULL) ENGINE=myisam; +INSERT INTO t2 VALUES (10); +SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); +1+0 MIN(t1.a) +1 1 +explain format=json SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "pseudo_bits_condition": "10 = rand()", + "table": { + "table_name": "t1", + "access_type": "system", + "rows": 1, + "filtered": 100 + }, + "table": { + "table_name": "t2", + "access_type": "system", + "rows": 1, + "filtered": 100 + } + } +} +DROP TABLE t1,t2; +# # End of 10.5 tests # diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index eaa0d060fe9..19f2e6582ae 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -2152,6 +2152,28 @@ UPDATE t1 SET c=1 ORDER BY (SELECT c); UPDATE t1 SET c=1 ORDER BY (SELECT c); DROP TABLE t1; +--echo # +--echo # MDEV-35238: Wrong results from a tables with a single record and an aggregate +--echo # +CREATE OR REPLACE TABLE t1 (a int) ENGINE=myisam; +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +INSERT INTO t1 VALUES (NULL); +SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +explain format=json SELECT 1+0, min(1) FROM t1 WHERE if(uuid_short(), a,1); +DROP TABLE t1; + +CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=myisam; +INSERT INTO t1 VALUES (1); + +CREATE TABLE t2 (a int NOT NULL) ENGINE=myisam; +INSERT INTO t2 VALUES (10); + +SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); +explain format=json SELECT 1+0, MIN(t1.a) FROM t1,t2 WHERE t2.a = rand(); + +DROP TABLE t1,t2; + --echo # --echo # End of 10.5 tests --echo # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc b/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc index 596036fc0ee..9cf91169528 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_engines.inc @@ -36,3 +36,16 @@ SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); DROP TABLE t1; + +--echo # +--echo # MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +--echo # Type_handler_fbt::Field_fbt::store_native, +--echo # Assertion `item->null_value' failed in Type_handler::Item_send_str +--echo # + +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +DROP TABLE t1; + +--echo # End of 10.5 tests diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result index deb1c718b49..dd5e3ba9f7f 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result @@ -88,6 +88,18 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = INET6'::ff' DROP TABLE t1; # +# MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +# Type_handler_fbt::Field_fbt::store_native, +# Assertion `item->null_value' failed in Type_handler::Item_send_str +# +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +cast('::' AS INET6) min(1) +:: NULL +DROP TABLE t1; +# End of 10.5 tests +# # MDEV-26742 Assertion `field->type_handler() == this' failed in FixedBinTypeBundle::Type_handler_fbt::stored_field_cmp_to_item # CREATE TABLE t1 (pk inet6, c text) engine=myisam; diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result index e805b167136..9bf8e58fb0b 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result @@ -155,5 +155,17 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = INET6'::ff' DROP TABLE t1; # +# MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +# Type_handler_fbt::Field_fbt::store_native, +# Assertion `item->null_value' failed in Type_handler::Item_send_str +# +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +cast('::' AS INET6) min(1) +:: NULL +DROP TABLE t1; +# End of 10.5 tests +# # End of 10.5 tests # diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result index c2577ef44df..c05830f55c7 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result @@ -88,6 +88,18 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = INET6'::ff' DROP TABLE t1; # +# MDEV-34922: Assertion `value.length() == FbtImpl::binary_length()' failed in +# Type_handler_fbt::Field_fbt::store_native, +# Assertion `item->null_value' failed in Type_handler::Item_send_str +# +CREATE TABLE t1 (a datetime); +INSERT INTO t1 VALUES (NULL); +SELECT * FROM (SELECT cast('::' AS INET6),min(1) FROM t1 WHERE if(uuid_short(), a,1)) dt; +cast('::' AS INET6) min(1) +:: NULL +DROP TABLE t1; +# End of 10.5 tests +# # MDEV-26742 Assertion `field->type_handler() == this' failed in FixedBinTypeBundle::Type_handler_fbt::stored_field_cmp_to_item # CREATE TABLE t1 (c varchar(64), key(c)) engine=myisam; diff --git a/sql/item.cc b/sql/item.cc index 7143bced98b..9498d816bb0 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5218,6 +5218,7 @@ bool Item_param::assign_default(Field *field) double Item_copy_string::val_real() { + DBUG_ASSERT(copied_in); int err_not_used; char *end_not_used; return (null_value ? 0.0 : @@ -5228,6 +5229,7 @@ double Item_copy_string::val_real() longlong Item_copy_string::val_int() { + DBUG_ASSERT(copied_in); int err; return null_value ? 0 : str_value.charset()->strntoll(str_value.ptr(), str_value.length(), 10, @@ -5237,6 +5239,7 @@ longlong Item_copy_string::val_int() int Item_copy_string::save_in_field(Field *field, bool no_conversions) { + DBUG_ASSERT(copied_in); return save_str_value_in_field(field, &str_value); } @@ -5247,11 +5250,15 @@ void Item_copy_string::copy() if (res && res != &str_value) str_value.copy(*res); null_value=item->null_value; +#ifndef DBUG_OFF + copied_in= 1; +#endif } /* ARGSUSED */ String *Item_copy_string::val_str(String *str) { + DBUG_ASSERT(copied_in); // Item_copy_string is used without fix_fields call if (null_value) return (String*) 0; @@ -5261,6 +5268,7 @@ String *Item_copy_string::val_str(String *str) my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value) { + DBUG_ASSERT(copied_in); // Item_copy_string is used without fix_fields call if (null_value) return (my_decimal *) 0; diff --git a/sql/item.h b/sql/item.h index ce02b0edda1..d60d5c01985 100644 --- a/sql/item.h +++ b/sql/item.h @@ -6383,8 +6383,15 @@ protected: Type_std_attributes::set(item); name= item->name; set_handler(item->type_handler()); +#ifndef DBUG_OFF + copied_in= 0; +#endif } +#ifndef DBUG_OFF + bool copied_in; +#endif + public: /** @@ -6451,7 +6458,10 @@ public: double val_real() override; longlong val_int() override; bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override - { return get_date_from_string(thd, ltime, fuzzydate); } + { + DBUG_ASSERT(copied_in); + return get_date_from_string(thd, ltime, fuzzydate); + } void copy() override; int save_in_field(Field *field, bool no_conversions) override; Item *do_get_copy(THD *thd) const override @@ -6481,9 +6491,13 @@ public: null_value= tmp.is_null(); m_value= tmp.is_null() ? Timestamp_or_zero_datetime() : Timestamp_or_zero_datetime(tmp); +#ifndef DBUG_OFF + copied_in=1; +#endif } int save_in_field(Field *field, bool) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); if (null_value) return set_field_to_null(field); @@ -6492,30 +6506,35 @@ public: } longlong val_int() override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? 0 : m_value.to_datetime(current_thd).to_longlong(); } double val_real() override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? 0e0 : m_value.to_datetime(current_thd).to_double(); } String *val_str(String *to) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? NULL : m_value.to_datetime(current_thd).to_string(to, decimals); } my_decimal *val_decimal(my_decimal *to) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value ? NULL : m_value.to_datetime(current_thd).to_decimal(to); } bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); bool res= m_value.to_TIME(thd, ltime, fuzzydate); DBUG_ASSERT(!res); @@ -6523,6 +6542,7 @@ public: } bool val_native(THD *thd, Native *to) override { + DBUG_ASSERT(copied_in); DBUG_ASSERT(sane()); return null_value || m_value.to_native(to, decimals); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f0da265f86b..bb7cc72e623 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -20788,6 +20788,8 @@ do_select(JOIN *join, Procedure *procedure) */ clear_tables(join, &cleared_tables); } + if (join->tmp_table_param.copy_funcs.elements) + copy_fields(&join->tmp_table_param); if (!join->having || join->having->val_int()) { List *columns_list= (procedure ? &join->procedure_fields_list : From cb7e39b75bfc18813f818404c83a4fb6dc519320 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Tue, 8 Apr 2025 21:57:11 +0200 Subject: [PATCH 23/30] MDEV-36181 Field pointer may be uninitialized in fill_record Newer gcc reports: error: 'rfield' may be used uninitialized [-Werror=maybe-uninitialized] 9041 | unwind_stored_field_offsets(fields, rfield); After investigation, it turned to be an impossible case: 1. The only way it could be broken is if if (!(field= fld->field_for_view_update())) line case would succeed from the first time. 2. Consequent checks initialize rfield. fld may return NULL in field_for_view_update() only for views. 3. Before fill_record, UPDATE first calls check_fields, where field_for_view_update() result is already checked. INSERT calls check_view_insertability that checks that all view fields are updateable. It all means that field_for_view_update() cannot be NULL in fill_record, so the if can be converted to DBUG_ASSERT. This essentially shifts the responsibility on preliminary field_for_view_update() check to the caller. In this patch: 1. convert field_for_view_update() check to DBUG_ASSERT 2. harden unwind_stored_field_offsets function so that it can be used even if field_for_view_update() is NULL 3. As a consequence, `field` is passed instead of `rfield` as a terminator. 4. Initialize `field` to NULL to bypass a false-positive warning! --- sql/sql_base.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 09dac838c3f..ac4bce1dce0 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8485,14 +8485,15 @@ err_no_arena: } -static void unwind_stored_field_offsets(const List &fields, Field *end) +static void unwind_stored_field_offsets(const List &fields, Item_field *end) { - for (Item &item_field: fields) + for (Item &item: fields) { - Field *f= item_field.field_for_view_update()->field; - if (f == end) + Item_field *item_field= item.field_for_view_update(); + if (item_field == end) break; + Field *f= item_field->field; if (f->stored_in_db()) { TABLE *table= f->table; @@ -8537,7 +8538,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, { List_iterator_fast f(fields),v(values); Item *value, *fld; - Item_field *field; + Item_field *field= NULL; Field *rfield; TABLE *table; bool only_unvers_fields= update && table_arg->versioned(); @@ -8555,11 +8556,8 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, while ((fld= f++)) { - if (!(field= fld->field_for_view_update())) - { - my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name.str); - goto err_unwind_fields; - } + field= fld->field_for_view_update(); + DBUG_ASSERT(field); // ensured by check_fields or check_view_insertability. value=v++; DBUG_ASSERT(value); rfield= field->field; @@ -8621,7 +8619,7 @@ fill_record(THD *thd, TABLE *table_arg, List &fields, List &values, DBUG_RETURN(thd->is_error()); err_unwind_fields: if (update && thd->variables.sql_mode & MODE_SIMULTANEOUS_ASSIGNMENT) - unwind_stored_field_offsets(fields, rfield); + unwind_stored_field_offsets(fields, field); err: DBUG_PRINT("error",("got error")); thd->abort_on_warning= save_abort_on_warning; From ec5068fe59b6711d47217c75c13ab45bdd2c6a54 Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Fri, 7 Jun 2024 00:52:29 +0300 Subject: [PATCH 24/30] MDEV-34998: master can stop responding after cluster vote to evict a node After cluster vote to evict a node that failed a transaction, current master can't commit anymore. Error voting for joiner in the JOINED state was broken because the group-wide commit cut (implicit SUCCESS vote) was not taken into account when processing error vote request from the JOINED node. This commit adds 3 MTR tests to verify the fix in the galera library works as designed. Requires Galera library commit 91f0090a05e96c3cc353b80d961ede45cefb9279 (galera library version > 26.4.19). Signed-off-by: Julius Goryavsky --- .../galera/r/galera_vote_during_ist.result | 109 ++++++++++++ .../galera/r/galera_vote_joined_apply.result | 93 +++++++++++ .../galera/r/galera_vote_joined_skip.result | 101 +++++++++++ .../suite/galera/t/galera_vote_during_ist.cnf | 20 +++ .../galera/t/galera_vote_during_ist.test | 158 ++++++++++++++++++ .../galera/t/galera_vote_joined_apply.cnf | 21 +++ .../galera/t/galera_vote_joined_apply.test | 73 ++++++++ .../galera/t/galera_vote_joined_begin.inc | 74 ++++++++ .../suite/galera/t/galera_vote_joined_end.inc | 33 ++++ .../galera/t/galera_vote_joined_skip.cnf | 21 +++ .../galera/t/galera_vote_joined_skip.test | 100 +++++++++++ scripts/wsrep_sst_rsync.sh | 7 + 12 files changed, 810 insertions(+) create mode 100644 mysql-test/suite/galera/r/galera_vote_during_ist.result create mode 100644 mysql-test/suite/galera/r/galera_vote_joined_apply.result create mode 100644 mysql-test/suite/galera/r/galera_vote_joined_skip.result create mode 100644 mysql-test/suite/galera/t/galera_vote_during_ist.cnf create mode 100644 mysql-test/suite/galera/t/galera_vote_during_ist.test create mode 100644 mysql-test/suite/galera/t/galera_vote_joined_apply.cnf create mode 100644 mysql-test/suite/galera/t/galera_vote_joined_apply.test create mode 100644 mysql-test/suite/galera/t/galera_vote_joined_begin.inc create mode 100644 mysql-test/suite/galera/t/galera_vote_joined_end.inc create mode 100644 mysql-test/suite/galera/t/galera_vote_joined_skip.cnf create mode 100644 mysql-test/suite/galera/t/galera_vote_joined_skip.test diff --git a/mysql-test/suite/galera/r/galera_vote_during_ist.result b/mysql-test/suite/galera/r/galera_vote_during_ist.result new file mode 100644 index 00000000000..2dd295cce85 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_vote_during_ist.result @@ -0,0 +1,109 @@ +connection node_4; +connection node_3; +connection node_2; +connection node_1; +connection node_1; +connection node_2; +connection node_3; +connection node_4; +connection node_1; +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); +CREATE PROCEDURE p1(IN max INT) +BEGIN +DECLARE i INT; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET i = 0; +WHILE i < max DO +INSERT IGNORE INTO t1 VALUES (DEFAULT); +SET i = i + 1; +END WHILE; +END| +CALL p1(130); +connection node_4; +Shutting down server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +Server 4 left the cluster +connection node_1; +CALL p1(130); +connection node_1; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_2; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_3; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +INSERT INTO t2 VALUES (DEFAULT); +CALL p1(130); +connection node_1; +SET GLOBAL debug = "+d,sync.wsrep_sst_donor_after_donation"; +Restarting server 4 +Wait for server 1 to become a donor +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_sst_donor_after_donation_reached"; +Server 1 got SST request from server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_sst_donor_after_donation_continue"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; +Waiting for server 4 to leave the cluster +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_4; +Server 4 left the cluster, killing it... +Killed server 4... +Restarting server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SELECT count(*) AS expect1_390 FROM t1; +expect1_390 +390 +SELECT count(*) AS expect1_1 FROM t2; +expect1_1 +1 +connection node_2; +SELECT count(*) AS expect2_390 FROM t1; +expect2_390 +390 +SELECT count(*) AS expect2_1 FROM t2; +expect2_1 +1 +connection node_3; +SELECT count(*) AS expect3_390 FROM t1; +expect3_390 +390 +SELECT count(*) AS expect3_1 FROM t2; +expect3_1 +1 +connection node_4; +SELECT count(*) AS expect4_390 FROM t1; +expect4_390 +390 +SELECT count(*) AS expect4_1 FROM t2; +expect4_1 +1 +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); +CALL mtr.add_suppression("Failed to apply write set"); diff --git a/mysql-test/suite/galera/r/galera_vote_joined_apply.result b/mysql-test/suite/galera/r/galera_vote_joined_apply.result new file mode 100644 index 00000000000..b71487c83b9 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_vote_joined_apply.result @@ -0,0 +1,93 @@ +connection node_4; +connection node_3; +connection node_2; +connection node_1; +connection node_1; +connection node_2; +connection node_3; +connection node_4; +connection node_1; +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); +CREATE PROCEDURE p1(IN max INT) +BEGIN +DECLARE i INT; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET i = 0; +WHILE i < max DO +INSERT IGNORE INTO t1 VALUES (DEFAULT); +SET i = i + 1; +END WHILE; +END| +CALL p1(130); +connection node_4; +Shutting down server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +SET GLOBAL debug = "+d,sync.wsrep_donor_state"; +connection node_4; +Restarting server 4... +connection node_1; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_donor_state_reached"; +Tables on server 1 flushed and locked for SST to server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_donor_state"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; +Wait for the state snapshot to be copied to server 4 +SST script unlocked server 1 +connection node_1; +CALL p1(130); +connection node_1; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_2; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +connection node_3; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +INSERT INTO t2 VALUES (DEFAULT); +CALL p1(130); +Waiting for server 4 to leave the cluster +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_4; +Server 4 left the cluster, killing it... +Killed server 4... +Restarting server 4... +DROP TABLE t2; +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SELECT count(*) AS expect1_390 FROM t1; +expect1_390 +390 +connection node_2; +SELECT count(*) AS expect2_390 FROM t1; +expect2_390 +390 +connection node_3; +SELECT count(*) AS expect3_390 FROM t1; +expect3_390 +390 +connection node_4; +SELECT count(*) AS expect4_390 FROM t1; +expect4_390 +390 +DROP TABLE t1; +DROP PROCEDURE p1; +connection node_4; +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus"); +CALL mtr.add_suppression("Failed to apply write set: gtid:"); diff --git a/mysql-test/suite/galera/r/galera_vote_joined_skip.result b/mysql-test/suite/galera/r/galera_vote_joined_skip.result new file mode 100644 index 00000000000..427c34f0f39 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_vote_joined_skip.result @@ -0,0 +1,101 @@ +connection node_4; +connection node_3; +connection node_2; +connection node_1; +connection node_1; +connection node_2; +connection node_3; +connection node_4; +connection node_1; +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); +CREATE PROCEDURE p1(IN max INT) +BEGIN +DECLARE i INT; +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; +SET i = 0; +WHILE i < max DO +INSERT IGNORE INTO t1 VALUES (DEFAULT); +SET i = i + 1; +END WHILE; +END| +CALL p1(130); +connection node_4; +Shutting down server 4... +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +SET GLOBAL debug = "+d,sync.wsrep_donor_state"; +connection node_4; +Restarting server 4... +connection node_1; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_donor_state_reached"; +Tables on server 1 flushed and locked for SST to server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_donor_state"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; +Wait for the state snapshot to be copied to server 4 +SST script unlocked server 1 +connection node_1; +CALL p1(130); +connection node_3; +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; +INSERT INTO t2 VALUES (DEFAULT); +SET SESSION wsrep_on = OFF; +connection node_1; +CALL p1(130); +Waiting for server 3 to leave the cluster +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_2; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_4; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +Server 3 left the cluster, killing it... +Killed server 3. +Restarting server 3... +Waiting for server 3 to rejoin the cluster +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_3; +sleeping for 20 +Waiting ready +Server 3 restarted. +connection node_1; +SET SESSION wsrep_on = ON; +SET SESSION wsrep_sync_wait = 15; +connection node_1; +SELECT count(*) AS expect1_390 FROM t1; +expect1_390 +390 +connection node_2; +SELECT count(*) AS expect2_390 FROM t1; +expect2_390 +390 +connection node_3; +SELECT count(*) AS expect3_390 FROM t1; +expect3_390 +390 +connection node_4; +SELECT count(*) AS expect4_390 FROM t1; +expect4_390 +390 +DROP TABLE t1; +DROP PROCEDURE p1; +connection node_1; +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +connection node_2; +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +connection node_3; +CALL mtr.add_suppression("Vote 0 \\(success\\) on .* is inconsistent with group"); +connection node_4; +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); diff --git a/mysql-test/suite/galera/t/galera_vote_during_ist.cnf b/mysql-test/suite/galera/t/galera_vote_during_ist.cnf new file mode 100644 index 00000000000..d6c7d771d5d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_during_ist.cnf @@ -0,0 +1,20 @@ +!include ../galera_4nodes.cnf + +[mysqld] +wsrep-ignore-apply-errors=0 + +[mysqld.1] +wsrep_node_name='node_1' + +[mysqld.2] +wsrep_node_name='node_2' + +[mysqld.3] +wsrep_node_name='node_3' + +[mysqld.4] +wsrep_node_name='node_4' +wsrep_sst_donor='node_1' + +[ENV] +galera_cluster_size=4 diff --git a/mysql-test/suite/galera/t/galera_vote_during_ist.test b/mysql-test/suite/galera/t/galera_vote_during_ist.test new file mode 100644 index 00000000000..ee29d08567d --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_during_ist.test @@ -0,0 +1,158 @@ +# +# Test a case where a joiner encounters an error during IST +# Instead of voting it should assume error and bail out. +# + +--source include/galera_cluster.inc +--source include/big_test.inc +--source include/have_debug_sync.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--let $node_4=node_4 +--source ../include/auto_increment_offset_save.inc + +# create table t1 and procedure p1 to generate wirtesets +--connection node_1 +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); + +DELIMITER |; +CREATE PROCEDURE p1(IN max INT) +BEGIN + DECLARE i INT; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + + SET i = 0; + WHILE i < max DO + INSERT IGNORE INTO t1 VALUES (DEFAULT); + SET i = i + 1; + END WHILE; +END| +DELIMITER ;| + +CALL p1(130); + +--connection node_4 +--echo Shutting down server 4... +--let $node_4_server_id= `SELECT @@server_id` +--let $node_4_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$node_4_server_id.expect +--let $node_4_pid_file= `SELECT @@pid_file` +--source include/shutdown_mysqld.inc + +# Wait for node #4 to leave cluster +--let $members = 3 +--connection node_1 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_3 +--source include/wsrep_wait_membership.inc +--echo Server 4 left the cluster + +# Create some writesets for IST +--connection node_1 +CALL p1(130); + +# Create a writeset that node 4 won't be able to apply by creating a table +# that won't be present in the replication stream +--connection node_1 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_2 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_3 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +# This should cause error during IST +INSERT INTO t2 VALUES (DEFAULT); + +# make sure nodes 1,2,3 progress far enough for commit cut update +CALL p1(130); + +--connection node_1 +# prepare to stop SST donor thread when it receives a request from starting node #4 +SET GLOBAL debug = "+d,sync.wsrep_sst_donor_after_donation"; + +--echo Restarting server 4 +# Need to use this form instead of start_mysqld.inc because the latter is blocking +--exec echo "restart:$start_mysqld_params" > $node_4_expect_file_name + +--echo Wait for server 1 to become a donor +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_sst_donor_after_donation_reached"; +--echo Server 1 got SST request from server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_sst_donor_after_donation_continue"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; + +# +# After this point node #4 shall proceed to IST and bail out +# + +--echo Waiting for server 4 to leave the cluster +--let $members = 3 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_3 +--source include/wsrep_wait_membership.inc + +--connection node_4 +--echo Server 4 left the cluster, killing it... + +# Kill the connected server +--exec echo "wait" > $node_4_expect_file_name +--let KILL_NODE_PIDFILE = $node_4_pid_file +--perl + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -9 $mysqld_pid"); + exit(0); +EOF +--echo Killed server 4... +--source include/wait_until_disconnected.inc +--echo Restarting server 4... +--source include/start_mysqld.inc +--source include/galera_wait_ready.inc + +# Confirm node #4 has rejoined +--connection node_1 +--let $members = 4 +--source include/wsrep_wait_membership.inc + +# Confirm that all is good and all nodes have identical data + +--connection node_1 +SELECT count(*) AS expect1_390 FROM t1; +SELECT count(*) AS expect1_1 FROM t2; + +--connection node_2 +SELECT count(*) AS expect2_390 FROM t1; +SELECT count(*) AS expect2_1 FROM t2; + +--connection node_3 +SELECT count(*) AS expect3_390 FROM t1; +SELECT count(*) AS expect3_1 FROM t2; + +--connection node_4 +SELECT count(*) AS expect4_390 FROM t1; +SELECT count(*) AS expect4_1 FROM t2; + +DROP TABLE t1; +DROP TABLE t2; +DROP PROCEDURE p1; + +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); +CALL mtr.add_suppression("Failed to apply write set"); + +--source ../include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_vote_joined_apply.cnf b/mysql-test/suite/galera/t/galera_vote_joined_apply.cnf new file mode 100644 index 00000000000..88a1982bf66 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_apply.cnf @@ -0,0 +1,21 @@ +!include ../galera_4nodes.cnf + +[mysqld] +wsrep-ignore-apply-errors=0 + +[mysqld.1] +wsrep_node_name='node_1' + +[mysqld.2] +wsrep_node_name='node_2' + +[mysqld.3] +wsrep_node_name='node_3' + +[mysqld.4] +wsrep_node_name='node_4' +wsrep_sst_donor='node_1' + +[ENV] +galera_cluster_size=4 +MTR_SST_JOINER_DELAY=20 diff --git a/mysql-test/suite/galera/t/galera_vote_joined_apply.test b/mysql-test/suite/galera/t/galera_vote_joined_apply.test new file mode 100644 index 00000000000..d903b83dc0e --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_apply.test @@ -0,0 +1,73 @@ +# +# Test a case where a vote happens in JOINED state after SST on a writeset +# that should be applied. +# + +--source galera_vote_joined_begin.inc +# +# At this point state snapshot has been copied, node 1 is operational and +# we have about 10 seconds while everything we do will go into the replication +# queue on node 4 which it will have to apply on top of the snapshot. +# + +# Increase replication queue on node_4 +--connection node_1 +CALL p1(130); + +# Create a writeset that node 4 won't be able to apply by creating a table +# that won't be present in the replication stream +--connection node_1 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_2 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +--connection node_3 +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +# This should cause node #4 to initiate a vote and leave the cluster +INSERT INTO t2 VALUES (DEFAULT); + +# make sure nodes 1,2,3 progress far enough for commit cut update +CALL p1(130); + +--echo Waiting for server 4 to leave the cluster +--let $members = 3 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_1 +--source include/wsrep_wait_membership.inc + +--connection node_4 +--echo Server 4 left the cluster, killing it... +# Kill the connected server +--exec echo "wait" > $node_4_expect_file_name +--let KILL_NODE_PIDFILE = $node_4_pid_file +--perl + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -9 $mysqld_pid"); + exit(0); +EOF +--echo Killed server 4... +--source include/wait_until_disconnected.inc +--echo Restarting server 4... +--source include/start_mysqld.inc +--source include/galera_wait_ready.inc +DROP TABLE t2; + +--source galera_vote_joined_end.inc + +--connection node_4 +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); +CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus"); +CALL mtr.add_suppression("Failed to apply write set: gtid:"); diff --git a/mysql-test/suite/galera/t/galera_vote_joined_begin.inc b/mysql-test/suite/galera/t/galera_vote_joined_begin.inc new file mode 100644 index 00000000000..abc59caee81 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_begin.inc @@ -0,0 +1,74 @@ +# This file purpose is to set up node 4 to require SST which is artificaially +# prolonged and as a result accumulate sufficient relication queue. +# The contents of the qeuee are controlled in the sourcing test files. + +--source include/galera_cluster.inc +--source include/big_test.inc +--source include/have_debug_sync.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--let $node_4=node_4 +--source ../include/auto_increment_offset_save.inc + +# create table t1 and procedure p1 to generate wirtesets +--connection node_1 +CREATE TABLE t1(pk INT AUTO_INCREMENT PRIMARY KEY); + +DELIMITER |; +CREATE PROCEDURE p1(IN max INT) +BEGIN + DECLARE i INT; + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN END; + + SET i = 0; + WHILE i < max DO + INSERT IGNORE INTO t1 VALUES (DEFAULT); + SET i = i + 1; + END WHILE; +END| +DELIMITER ;| + +# 130 events move the commit cut, it is essential in voting +CALL p1(130); + +--connection node_4 +--echo Shutting down server 4... +--let $node_4_server_id= `SELECT @@server_id` +--let $node_4_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$node_4_server_id.expect +--let $node_4_pid_file= `SELECT @@pid_file` +--source include/shutdown_mysqld.inc +# enforce SST +--exec rm -rf $MYSQLTEST_VARDIR/mysqld.4/data/grastate.dat + +# Wait for node #4 to leave cluster +--connection node_1 +--let $members = 3 +--source include/wsrep_wait_membership.inc + +# prepare to stop SST donor thread when node is in donor state +SET GLOBAL debug = "+d,sync.wsrep_donor_state"; + +--connection node_4 +--echo Restarting server 4... +# Need to use this form instead of start_mysqld.inc because the latter is blocking +--exec echo "restart:$start_mysqld_params" > $node_4_expect_file_name + +# Wait for node #1 to become a donor +--connection node_1 +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_donor_state_reached"; +--echo Tables on server 1 flushed and locked for SST to server 4 +SET SESSION DEBUG_SYNC = "now SIGNAL signal.wsrep_donor_state"; +SET GLOBAL debug = ""; +SET DEBUG_SYNC='RESET'; + +--echo Wait for the state snapshot to be copied to server 4 +--source include/galera_wait_ready.inc +--echo SST script unlocked server 1 + +# +# At this point state snapshot has been copied, node 1 is operational and +# we have about 20 seconds while everything we do will go into the replication +# queue on node 4 which it will have to apply on top of the snapshot. +# diff --git a/mysql-test/suite/galera/t/galera_vote_joined_end.inc b/mysql-test/suite/galera/t/galera_vote_joined_end.inc new file mode 100644 index 00000000000..1b652634001 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_end.inc @@ -0,0 +1,33 @@ +# Confirm node #4 has rejoined +--connection node_1 +--let $members = 4 +--source include/wsrep_wait_membership.inc +#DROP TABLE IF EXISTS t2; + +# Confirm that all is good and all nodes have identical data + +--connection node_1 +SELECT count(*) AS expect1_390 FROM t1; + +#CALL mtr.add_suppression("Replica SQL: Could not execute Delete_rows"); +#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno [0-9]*"); + +--connection node_2 +SELECT count(*) AS expect2_390 FROM t1; + +#CALL mtr.add_suppression("mysqld: Can't find record in 't1'"); +#CALL mtr.add_suppression("Replica SQL: Could not execute Delete_rows"); +#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno seqno [0-9]*"); + +--connection node_3 +SELECT count(*) AS expect3_390 FROM t1; + +--connection node_4 +SELECT count(*) AS expect4_390 FROM t1; + +DROP TABLE t1; +DROP PROCEDURE p1; + +#CALL mtr.add_suppression("inconsistent with group"); + +--source ../include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_vote_joined_skip.cnf b/mysql-test/suite/galera/t/galera_vote_joined_skip.cnf new file mode 100644 index 00000000000..88a1982bf66 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_skip.cnf @@ -0,0 +1,21 @@ +!include ../galera_4nodes.cnf + +[mysqld] +wsrep-ignore-apply-errors=0 + +[mysqld.1] +wsrep_node_name='node_1' + +[mysqld.2] +wsrep_node_name='node_2' + +[mysqld.3] +wsrep_node_name='node_3' + +[mysqld.4] +wsrep_node_name='node_4' +wsrep_sst_donor='node_1' + +[ENV] +galera_cluster_size=4 +MTR_SST_JOINER_DELAY=20 diff --git a/mysql-test/suite/galera/t/galera_vote_joined_skip.test b/mysql-test/suite/galera/t/galera_vote_joined_skip.test new file mode 100644 index 00000000000..8ccd8dabbfb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_vote_joined_skip.test @@ -0,0 +1,100 @@ +# +# Test a case where a vote happens in JOINED state after SST on a writeset +# that should be skipped. I.e. JOINED node should continue operation. +# + +--source galera_vote_joined_begin.inc +# +# At this point state snapshot has been copied, node 1 is operational and +# we have about 10 seconds while everything we do will go into the replication +# queue on node 4 which it will have to apply on top of the snapshot. +# + +# Increase replication queue on node_4 +--connection node_1 +CALL p1(130); + +# +# Create a writeset that node 4 won't be able to apply by making node 3 +# inconsisitent +# +--connection node_3 +--let $node_3_server_id= `SELECT @@server_id` +--let $node_3_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$node_3_server_id.expect +--let $node_3_pid_file= `SELECT @@pid_file` +SET SESSION wsrep_on = OFF; +CREATE TABLE t2(pk INT AUTO_INCREMENT PRIMARY KEY); +SET SESSION wsrep_on = ON; + +# This should cause nodes #1 and #2 to initiate a vote and kick node #3 +# out of the cluster, node #4 should recover the vote when fails to apply +# the event and continue +INSERT INTO t2 VALUES (DEFAULT); +SET SESSION wsrep_on = OFF; + +# make sure nodes 1,2 progress far enough for commit cut update +--connection node_1 +CALL p1(130); + +--let $members = 3 +--echo Waiting for server 3 to leave the cluster +--connection node_1 +--source include/wsrep_wait_membership.inc +--connection node_2 +--source include/wsrep_wait_membership.inc +--connection node_4 +# need to wait for extra SST delay on joiner +--sleep $MTR_SST_JOINER_DELAY +--sleep $MTR_SST_JOINER_DELAY +--enable_reconnect +--let $wait_timeout = 60 +--source include/wsrep_wait_membership.inc + +--connection node_3 +--echo Server 3 left the cluster, killing it... +# Kill the connected server +--exec echo "wait" > $node_3_expect_file_name +--let KILL_NODE_PIDFILE = $node_3_pid_file +--perl + my $pid_filename = $ENV{'KILL_NODE_PIDFILE'}; + my $mysqld_pid = `cat $pid_filename`; + chomp($mysqld_pid); + system("kill -9 $mysqld_pid"); + exit(0); +EOF +--echo Killed server 3. +--source include/wait_until_disconnected.inc +--echo Restarting server 3... +--exec echo "restart:$start_mysqld_params" > $node_3_expect_file_name + +--echo Waiting for server 3 to rejoin the cluster +--connection node_1 +--let $members = 3 +--source include/wsrep_wait_membership.inc + +--connection node_3 +--echo sleeping for $MTR_SST_JOINER_DELAY +# need to wait for extra SST delay on joiner +--sleep $MTR_SST_JOINER_DELAY +--sleep $MTR_SST_JOINER_DELAY +--echo Waiting ready +--enable_reconnect +--source include/galera_wait_ready.inc +--echo Server 3 restarted. + +--source galera_vote_joined_end.inc + +--connection node_1 +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); + +--connection node_2 +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); + +--connection node_3 +CALL mtr.add_suppression("Vote 0 \\(success\\) on .* is inconsistent with group"); + +--connection node_4 +CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 2b90f2047b3..6e0336713ea 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -915,6 +915,13 @@ EOF fi fi + # Delay for MTR tests if needed to simulate long SST + if [ ${MTR_SST_JOINER_DELAY:=0} -gt 0 ] + then + wsrep_log_info "Sleeping $MTR_SST_JOINER_DELAY seconds for MTR test" + sleep $MTR_SST_JOINER_DELAY + fi + # Remove special tags from the magic file, and from the output: coords=$(head -n1 "$MAGIC_FILE") wsrep_log_info "Galera co-ords from recovery: $coords" From bbd0e4b2c92f6456989e9540ee161ca7d8e4fa0e Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Thu, 3 Apr 2025 14:15:34 +0200 Subject: [PATCH 25/30] MDEV-34998 addendum: post-fix corrections for SST scripts Delaying scripts on joiner after SST/IST has been made a common debug feature for all suitable SST/IST methods. Also some minor fixes have been made for new tests. --- .../suite/galera/r/galera_vote_during_ist.result | 3 ++- .../suite/galera/r/galera_vote_joined_apply.result | 3 ++- .../suite/galera/r/galera_vote_joined_skip.result | 9 +++++---- .../suite/galera/t/galera_vote_during_ist.test | 7 ++++++- .../suite/galera/t/galera_vote_joined_apply.test | 2 +- .../suite/galera/t/galera_vote_joined_begin.inc | 5 +++++ .../suite/galera/t/galera_vote_joined_end.inc | 4 ++-- .../suite/galera/t/galera_vote_joined_skip.test | 8 ++++---- scripts/wsrep_sst_common.sh | 13 +++++++++++++ scripts/wsrep_sst_mariabackup.sh | 2 ++ scripts/wsrep_sst_mysqldump.sh | 4 ++++ scripts/wsrep_sst_rsync.sh | 7 +------ 12 files changed, 47 insertions(+), 20 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_vote_during_ist.result b/mysql-test/suite/galera/r/galera_vote_during_ist.result index 2dd295cce85..0949742a21e 100644 --- a/mysql-test/suite/galera/r/galera_vote_during_ist.result +++ b/mysql-test/suite/galera/r/galera_vote_during_ist.result @@ -2,6 +2,7 @@ connection node_4; connection node_3; connection node_2; connection node_1; +# Correct Galera library found connection node_1; connection node_2; connection node_3; @@ -103,7 +104,7 @@ expect4_1 DROP TABLE t1; DROP TABLE t2; DROP PROCEDURE p1; -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); CALL mtr.add_suppression("Failed to apply write set"); diff --git a/mysql-test/suite/galera/r/galera_vote_joined_apply.result b/mysql-test/suite/galera/r/galera_vote_joined_apply.result index b71487c83b9..4458dd32fb8 100644 --- a/mysql-test/suite/galera/r/galera_vote_joined_apply.result +++ b/mysql-test/suite/galera/r/galera_vote_joined_apply.result @@ -2,6 +2,7 @@ connection node_4; connection node_3; connection node_2; connection node_1; +# Correct Galera library found connection node_1; connection node_2; connection node_3; @@ -87,7 +88,7 @@ expect4_390 DROP TABLE t1; DROP PROCEDURE p1; connection node_4; -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus"); CALL mtr.add_suppression("Failed to apply write set: gtid:"); diff --git a/mysql-test/suite/galera/r/galera_vote_joined_skip.result b/mysql-test/suite/galera/r/galera_vote_joined_skip.result index 427c34f0f39..187028fd55c 100644 --- a/mysql-test/suite/galera/r/galera_vote_joined_skip.result +++ b/mysql-test/suite/galera/r/galera_vote_joined_skip.result @@ -2,6 +2,7 @@ connection node_4; connection node_3; connection node_2; connection node_1; +# Correct Galera library found connection node_1; connection node_2; connection node_3; @@ -89,13 +90,13 @@ expect4_390 DROP TABLE t1; DROP PROCEDURE p1; connection node_1; -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); connection node_2; -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); connection node_3; -CALL mtr.add_suppression("Vote 0 \\(success\\) on .* is inconsistent with group"); +CALL mtr.add_suppression("Vote 0 \\(success\\) on .+ is inconsistent with group"); connection node_4; -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); diff --git a/mysql-test/suite/galera/t/galera_vote_during_ist.test b/mysql-test/suite/galera/t/galera_vote_during_ist.test index ee29d08567d..d18014551c1 100644 --- a/mysql-test/suite/galera/t/galera_vote_during_ist.test +++ b/mysql-test/suite/galera/t/galera_vote_during_ist.test @@ -5,8 +5,13 @@ --source include/galera_cluster.inc --source include/big_test.inc +--source include/have_debug.inc --source include/have_debug_sync.inc +# Make sure that the test is operating on the right version of galera library. +--let $galera_version=26.4.19 +source ../wsrep/include/check_galera_version.inc; + --let $node_1=node_1 --let $node_2=node_2 --let $node_3=node_3 @@ -150,7 +155,7 @@ DROP TABLE t1; DROP TABLE t2; DROP PROCEDURE p1; -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); CALL mtr.add_suppression("Failed to apply write set"); diff --git a/mysql-test/suite/galera/t/galera_vote_joined_apply.test b/mysql-test/suite/galera/t/galera_vote_joined_apply.test index d903b83dc0e..bbd40323f87 100644 --- a/mysql-test/suite/galera/t/galera_vote_joined_apply.test +++ b/mysql-test/suite/galera/t/galera_vote_joined_apply.test @@ -67,7 +67,7 @@ DROP TABLE t2; --source galera_vote_joined_end.inc --connection node_4 -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus"); CALL mtr.add_suppression("Failed to apply write set: gtid:"); diff --git a/mysql-test/suite/galera/t/galera_vote_joined_begin.inc b/mysql-test/suite/galera/t/galera_vote_joined_begin.inc index abc59caee81..3e8befc3ece 100644 --- a/mysql-test/suite/galera/t/galera_vote_joined_begin.inc +++ b/mysql-test/suite/galera/t/galera_vote_joined_begin.inc @@ -4,8 +4,13 @@ --source include/galera_cluster.inc --source include/big_test.inc +--source include/have_debug.inc --source include/have_debug_sync.inc +# Make sure that the test is operating on the right version of galera library. +--let $galera_version=26.4.19 +source ../wsrep/include/check_galera_version.inc; + --let $node_1=node_1 --let $node_2=node_2 --let $node_3=node_3 diff --git a/mysql-test/suite/galera/t/galera_vote_joined_end.inc b/mysql-test/suite/galera/t/galera_vote_joined_end.inc index 1b652634001..3ba138bbbf9 100644 --- a/mysql-test/suite/galera/t/galera_vote_joined_end.inc +++ b/mysql-test/suite/galera/t/galera_vote_joined_end.inc @@ -10,14 +10,14 @@ SELECT count(*) AS expect1_390 FROM t1; #CALL mtr.add_suppression("Replica SQL: Could not execute Delete_rows"); -#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno [0-9]*"); +#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno [0-9]+"); --connection node_2 SELECT count(*) AS expect2_390 FROM t1; #CALL mtr.add_suppression("mysqld: Can't find record in 't1'"); #CALL mtr.add_suppression("Replica SQL: Could not execute Delete_rows"); -#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno seqno [0-9]*"); +#CALL mtr.add_suppression("Event 3 Delete_rows apply failed: 120, seqno seqno [0-9]+"); --connection node_3 SELECT count(*) AS expect3_390 FROM t1; diff --git a/mysql-test/suite/galera/t/galera_vote_joined_skip.test b/mysql-test/suite/galera/t/galera_vote_joined_skip.test index 8ccd8dabbfb..2019b639be1 100644 --- a/mysql-test/suite/galera/t/galera_vote_joined_skip.test +++ b/mysql-test/suite/galera/t/galera_vote_joined_skip.test @@ -85,16 +85,16 @@ EOF --source galera_vote_joined_end.inc --connection node_1 -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); --connection node_2 -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); --connection node_3 -CALL mtr.add_suppression("Vote 0 \\(success\\) on .* is inconsistent with group"); +CALL mtr.add_suppression("Vote 0 \\(success\\) on .+ is inconsistent with group"); --connection node_4 -CALL mtr.add_suppression("BF applier failed to open_and_lock_tables: 1146"); +CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables for Table "); CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 550165b0c3a..38aa18d5f69 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -1910,4 +1910,17 @@ create_data SST_PID="$DATA/wsrep_sst.pid" +if [ -n "${MTR_SST_JOINER_DELAY:-}" ]; then + MTR_SST_JOINER_DELAY=$(trim_string "$MTR_SST_JOINER_DELAY") +fi + +simulate_long_sst() +{ + # Delay for MTR tests if needed to simulate long SST/IST: + if [ ${MTR_SST_JOINER_DELAY:-0} -gt 0 ]; then + wsrep_log_info "Sleeping $MTR_SST_JOINER_DELAY seconds for MTR test" + sleep $MTR_SST_JOINER_DELAY + fi +} + wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE started on $WSREP_SST_OPT_ROLE" diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 3e13efb6c6d..d6de8fc1127 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -1519,6 +1519,8 @@ else # joiner exit 2 fi + simulate_long_sst + # use donor magic file, if present # if IST was used, donor magic file was not created # Remove special tags from the magic file, and from the output: diff --git a/scripts/wsrep_sst_mysqldump.sh b/scripts/wsrep_sst_mysqldump.sh index f8fbda24356..eee38c136c8 100644 --- a/scripts/wsrep_sst_mysqldump.sh +++ b/scripts/wsrep_sst_mysqldump.sh @@ -184,5 +184,9 @@ else echo "$SET_START_POSITION" | $MYSQL || exit $? fi +if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then + simulate_long_sst +fi + wsrep_log_info "$WSREP_METHOD $WSREP_TRANSFER_TYPE completed on $WSREP_SST_OPT_ROLE" exit 0 diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 6e0336713ea..90d439b9316 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -915,12 +915,7 @@ EOF fi fi - # Delay for MTR tests if needed to simulate long SST - if [ ${MTR_SST_JOINER_DELAY:=0} -gt 0 ] - then - wsrep_log_info "Sleeping $MTR_SST_JOINER_DELAY seconds for MTR test" - sleep $MTR_SST_JOINER_DELAY - fi + simulate_long_sst # Remove special tags from the magic file, and from the output: coords=$(head -n1 "$MAGIC_FILE") From 77391482bdd3b78f977cd1a4d6bd8f6fc6cec98e Mon Sep 17 00:00:00 2001 From: Alexey Yurchenko Date: Fri, 11 Apr 2025 22:22:41 +0200 Subject: [PATCH 26/30] MDEV-34998: master can stop responding after cluster vote to evict a node Additional corrections: there is a natural race between closing connection to cluster in case of applying error and finishing the IST and sometimes IST finishes and tries to send JOIN message over a closed connection. This does not affect the correctness of the test or node behavior. Added error message suppression. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/galera_vote_during_ist.result | 2 ++ mysql-test/suite/galera/t/galera_vote_during_ist.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/suite/galera/r/galera_vote_during_ist.result b/mysql-test/suite/galera/r/galera_vote_during_ist.result index 0949742a21e..adbe0e2fe7d 100644 --- a/mysql-test/suite/galera/r/galera_vote_during_ist.result +++ b/mysql-test/suite/galera/r/galera_vote_during_ist.result @@ -108,3 +108,5 @@ CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables fo CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); CALL mtr.add_suppression("Failed to apply write set"); +CALL mtr.add_suppression("Sending JOIN failed: -103"); +CALL mtr.add_suppression("Failed to JOIN the cluster after SST"); diff --git a/mysql-test/suite/galera/t/galera_vote_during_ist.test b/mysql-test/suite/galera/t/galera_vote_during_ist.test index d18014551c1..eff7f527300 100644 --- a/mysql-test/suite/galera/t/galera_vote_during_ist.test +++ b/mysql-test/suite/galera/t/galera_vote_during_ist.test @@ -159,5 +159,7 @@ CALL mtr.add_suppression("BF applier thread=.+ failed to open_and_lock_tables fo CALL mtr.add_suppression("Event 3 Write_rows_v1 apply failed: 1146"); CALL mtr.add_suppression("Inconsistency detected: Failed on preordered"); CALL mtr.add_suppression("Failed to apply write set"); +CALL mtr.add_suppression("Sending JOIN failed: -103"); +CALL mtr.add_suppression("Failed to JOIN the cluster after SST"); --source ../include/auto_increment_offset_restore.inc From 08f902e9ce525e0512c5d6d43b6548200c6fc673 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Mon, 7 Apr 2025 17:28:32 +0200 Subject: [PATCH 27/30] MDEV-36116: correction for error codes --- mysql-test/suite/galera/r/MDEV-36116.result | 2 +- mysql-test/suite/galera/t/MDEV-36116.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera/r/MDEV-36116.result b/mysql-test/suite/galera/r/MDEV-36116.result index 11899b9c09b..fe992d118f0 100644 --- a/mysql-test/suite/galera/r/MDEV-36116.result +++ b/mysql-test/suite/galera/r/MDEV-36116.result @@ -9,7 +9,7 @@ connection con1; SET DEBUG_SYNC = 'now WAIT_FOR may_kill'; SET DEBUG_SYNC = 'now SIGNAL continue'; connection node_1; -ERROR HY000: Lost connection to MySQL server during query +Got one of the listed errors connection node_2; SHOW TABLES LIKE 't1'; Tables_in_test (t1) diff --git a/mysql-test/suite/galera/t/MDEV-36116.test b/mysql-test/suite/galera/t/MDEV-36116.test index eb166e69066..c216e00652f 100644 --- a/mysql-test/suite/galera/t/MDEV-36116.test +++ b/mysql-test/suite/galera/t/MDEV-36116.test @@ -27,7 +27,7 @@ SET DEBUG_SYNC = 'now WAIT_FOR may_kill'; SET DEBUG_SYNC = 'now SIGNAL continue'; --connection node_1 ---error 2013 +--error 2013,2026 --reap # Verify no tables created on either nodes. From 0403f0147f176190b6a2ca61996c12eada275e4c Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Mon, 7 Apr 2025 17:40:33 +0200 Subject: [PATCH 28/30] MDEV-33136: backport corrections from 10.11+ --- mysql-test/suite/galera/r/MDEV-33136.result | 2 +- mysql-test/suite/galera/t/MDEV-33136.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/galera/r/MDEV-33136.result b/mysql-test/suite/galera/r/MDEV-33136.result index 36159fa05cd..fb9945235d6 100644 --- a/mysql-test/suite/galera/r/MDEV-33136.result +++ b/mysql-test/suite/galera/r/MDEV-33136.result @@ -4,7 +4,7 @@ connect node_1a,127.0.0.1,root,,test,$NODE_MYPORT_1; connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; connection node_1a; -TRUNCATE TABLE t1; +RENAME TABLE t1 TO tmp, tmp TO t1; SET SESSION wsrep_retry_autocommit = 0; SET DEBUG_SYNC = 'dict_stats_mdl_acquired SIGNAL may_toi WAIT_FOR bf_abort'; INSERT INTO t1 VALUES (1); diff --git a/mysql-test/suite/galera/t/MDEV-33136.test b/mysql-test/suite/galera/t/MDEV-33136.test index 4b484eb47da..dc1ae1aecdd 100644 --- a/mysql-test/suite/galera/t/MDEV-33136.test +++ b/mysql-test/suite/galera/t/MDEV-33136.test @@ -20,8 +20,8 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; --connection node_1a -TRUNCATE TABLE t1; -# TRUNCATE forces the next statement to re-read statistics from persistent storage, +RENAME TABLE t1 TO tmp, tmp TO t1; +# RENAME forces the next statement to re-read statistics from persistent storage, # which will acquire MDL locks on the statistics tables in InnoDB. SET SESSION wsrep_retry_autocommit = 0; SET DEBUG_SYNC = 'dict_stats_mdl_acquired SIGNAL may_toi WAIT_FOR bf_abort'; From ee947fae80dc5f82d2c964cd0d8e897e9c244002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 2 Apr 2025 14:44:41 +0300 Subject: [PATCH 29/30] MDEV-36464 : Galera test failure on galera_3nodes.galera_gtid_2_cluster Test changes only. Add wait conditions after INSERT-clauses to make sure that they are replicated before checking gtid position or table contents. Signed-off-by: Julius Goryavsky --- .../t/galera_gtid_2_cluster.test | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test index 750f840c470..fe71303277c 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test +++ b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test @@ -77,6 +77,8 @@ select @@gtid_binlog_state; --echo cluster 2 node 1 --connection node_4 +--let $wait_condition = SELECT COUNT(*) = 1 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 21, 1); select @@gtid_binlog_state; @@ -85,11 +87,16 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 1 node 2 --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc + select @@gtid_binlog_state; insert into t1 values (1, 12, 3); select @@gtid_binlog_state; @@ -99,10 +106,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 1 node 3 --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (1, 13, 4); select @@gtid_binlog_state; @@ -112,10 +123,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 2 --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 22, 2); select @@gtid_binlog_state; @@ -125,37 +140,55 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 3 --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 23, 3); select @@gtid_binlog_state; --echo #wait for sync cluster 2 and 1 --connection node_4 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo # check other nodes are consistent --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --echo cluster 1 node 1 --connection node_1 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; drop table t1; stop slave; @@ -250,6 +283,8 @@ select @@gtid_binlog_state; --sleep 2 --echo cluster 2 node 1 --connection node_4 +--let $wait_condition = SELECT COUNT(*) = 1 FROM test.t1; +--source include/wait_condition.inc insert into t1 values (2, 21, 1); select @@gtid_binlog_state; @@ -258,11 +293,16 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc + select * from t1 order by 1, 2, 3; --echo cluster 1 node 2 --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (1, 12, 3); select @@gtid_binlog_state; @@ -272,10 +312,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 1 node 3 --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (1, 13, 4); select @@gtid_binlog_state; @@ -285,10 +329,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_4 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 2 --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 22, 2); select @@gtid_binlog_state; @@ -298,10 +346,14 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo cluster 2 node 3 --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 5 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; insert into t1 values (2, 23, 3); select @@gtid_binlog_state; @@ -311,24 +363,36 @@ select @@gtid_binlog_state; --source include/save_master_gtid.inc --connection node_1 --source include/sync_with_master_gtid.inc +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select * from t1 order by 1, 2, 3; --echo # check other nodes are consistent --connection node_2 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_3 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_5 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --connection node_6 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; select * from t1 order by 1, 2, 3; --echo cluster 1 node 1 --connection node_1 +--let $wait_condition = SELECT COUNT(*) = 6 FROM test.t1; +--source include/wait_condition.inc select @@gtid_binlog_state; drop table t1; stop slave; From 5f2562291c8c2792c33048c1bd21c3ccd18ac75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 8 Apr 2025 09:56:47 +0300 Subject: [PATCH 30/30] MDEV-36509 : Galera test failure on galera_sr.mysql-wsrep-features#165 Problem was that thread was holding lock_sys.wait_mutex when streaming replication transaction rollback was handled and in wsrep-lib requests THD::LOCK_thd_kill mutex causing wrong mutex usage (thd->reset_globals()). Fix is to remove streaming replication rollback handling from Deadlock::report() i.e. wsrep_handle_SR_rollback call. Purpose of Deadloc::report() is to find a cycle in the waits-for graph if exists, report it, mark victim transaction as deadlock victim and release locks it is waiting for. Actual streaming replication rollback that can take longer time can be handled later at trx_t::rollback where lock_sys.wait_mutex is not held. Signed-off-by: Julius Goryavsky --- storage/innobase/lock/lock0lock.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index d258e5c6b27..7ecdc034bbc 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -7108,10 +7108,6 @@ and less modified rows. Bit 0 is used to prefer orig_trx in case of a tie. victim->lock.was_chosen_as_deadlock_victim= true; DEBUG_SYNC_C("deadlock_report_before_lock_releasing"); lock_cancel_waiting_and_release(victim->lock.wait_lock); -#ifdef WITH_WSREP - if (victim->is_wsrep() && wsrep_thd_is_SR(victim->mysql_thd)) - wsrep_handle_SR_rollback(trx->mysql_thd, victim->mysql_thd); -#endif } func_exit: