From 3deac2ea77c78c653b47774a7551a02760ed0806 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 28 Feb 2025 19:16:14 +0100 Subject: [PATCH 1/3] galera_inject_bf_log_wait mtr test: more stable test Added explicit checkpoint wait instead of implicit assumption that statement sent via --send will already be executed when lock-contesting statement is started in another session. --- mysql-test/suite/galera/r/galera_inject_bf_long_wait.result | 4 ++++ mysql-test/suite/galera/t/galera_inject_bf_long_wait.test | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/mysql-test/suite/galera/r/galera_inject_bf_long_wait.result b/mysql-test/suite/galera/r/galera_inject_bf_long_wait.result index eeacc9ab212..9ee8a4893c4 100644 --- a/mysql-test/suite/galera/r/galera_inject_bf_long_wait.result +++ b/mysql-test/suite/galera/r/galera_inject_bf_long_wait.result @@ -3,8 +3,11 @@ connection node_1; CREATE TABLE t1(id int not null primary key, b int) engine=InnoDB; INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3); BEGIN; +SET DEBUG_SYNC = 'wsrep_after_statement_enter SIGNAL blocked'; UPDATE t1 set b = 100 where id between 1 and 2;; connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET DEBUG_SYNC = 'now WAIT_FOR blocked'; +SET DEBUG_SYNC = 'wsrep_after_statement_enter CLEAR'; connection node_1b; SET @save_dbug = @@SESSION.debug_dbug; SET @@SESSION.innodb_lock_wait_timeout=2; @@ -20,5 +23,6 @@ id b 1 100 2 100 3 3 +SET DEBUG_SYNC = 'RESET'; disconnect node_1b; DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_inject_bf_long_wait.test b/mysql-test/suite/galera/t/galera_inject_bf_long_wait.test index f4aac7fd795..1aeb1981150 100644 --- a/mysql-test/suite/galera/t/galera_inject_bf_long_wait.test +++ b/mysql-test/suite/galera/t/galera_inject_bf_long_wait.test @@ -6,9 +6,14 @@ CREATE TABLE t1(id int not null primary key, b int) engine=InnoDB; INSERT INTO t1 VALUES (0,0),(1,1),(2,2),(3,3); BEGIN; +SET DEBUG_SYNC = 'wsrep_after_statement_enter SIGNAL blocked'; --send UPDATE t1 set b = 100 where id between 1 and 2; --connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 + +SET DEBUG_SYNC = 'now WAIT_FOR blocked'; +SET DEBUG_SYNC = 'wsrep_after_statement_enter CLEAR'; + --connection node_1b SET @save_dbug = @@SESSION.debug_dbug; SET @@SESSION.innodb_lock_wait_timeout=2; @@ -21,5 +26,6 @@ SET @@SESSION.debug_dbug = @save_dbug; --reap COMMIT; SELECT * FROM t1; +SET DEBUG_SYNC = 'RESET'; --disconnect node_1b DROP TABLE t1; From 7544fd4caeb959bdb573a4b09fbfa225a1ab37a6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 20 Feb 2025 00:06:09 +0100 Subject: [PATCH 2/3] fix problem of reallocated string --- sql/filesort.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index af03067257c..a0e16791f89 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -634,6 +634,9 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, } #ifndef DBUG_OFF + +static char dbug_row_print_buf[4096]; + /* Print table's current row into a buffer and return a pointer to it. @@ -649,11 +652,9 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names) { Field **pfield; - const size_t alloc_size= 512; - char *row_buff= (char *) alloc_root(&table->mem_root, alloc_size); - char *row_buff_tmp= (char *) alloc_root(&table->mem_root, alloc_size); - String tmp(row_buff_tmp, alloc_size, &my_charset_bin); - String output(row_buff, alloc_size, &my_charset_bin); + char row_buff_tmp[512]; + String tmp(row_buff_tmp, sizeof(row_buff_tmp), &my_charset_bin); + String output(dbug_row_print_buf, sizeof(dbug_row_print_buf), &my_charset_bin); auto move_back_lambda= [table, rec]() mutable { table->move_fields(table->field, table->record[0], rec); @@ -717,8 +718,10 @@ const char* dbug_print_row(TABLE *table, const uchar *rec, bool print_names) } } output.append(")"); - - return output.c_ptr_safe(); + if (output.c_ptr() == dbug_row_print_buf) + return dbug_row_print_buf; + else + return "Couldn't fit into buffer"; } From 3a4c0295ae0973a068eaac5f1edef6c69bbf5e48 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 4 Mar 2025 03:22:19 +0100 Subject: [PATCH 3/3] galera: synchronization between branches and editions --- mysql-test/suite/galera/r/galera_nonPK_and_PA.result | 4 ++-- mysql-test/suite/galera/t/galera_nonPK_and_PA.test | 6 ++---- mysql-test/suite/galera/t/galera_sync_wait_upto.test | 2 -- sql/handler.cc | 6 ++++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_nonPK_and_PA.result b/mysql-test/suite/galera/r/galera_nonPK_and_PA.result index 5ad55417fd1..d440d66e8d7 100644 --- a/mysql-test/suite/galera/r/galera_nonPK_and_PA.result +++ b/mysql-test/suite/galera/r/galera_nonPK_and_PA.result @@ -8,7 +8,7 @@ connection node_2; SET SESSION wsrep_sync_wait = 0; SET GLOBAL wsrep_slave_threads = 2; *************************************************************** -scenario 1, conflicting UPDATE +scenario 1, conflicting UPDATE *************************************************************** SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_slave_enter_sync'; connection node_1; @@ -31,7 +31,7 @@ SET SESSION wsrep_on = 1; SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_slave_enter_sync'; SET GLOBAL wsrep_provider_options = 'dbug='; *************************************************************** -scenario 2, conflicting DELETE +scenario 2, conflicting DELETE *************************************************************** SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_slave_enter_sync'; connection node_1; diff --git a/mysql-test/suite/galera/t/galera_nonPK_and_PA.test b/mysql-test/suite/galera/t/galera_nonPK_and_PA.test index dbd516e9b31..c7592d8fe88 100644 --- a/mysql-test/suite/galera/t/galera_nonPK_and_PA.test +++ b/mysql-test/suite/galera/t/galera_nonPK_and_PA.test @@ -26,7 +26,6 @@ --source include/have_debug_sync.inc --source include/galera_have_debug_sync.inc - # Setup CREATE TABLE t1 (f1 VARCHAR(32) NOT NULL) ENGINE=InnoDB; @@ -44,7 +43,7 @@ SET SESSION wsrep_sync_wait = 0; SET GLOBAL wsrep_slave_threads = 2; --echo *************************************************************** ---echo scenario 1, conflicting UPDATE +--echo scenario 1, conflicting UPDATE --echo *************************************************************** # Set up a synchronization point to catch the first transaction @@ -99,9 +98,8 @@ COMMIT; --source include/galera_signal_sync_point.inc --source include/galera_clear_sync_point.inc - --echo *************************************************************** ---echo scenario 2, conflicting DELETE +--echo scenario 2, conflicting DELETE --echo *************************************************************** # Set up a synchronization point to catch the first transaction diff --git a/mysql-test/suite/galera/t/galera_sync_wait_upto.test b/mysql-test/suite/galera/t/galera_sync_wait_upto.test index aaecd8760f5..56d5aac73a7 100644 --- a/mysql-test/suite/galera/t/galera_sync_wait_upto.test +++ b/mysql-test/suite/galera/t/galera_sync_wait_upto.test @@ -4,7 +4,6 @@ --source include/galera_cluster.inc --source include/have_debug.inc ---source include/have_debug_sync.inc CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); @@ -44,7 +43,6 @@ SELECT WSREP_SYNC_WAIT_UPTO_GTID('1-1-1,1-1-2'); --eval SELECT WSREP_SYNC_WAIT_UPTO_GTID('$wsrep_last_committed_gtid') AS WSREP_SYNC_WAIT_UPTO; --enable_query_log - # Timeout if GTID is not received on time --disable_query_log diff --git a/sql/handler.cc b/sql/handler.cc index 2be0740fdd8..75c79f2bb5a 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -668,6 +668,8 @@ int ha_initialize_handlerton(void *plugin_) DBUG_EXECUTE_IF("unstable_db_type", { static int i= (int) DB_TYPE_FIRST_DYNAMIC; + while (installed_htons[i]) + i++; hton->db_type= (enum legacy_db_type)++i; }); @@ -2164,7 +2166,7 @@ int ha_rollback_trans(THD *thd, bool all) "conf %d wsrep_err %s SQL %s", thd->thread_id, thd->query_id, thd->wsrep_trx().state(), wsrep::to_c_string(thd->wsrep_cs().current_error()), - thd->query()); + wsrep_thd_query(thd)); } #endif /* WITH_WSREP */ } @@ -2180,7 +2182,7 @@ int ha_rollback_trans(THD *thd, bool all) if (WSREP(thd) && thd->is_error()) { WSREP_DEBUG("ha_rollback_trans(%lld, %s) rolled back: msg %s is_real %d wsrep_err %s", - thd->thread_id, all? "TRUE" : "FALSE", + thd->thread_id, all ? "TRUE" : "FALSE", thd->get_stmt_da()->message(), is_real_trans, wsrep::to_c_string(thd->wsrep_cs().current_error())); }