From 0e737f78980fcfe83b05c27215eb3f5ede1ea473 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Tue, 20 Dec 2022 14:25:21 +0100 Subject: [PATCH 01/12] MDEV-30186 Use of uninitialized value in substitution Reviewer: <> --- mysql-test/mariadb-test-run.pl | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 46a51d2fa58..670f63a990f 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -145,6 +145,7 @@ my $opt_start_exit; my $start_only; my $file_wsrep_provider; my $num_saved_cores= 0; # Number of core files saved in vardir/log/ so far. +my $test_name_for_report; our @global_suppressions; @@ -515,13 +516,13 @@ sub main { } if ( not @$completed ) { - my $test_name= mtr_grab_file($path_testlog); - $test_name =~ s/^CURRENT_TEST:\s//; - chomp($test_name); - my $tinfo = My::Test->new(name => $test_name); - $tinfo->{result}= 'MTR_RES_FAILED'; - $tinfo->{comment}=' '; - mtr_report_test($tinfo); + if ($test_name_for_report) + { + my $tinfo = My::Test->new(name => $test_name_for_report); + $tinfo->{result}= 'MTR_RES_FAILED'; + $tinfo->{comment}=' '; + mtr_report_test($tinfo); + } mtr_error("Test suite aborted"); } @@ -3740,8 +3741,8 @@ sub resfile_report_test ($) { sub run_testcase ($$) { my ($tinfo, $server_socket)= @_; my $print_freq=20; - - mtr_verbose("Running test:", $tinfo->{name}); + $test_name_for_report= $tinfo->{name}; + mtr_verbose("Running test:", $test_name_for_report); $ENV{'MTR_TEST_NAME'} = $tinfo->{name}; resfile_report_test($tinfo) if $opt_resfile; @@ -5130,12 +5131,10 @@ sub mysqld_start ($$) { if (!$rc) { # Report failure about the last test case before exit - my $test_name= mtr_grab_file($path_current_testlog); - $test_name =~ s/^CURRENT_TEST:\s//; - my $tinfo = My::Test->new(name => $test_name); + my $tinfo = My::Test->new(name => $test_name_for_report); $tinfo->{result}= 'MTR_RES_FAILED'; $tinfo->{failures}= 1; - $tinfo->{logfile}=get_log_from_proc($mysqld->{'proc'}, $tinfo->{name}); + $tinfo->{logfile}=get_log_from_proc($mysqld->{'proc'}, $test_name_for_report); report_option('verbose', 1); mtr_report_test($tinfo); } From b482e87f26972506cc4a79317d0f9339586506ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 28 Sep 2021 22:14:36 +0300 Subject: [PATCH 02/12] Silence gcc-11 warnings --- storage/connect/bsonudf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/connect/bsonudf.cpp b/storage/connect/bsonudf.cpp index 618c0168470..e86ddd7c1b7 100644 --- a/storage/connect/bsonudf.cpp +++ b/storage/connect/bsonudf.cpp @@ -3571,7 +3571,7 @@ char *bson_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result, } // endif Xchk if (!CheckMemory(g, initid, args, 2, false, false, true)) { - JTYP type; + JTYP type= TYPE_JAR; BJNX bnx(g); PBVAL jvp = NULL, top = NULL; PBVAL jsp[2] = {NULL, NULL}; @@ -5722,7 +5722,7 @@ char *bbin_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result, } // endif Xchk if (!CheckMemory(g, initid, args, 2, false, false, true)) { - JTYP type; + JTYP type = TYPE_JAR; BJNX bnx(g); PBVAL jvp = NULL, top = NULL; PBVAL jsp[2] = {NULL, NULL}; From cc08872c16004a95f8a705e1d47c500f83e3152c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 28 Sep 2021 22:29:23 +0300 Subject: [PATCH 03/12] Initialize the Hash_set during creation If the Hash_set is not initialized, one can not call find() on it before at least one element has been inserted into it. --- sql/sql_hset.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sql/sql_hset.h b/sql/sql_hset.h index b3d8165f6f6..065a3181bec 100644 --- a/sql/sql_hset.h +++ b/sql/sql_hset.h @@ -28,17 +28,15 @@ class Hash_set public: enum { START_SIZE= 8 }; /** - Constructs an empty hash. Does not allocate memory, it is done upon - the first insert. Thus does not cause or return errors. + Constructs an empty unique hash. */ Hash_set(PSI_memory_key psi_key, uchar *(*K)(const T *, size_t *, my_bool), CHARSET_INFO *cs= &my_charset_bin) { - my_hash_clear(&m_hash); - m_hash.get_key= (my_hash_get_key)K; - m_hash.charset= cs; - m_hash.array.m_psi_key= psi_key; + my_hash_init(psi_key, &m_hash, cs, START_SIZE, 0, 0, (my_hash_get_key)K, 0, + HASH_UNIQUE); } + Hash_set(PSI_memory_key psi_key, CHARSET_INFO *charset, ulong default_array_elements, size_t key_offset, size_t key_length, my_hash_get_key get_key, void (*free_element)(void*), uint flags) @@ -65,8 +63,6 @@ public: */ bool insert(T *value) { - my_hash_init_opt(m_hash.array.m_psi_key, &m_hash, m_hash.charset, - START_SIZE, 0, 0, m_hash.get_key, 0, HASH_UNIQUE); return my_hash_insert(&m_hash, reinterpret_cast(value)); } bool remove(T *value) From 8885225de66906dc424be8f6ffc4d1b68e54ebca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 28 Sep 2021 22:17:59 +0300 Subject: [PATCH 04/12] Implement multiple-signal debug_sync The patch is inspired from MySQL. Instead of using a single String to hold the current active debug_sync signal, use a Hash_set to store LEX_STRINGS. This patch ensures that a signal can not be lost, by being overwritten by another thread via set DEBUG_SYNC = '... SIGNAL ...'; All signals are kepts "alive" until they are consumed by a wait event. This requires updating test cases that assume the GLOBAL signal is never consumed. Follow-up work needed: Port the additional syntax that allows one to set multiple signals and also conditionally deactivate signals when waiting. --- mysql-test/main/debug_sync.result | 39 +++-- mysql-test/main/debug_sync.test | 12 +- mysql-test/suite/innodb/r/mdev-14846.result | 3 +- mysql-test/suite/innodb/t/mdev-14846.test | 3 +- .../suite/sys_vars/r/debug_sync_basic.result | 6 +- .../suite/sys_vars/r/sysvars_debug.result | 2 +- sql/debug_sync.cc | 145 +++++++++++++++--- 7 files changed, 162 insertions(+), 48 deletions(-) diff --git a/mysql-test/main/debug_sync.result b/mysql-test/main/debug_sync.result index bb9ae1a417d..45cdc40e241 100644 --- a/mysql-test/main/debug_sync.result +++ b/mysql-test/main/debug_sync.result @@ -2,7 +2,7 @@ SET DEBUG_SYNC= 'RESET'; DROP TABLE IF EXISTS t1; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: '' +debug_sync ON - current signals: '' SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2 HIT_LIMIT 3'; SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 EXECUTE 2'; SET DEBUG_SYNC='p0 SIGNAL s1 WAIT_FOR s2 TIMEOUT 6 HIT_LIMIT 3'; @@ -150,34 +150,34 @@ SET @myvar= 'now SIGNAL from_myvar'; SET DEBUG_SYNC= @myvar; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 'from_myvar' +debug_sync ON - current signals: 'from_myvar' SET DEBUG_SYNC= LEFT('now SIGNAL from_function_cut_here', 24); SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 'from_function' +debug_sync ON - current signals: 'from_myvar,from_function' SET DEBUG_SYNC= 'now SIGNAL something'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 'something' +debug_sync ON - current signals: 'something,from_function,from_myvar' SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0'; Warnings: Warning #### debug sync point wait timed out SET DEBUG_SYNC= 'now SIGNAL nothing'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 'nothing' +debug_sync ON - current signals: 'something,from_function,nothing,from_myvar' SET DEBUG_SYNC= 'now WAIT_FOR nothing TIMEOUT 0'; SET DEBUG_SYNC= 'now SIGNAL something EXECUTE 0'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 'nothing' +debug_sync ON - current signals: 'something,from_function,from_myvar' SET DEBUG_SYNC= 'now WAIT_FOR anotherthing TIMEOUT 0 EXECUTE 0'; SET DEBUG_SYNC= 'now HIT_LIMIT 1'; ERROR HY000: debug sync point hit limit reached SET DEBUG_SYNC= 'RESET'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: '' +debug_sync ON - current signals: '' SET DEBUG_SYNC= 'p1abcd SIGNAL s1 EXECUTE 2'; SET DEBUG_SYNC= 'p2abc SIGNAL s2 EXECUTE 2'; SET DEBUG_SYNC= 'p9abcdef SIGNAL s9 EXECUTE 2'; @@ -190,23 +190,30 @@ SET DEBUG_SYNC= 'p3abcdef SIGNAL s3 EXECUTE 2'; SET DEBUG_SYNC= 'p4a TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's4' +debug_sync ON - current signals: 's4' SET DEBUG_SYNC= 'p1abcd TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's1' +debug_sync ON - current signals: 's4,s1' SET DEBUG_SYNC= 'p7 TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's7' +debug_sync ON - current signals: 's1,s7,s4' SET DEBUG_SYNC= 'p9abcdef TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's9' +debug_sync ON - current signals: 's1,s7,s4,s9' SET DEBUG_SYNC= 'p3abcdef TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's3' +debug_sync ON - current signals: 's1,s3,s4,s9,s7' +SET DEBUG_SYNC= 'now WAIT_FOR s9'; +SET DEBUG_SYNC= 'now WAIT_FOR s1'; +SET DEBUG_SYNC= 'now WAIT_FOR s4'; +SET DEBUG_SYNC= 'now WAIT_FOR s7'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +Variable_name Value +debug_sync ON - current signals: 's3' SET DEBUG_SYNC= 'p1abcd CLEAR'; SET DEBUG_SYNC= 'p2abc CLEAR'; SET DEBUG_SYNC= 'p5abcde CLEAR'; @@ -219,19 +226,19 @@ SET DEBUG_SYNC= 'p7 CLEAR'; SET DEBUG_SYNC= 'p1abcd TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's3' +debug_sync ON - current signals: 's3' SET DEBUG_SYNC= 'p7 TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's3' +debug_sync ON - current signals: 's3' SET DEBUG_SYNC= 'p9abcdef TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: 's3' +debug_sync ON - current signals: 's3' SET DEBUG_SYNC= 'RESET'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value -debug_sync ON - current signal: '' +debug_sync ON - current signals: '' CREATE USER mysqltest_1@localhost; GRANT SUPER ON *.* TO mysqltest_1@localhost; connect con1,localhost,mysqltest_1,,; diff --git a/mysql-test/main/debug_sync.test b/mysql-test/main/debug_sync.test index 89414939f59..0e57071e08a 100644 --- a/mysql-test/main/debug_sync.test +++ b/mysql-test/main/debug_sync.test @@ -298,6 +298,16 @@ SET DEBUG_SYNC= 'p9abcdef TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; SET DEBUG_SYNC= 'p3abcdef TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; + +# +# Wait for all signals currently active except s3. +# +SET DEBUG_SYNC= 'now WAIT_FOR s9'; +SET DEBUG_SYNC= 'now WAIT_FOR s1'; +SET DEBUG_SYNC= 'now WAIT_FOR s4'; +SET DEBUG_SYNC= 'now WAIT_FOR s7'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; + # # Clear the actions. # @@ -320,7 +330,7 @@ SHOW VARIABLES LIKE 'DEBUG_SYNC'; SET DEBUG_SYNC= 'p9abcdef TEST'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; # -# Now cleanup. Actions are clear already, but signal needs to be cleared. +# Now cleanup. Actions are clear already, but s3 signal needs to be cleared. # SET DEBUG_SYNC= 'RESET'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; diff --git a/mysql-test/suite/innodb/r/mdev-14846.result b/mysql-test/suite/innodb/r/mdev-14846.result index 219bd718feb..a1ccfb6bb4d 100644 --- a/mysql-test/suite/innodb/r/mdev-14846.result +++ b/mysql-test/suite/innodb/r/mdev-14846.result @@ -31,11 +31,12 @@ pk f1 f2 f3 3 t q 1 5 z t NULL SET DEBUG_SYNC='now SIGNAL default_dml'; +SET DEBUG_SYNC='now SIGNAL con2_dml'; connection default; SET DEBUG_SYNC='now WAIT_FOR default_dml'; UPDATE t3 AS alias1 LEFT JOIN t3 AS alias2 ON ( alias1.f1 <> alias1.f2 ) SET alias1.f3 = 59 WHERE ( EXISTS ( SELECT t1.f3 FROM t1 WHERE t1.f1 = alias1.f1 ) ) OR alias2.f1 = 'h'; connect con2,localhost,root,,test; -set debug_sync='now WAIT_FOR default_dml'; +set debug_sync='now WAIT_FOR con2_dml'; SET DEBUG_SYNC='now SIGNAL con1_dml2'; disconnect con2; connection con1; diff --git a/mysql-test/suite/innodb/t/mdev-14846.test b/mysql-test/suite/innodb/t/mdev-14846.test index adcefecd52f..b1f32302591 100644 --- a/mysql-test/suite/innodb/t/mdev-14846.test +++ b/mysql-test/suite/innodb/t/mdev-14846.test @@ -35,6 +35,7 @@ SET DEBUG_SYNC='now WAIT_FOR con1_dml'; begin; SELECT * FROM t1 for update; # Holds x lock of all records in the table t1 SET DEBUG_SYNC='now SIGNAL default_dml'; +SET DEBUG_SYNC='now SIGNAL con2_dml'; --connection default SET DEBUG_SYNC='now WAIT_FOR default_dml'; @@ -42,7 +43,7 @@ SET DEBUG_SYNC='now WAIT_FOR default_dml'; # It holds the lock of all record in t3 and tries to acquire record lock for the table t1. --connect (con2,localhost,root,,test) -set debug_sync='now WAIT_FOR default_dml'; +set debug_sync='now WAIT_FOR con2_dml'; let $wait_condition= select count(*) > 0 from information_schema.innodb_lock_waits; --source include/wait_condition.inc diff --git a/mysql-test/suite/sys_vars/r/debug_sync_basic.result b/mysql-test/suite/sys_vars/r/debug_sync_basic.result index 6ebb46dd662..11506cac2c2 100644 --- a/mysql-test/suite/sys_vars/r/debug_sync_basic.result +++ b/mysql-test/suite/sys_vars/r/debug_sync_basic.result @@ -2,17 +2,17 @@ select @@global.debug_sync; ERROR HY000: Variable 'debug_sync' is a SESSION variable select @@session.debug_sync; @@session.debug_sync -ON - current signal: '' +ON - current signals: '' show global variables like "debug_sync"; Variable_name Value show session variables like "debug_sync"; Variable_name Value -debug_sync ON - current signal: '' +debug_sync ON - current signals: '' select * from information_schema.global_variables where variable_name="debug_sync"; VARIABLE_NAME VARIABLE_VALUE select * from information_schema.session_variables where variable_name="debug_sync"; VARIABLE_NAME VARIABLE_VALUE -DEBUG_SYNC ON - current signal: '' +DEBUG_SYNC ON - current signals: '' set @@session.debug_sync=1; ERROR 42000: Incorrect argument type to variable 'debug_sync' set @@session.debug_sync=1.1; diff --git a/mysql-test/suite/sys_vars/r/sysvars_debug.result b/mysql-test/suite/sys_vars/r/sysvars_debug.result index 0d77b0211a1..fc04ac83210 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_debug.result +++ b/mysql-test/suite/sys_vars/r/sysvars_debug.result @@ -77,7 +77,7 @@ READ_ONLY YES COMMAND_LINE_ARGUMENT OPTIONAL GLOBAL_VALUE_PATH NULL VARIABLE_NAME DEBUG_SYNC -SESSION_VALUE ON - current signal: '' +SESSION_VALUE ON - current signals: '' GLOBAL_VALUE NULL GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 55523a728f8..6c847dc9927 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -67,21 +67,99 @@ struct st_debug_sync_control }; + + /** Definitions for the debug sync facility. - 1. Global string variable to hold a "signal" ("signal post", "flag mast"). + 1. Global string variable to hold a set of of "signals". 2. Global condition variable for signaling and waiting. 3. Global mutex to synchronize access to the above. */ struct st_debug_sync_globals { - String ds_signal; /* signal variable */ + Hash_set ds_signal_set; /* A set of active signals */ mysql_cond_t ds_cond; /* condition variable */ mysql_mutex_t ds_mutex; /* mutex variable */ ulonglong dsp_hits; /* statistics */ ulonglong dsp_executed; /* statistics */ ulonglong dsp_max_active; /* statistics */ + + st_debug_sync_globals() : ds_signal_set(PSI_NOT_INSTRUMENTED, signal_key) {}; + ~st_debug_sync_globals() + { + clear_set(); + } + + void clear_set() + { + Hash_set::Iterator it{ds_signal_set}; + LEX_CSTRING *s; + while ((s= it++)) + my_free(s); + ds_signal_set.clear(); + } + + /* Hash key function for ds_signal_set. */ + static uchar *signal_key(const LEX_CSTRING *str, size_t *klen, my_bool) + { + *klen= str->length; + return (uchar*) str->str; + } + + /** + Return true if the signal is found in global signal list. + + @param signal_name Signal name identifying the signal. + + @note + If signal is found in the global signal set, it means that the + signal thread has signalled to the waiting thread. This method + must be called with the debug_sync_global.ds_mutex held. + + @retval true if signal is found in the global signal list. + @retval false otherwise. + */ + + inline bool is_signalled(const String &signal_name) + { + return ds_signal_set.find(signal_name.ptr(), signal_name.length()); + } + + void clear_signal(const String &signal_name) + { + DBUG_ENTER("clear_signal"); + LEX_CSTRING *record= ds_signal_set.find(signal_name.ptr(), + signal_name.length()); + if (record) + { + ds_signal_set.remove(record); + my_free(record); + } + DBUG_VOID_RETURN; + } + + bool set_signal(const String &signal_name) + { + /* Need to check if the signal is already in the hash set, because + Hash_set doesn't differentiate between OOM and key already in. */ + if (is_signalled(signal_name)) + return FALSE; + /* LEX_CSTRING and the string allocated with only one malloc. */ + LEX_CSTRING *s= (LEX_CSTRING *) my_malloc(PSI_NOT_INSTRUMENTED, + sizeof(LEX_CSTRING) + + signal_name.length() + 1, MYF(0)); + char *str= (char *)(s + 1); + memcpy(str, signal_name.ptr(), signal_name.length()); + str[signal_name.length()]= '\0'; + + s->length= signal_name.length(); + s->str= str; + if (ds_signal_set.insert(s)) + return TRUE; + return FALSE; + } }; + static st_debug_sync_globals debug_sync_global; /* All globals in one object */ /** @@ -161,7 +239,7 @@ int debug_sync_init(void) int rc; /* Initialize the global variables. */ - debug_sync_global.ds_signal.length(0); + debug_sync_global.clear_set(); if ((rc= mysql_cond_init(key_debug_sync_globals_ds_cond, &debug_sync_global.ds_cond, NULL)) || (rc= mysql_mutex_init(key_debug_sync_globals_ds_mutex, @@ -195,7 +273,7 @@ void debug_sync_end(void) debug_sync_C_callback_ptr= NULL; /* Destroy the global variables. */ - debug_sync_global.ds_signal.free(); + debug_sync_global.clear_set(); mysql_cond_destroy(&debug_sync_global.ds_cond); mysql_mutex_destroy(&debug_sync_global.ds_mutex); @@ -554,7 +632,7 @@ static void debug_sync_reset(THD *thd) /* Clear the global signal. */ mysql_mutex_lock(&debug_sync_global.ds_mutex); - debug_sync_global.ds_signal.length(0); + debug_sync_global.clear_set(); mysql_mutex_unlock(&debug_sync_global.ds_mutex); DBUG_VOID_RETURN; @@ -1325,13 +1403,19 @@ uchar *debug_sync_value_ptr(THD *thd) if (opt_debug_sync_timeout) { - static char on[]= "ON - current signal: '"; + static char on[]= "ON - current signals: '"; // Ensure exclusive access to debug_sync_global.ds_signal mysql_mutex_lock(&debug_sync_global.ds_mutex); - size_t lgt= (sizeof(on) /* includes '\0' */ + - debug_sync_global.ds_signal.length() + 1 /* for '\'' */); + size_t lgt= sizeof(on) + 1; /* +1 as we'll have to append ' at the end. */ + + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + { + /* Assume each signal is separated by a comma, hence +1. */ + lgt+= debug_sync_global.ds_signal_set.at(i)->length + 1; + } + char *vend; char *vptr; @@ -1339,10 +1423,15 @@ uchar *debug_sync_value_ptr(THD *thd) { vend= value + lgt - 1; /* reserve space for '\0'. */ vptr= debug_sync_bmove_len(value, vend, STRING_WITH_LEN(on)); - vptr= debug_sync_bmove_len(vptr, vend, debug_sync_global.ds_signal.ptr(), - debug_sync_global.ds_signal.length()); - if (vptr < vend) - *(vptr++)= '\''; + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + { + const LEX_CSTRING *s= debug_sync_global.ds_signal_set.at(i); + vptr= debug_sync_bmove_len(vptr, vend, s->str, s->length); + if (i != debug_sync_global.ds_signal_set.size() - 1) + *(vptr++)= ','; + } + DBUG_ASSERT(vptr < vend); + *(vptr++)= '\''; *vptr= '\0'; /* We have one byte reserved for the worst case. */ } mysql_mutex_unlock(&debug_sync_global.ds_mutex); @@ -1358,6 +1447,9 @@ uchar *debug_sync_value_ptr(THD *thd) } + + + /** Execute requested action at a synchronization point. @@ -1413,12 +1505,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) read access too, to create a memory barrier in order to avoid that threads just reads an old cached version of the signal. */ + mysql_mutex_lock(&debug_sync_global.ds_mutex); if (action->signal.length()) { - /* Copy the signal to the global variable. */ - if (debug_sync_global.ds_signal.copy(action->signal)) + if (debug_sync_global.set_signal(action->signal)) { /* Error is reported by my_malloc(). @@ -1461,12 +1553,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) restore_current_mutex = false; set_timespec(abstime, action->timeout); - DBUG_EXECUTE("debug_sync_exec", + // TODO turn this into a for loop printing. + DBUG_EXECUTE("debug_sync_exec", { /* Functions as DBUG_PRINT args can change keyword and line nr. */ DBUG_PRINT("debug_sync_exec", - ("wait for '%s' at: '%s' curr: '%s'", - sig_wait, dsp_name, - debug_sync_global.ds_signal.c_ptr()));); + ("wait for '%s' at: '%s'", + sig_wait, dsp_name));}); /* Wait until global signal string matches the wait_for string. @@ -1474,18 +1566,19 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) The facility can become disabled when some thread cannot get the required dynamic memory allocated. */ - while (stringcmp(&debug_sync_global.ds_signal, &action->wait_for) && - !(thd->killed & KILL_HARD_BIT) && opt_debug_sync_timeout) + while (!debug_sync_global.is_signalled(action->wait_for) && + !(thd->killed & KILL_HARD_BIT)&& + opt_debug_sync_timeout) { error= mysql_cond_timedwait(&debug_sync_global.ds_cond, &debug_sync_global.ds_mutex, &abstime); - DBUG_EXECUTE("debug_sync", + // TODO turn this into a for loop printing. + DBUG_EXECUTE("debug_sync", { /* Functions as DBUG_PRINT args can change keyword and line nr. */ DBUG_PRINT("debug_sync", - ("awoke from %s global: %s error: %d", - sig_wait, debug_sync_global.ds_signal.c_ptr(), - error));); + ("awoke from %s error: %d", + sig_wait, error));}); if (unlikely(error == ETIMEDOUT || error == ETIME)) { // We should not make the statement fail, even if in strict mode. @@ -1498,6 +1591,8 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) } error= 0; } + // TODO conditional on clear-event + debug_sync_global.clear_signal(action->wait_for); DBUG_EXECUTE("debug_sync_exec", if (thd->killed) DBUG_PRINT("debug_sync_exec", @@ -1571,10 +1666,10 @@ static void debug_sync(THD *thd, const char *sync_point_name, size_t name_len) st_debug_sync_control *ds_control= thd->debug_sync_control; st_debug_sync_action *action; DBUG_ENTER("debug_sync"); + DBUG_PRINT("debug_sync_point", ("hit: '%s'", sync_point_name)); DBUG_ASSERT(sync_point_name); DBUG_ASSERT(name_len); DBUG_ASSERT(ds_control); - DBUG_PRINT("debug_sync_point", ("hit: '%s'", sync_point_name)); /* Statistics. */ ds_control->dsp_hits++; From cd873c8688a6f21b3c859068d3146e9fd90120b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Wed, 29 Sep 2021 11:24:05 +0300 Subject: [PATCH 05/12] debug_sync: Implement NO_CLEAR_EVENT syntax When waiting on a signal, NO_CLEAR_EVENT allows one to not clear the signal, effectively allowing other threads to wait for the same signal. --- mysql-test/main/debug_sync.result | 16 ++++++++++++++++ mysql-test/main/debug_sync.test | 11 +++++++++++ sql/debug_sync.cc | 18 ++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/debug_sync.result b/mysql-test/main/debug_sync.result index 45cdc40e241..9b6699f9bc2 100644 --- a/mysql-test/main/debug_sync.result +++ b/mysql-test/main/debug_sync.result @@ -299,4 +299,20 @@ disconnect con1; disconnect con2; connection default; DROP TABLE t1; +# +# Test NO_CLEAR_EVENT flag. The signal should still be visible after +# the wait has completed succesfully. +# +SET DEBUG_SYNC= 'now SIGNAL s1'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +Variable_name Value +debug_sync ON - current signals: 's1' +SET DEBUG_SYNC= 'now WAIT_FOR s1 NO_CLEAR_EVENT'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +Variable_name Value +debug_sync ON - current signals: 's1' +SET DEBUG_SYNC= 'now WAIT_FOR s1'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +Variable_name Value +debug_sync ON - current signals: '' SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/main/debug_sync.test b/mysql-test/main/debug_sync.test index 0e57071e08a..0ea637a393a 100644 --- a/mysql-test/main/debug_sync.test +++ b/mysql-test/main/debug_sync.test @@ -428,6 +428,17 @@ disconnect con2; connection default; DROP TABLE t1; +--echo # +--echo # Test NO_CLEAR_EVENT flag. The signal should still be visible after +--echo # the wait has completed succesfully. +--echo # +SET DEBUG_SYNC= 'now SIGNAL s1'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'now WAIT_FOR s1 NO_CLEAR_EVENT'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'now WAIT_FOR s1'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; + # # Cleanup after test case. # Otherwise signal would contain 'flushed' here, diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 6c847dc9927..cdbeed1244f 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -48,6 +48,8 @@ struct st_debug_sync_action String wait_for; /* signal to wait for */ String sync_point; /* sync point name */ bool need_sort; /* if new action, array needs sort */ + bool clear_event; /* do not clear signal when waited + for if false. */ }; /* Debug sync control. Referenced by THD. */ @@ -1253,6 +1255,7 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end) /* Set default for EXECUTE and TIMEOUT options. */ action->execute= 1; action->timeout= opt_debug_sync_timeout; + action->clear_event= true; /* Get next token. If none follows, set action. */ if (!(ptr= debug_sync_token(&token, &token_length, ptr, action_end))) @@ -1303,6 +1306,15 @@ static bool debug_sync_eval_action(THD *thd, char *action_str, char *action_end) goto set_action; } + /* + Try NO_CLEAR_EVENT. + */ + if (!my_strcasecmp(system_charset_info, token, "NO_CLEAR_EVENT")) { + action->clear_event= false; + /* Get next token. If none follows, set action. */ + if (!(ptr = debug_sync_token(&token, &token_length, ptr, action_end))) goto set_action; + } + /* Try HIT_LIMIT. */ @@ -1591,8 +1603,10 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) } error= 0; } - // TODO conditional on clear-event - debug_sync_global.clear_signal(action->wait_for); + + if (action->clear_event) + debug_sync_global.clear_signal(action->wait_for); + DBUG_EXECUTE("debug_sync_exec", if (thd->killed) DBUG_PRINT("debug_sync_exec", From c115559b66f115b424fd1322db776d3815319f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Wed, 29 Sep 2021 14:04:31 +0300 Subject: [PATCH 06/12] Extend Binary_string::strstr to also take in a const char pointer One shouldn't have to instantiate a Binary_string every time a strstr call is needed. --- sql/sql_string.cc | 28 ++++++++++++++++------------ sql/sql_string.h | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/sql/sql_string.cc b/sql/sql_string.cc index fbc97ab54fb..d4639fb6bc4 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -677,33 +677,37 @@ bool String::append_with_prefill(const char *s,uint32 arg_length, } -int Binary_string::strstr(const Binary_string &s, uint32 offset) +int Binary_string::strstr(const char *search, uint32 search_length, uint32 offset) { - if (s.length()+offset <= str_length) + if (search_length + offset <= str_length) { - if (!s.length()) + if (!search_length) return ((int) offset); // Empty string is always found - const char *str = Ptr+offset; - const char *search=s.ptr(); - const char *end=Ptr+str_length-s.length()+1; - const char *search_end=s.ptr()+s.length(); + const char *str= Ptr + offset; + const char *end= Ptr + str_length - search_length + 1; + const char *search_end= search + search_length; skip: while (str != end) { if (*str++ == *search) { - char *i,*j; - i=(char*) str; j=(char*) search+1; - while (j != search_end) - if (*i++ != *j++) goto skip; - return (int) (str-Ptr) -1; + char *i= (char*) str; + char *j= (char*) search + 1 ; + while (j != search_end) + if (*i++ != *j++) goto skip; + return (int) (str-Ptr) -1; } } } return -1; } +int Binary_string::strstr(const Binary_string &s, uint32 offset) +{ + return strstr(s.ptr(), s.length(), offset); +} + /* ** Search string from end. Offset is offset to the end of string */ diff --git a/sql/sql_string.h b/sql/sql_string.h index b1f02bdb43b..7bf0e2d2518 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -330,6 +330,7 @@ public: // Returns offset to substring or -1 int strstr(const Binary_string &search, uint32 offset=0); + int strstr(const char *search, uint32 search_length, uint32 offset=0); // Returns offset to substring or -1 int strrstr(const Binary_string &search, uint32 offset=0); From 8ff0a7f893a71843967465f7d9ceafd8ae13f2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Wed, 29 Sep 2021 14:10:56 +0300 Subject: [PATCH 07/12] Implement DEBUG_SYNC multiple signal firing capability One can now do: set DEBUG_SYNC='... SIGNAL s1,s2,s3...' Multiple signals can be fired, they need to be split by commas. --- mysql-test/main/debug_sync.result | 4 +++ mysql-test/main/debug_sync.test | 7 ++++-- sql/debug_sync.cc | 41 ++++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/mysql-test/main/debug_sync.result b/mysql-test/main/debug_sync.result index 9b6699f9bc2..4c1711a6d6b 100644 --- a/mysql-test/main/debug_sync.result +++ b/mysql-test/main/debug_sync.result @@ -315,4 +315,8 @@ SET DEBUG_SYNC= 'now WAIT_FOR s1'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; Variable_name Value debug_sync ON - current signals: '' +SET DEBUG_SYNC= 'now SIGNAL s1,s2,s5,s7'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; +Variable_name Value +debug_sync ON - current signals: 's2,s7,s1,s5' SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/main/debug_sync.test b/mysql-test/main/debug_sync.test index 0ea637a393a..1dc3dc9c71e 100644 --- a/mysql-test/main/debug_sync.test +++ b/mysql-test/main/debug_sync.test @@ -439,10 +439,13 @@ SHOW VARIABLES LIKE 'DEBUG_SYNC'; SET DEBUG_SYNC= 'now WAIT_FOR s1'; SHOW VARIABLES LIKE 'DEBUG_SYNC'; +SET DEBUG_SYNC= 'now SIGNAL s1,s2,s5,s7'; +SHOW VARIABLES LIKE 'DEBUG_SYNC'; + + # # Cleanup after test case. -# Otherwise signal would contain 'flushed' here, -# which could confuse the next test. +# Otherwise signal would confuse the next test. # SET DEBUG_SYNC= 'RESET'; diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index cdbeed1244f..b7090efa01b 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -122,9 +122,9 @@ struct st_debug_sync_globals @retval false otherwise. */ - inline bool is_signalled(const String &signal_name) + inline bool is_signalled(const char *signal_name, size_t length) { - return ds_signal_set.find(signal_name.ptr(), signal_name.length()); + return ds_signal_set.find(signal_name, length); } void clear_signal(const String &signal_name) @@ -140,21 +140,21 @@ struct st_debug_sync_globals DBUG_VOID_RETURN; } - bool set_signal(const String &signal_name) + bool set_signal(const char *signal_name, size_t length) { /* Need to check if the signal is already in the hash set, because Hash_set doesn't differentiate between OOM and key already in. */ - if (is_signalled(signal_name)) + if (is_signalled(signal_name, length)) return FALSE; /* LEX_CSTRING and the string allocated with only one malloc. */ LEX_CSTRING *s= (LEX_CSTRING *) my_malloc(PSI_NOT_INSTRUMENTED, - sizeof(LEX_CSTRING) + - signal_name.length() + 1, MYF(0)); + sizeof(LEX_CSTRING) + length + 1, + MYF(0)); char *str= (char *)(s + 1); - memcpy(str, signal_name.ptr(), signal_name.length()); - str[signal_name.length()]= '\0'; + memcpy(str, signal_name, length); + str[length]= '\0'; - s->length= signal_name.length(); + s->length= length; s->str= str; if (ds_signal_set.insert(s)) return TRUE; @@ -1522,7 +1522,23 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) if (action->signal.length()) { - if (debug_sync_global.set_signal(action->signal)) + int offset= 0, pos; + bool error= false; + + /* This loop covers all signals in the list except for the last one. + Split the signal string by commas and set a signal in the global + variable for each one. */ + while (!error && (pos= action->signal.strstr(",", 1, offset)) > 0) + { + error= debug_sync_global.set_signal(action->signal.ptr() + offset, + pos - offset); + offset= pos + 1; + } + + if (error || + /* The last signal in the list. */ + debug_sync_global.set_signal(action->signal.ptr() + offset, + action->signal.length() - offset)) { /* Error is reported by my_malloc(). @@ -1578,8 +1594,9 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) The facility can become disabled when some thread cannot get the required dynamic memory allocated. */ - while (!debug_sync_global.is_signalled(action->wait_for) && - !(thd->killed & KILL_HARD_BIT)&& + while (!debug_sync_global.is_signalled(action->wait_for.ptr(), + action->wait_for.length()) && + !(thd->killed & KILL_HARD_BIT) && opt_debug_sync_timeout) { error= mysql_cond_timedwait(&debug_sync_global.ds_cond, From addcf08d0f429640b6b23ee73e9b80e902c82704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 3 Feb 2023 14:13:30 +0200 Subject: [PATCH 08/12] Revert test changes from "Fixed debug_sync timeout in deadlock_drop_table" After introducing multiple signals possible for debug_sync, the test changes are no longer necessary. Revert them to the original state. --- mysql-test/suite/stress/r/deadlock_drop_table.result | 3 ++- mysql-test/suite/stress/t/deadlock_drop_table.test | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/stress/r/deadlock_drop_table.result b/mysql-test/suite/stress/r/deadlock_drop_table.result index 326f694e8d9..7e549157c81 100644 --- a/mysql-test/suite/stress/r/deadlock_drop_table.result +++ b/mysql-test/suite/stress/r/deadlock_drop_table.result @@ -19,11 +19,12 @@ a b c 1 NULL NULL set debug_sync='now SIGNAL go'; set debug_sync='now WAIT_FOR parked2'; -set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go2'; +set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go3'; drop table t1;; connection con2; set debug_sync='now WAIT_FOR waiting'; set debug_sync='now SIGNAL go2'; +set debug_sync='now SIGNAL go3'; connection default; connection con1; connection default; diff --git a/mysql-test/suite/stress/t/deadlock_drop_table.test b/mysql-test/suite/stress/t/deadlock_drop_table.test index 0ec19f87389..b4f8f2201e0 100644 --- a/mysql-test/suite/stress/t/deadlock_drop_table.test +++ b/mysql-test/suite/stress/t/deadlock_drop_table.test @@ -20,15 +20,12 @@ set debug_sync='now WAIT_FOR parked'; select * from t1; set debug_sync='now SIGNAL go'; set debug_sync='now WAIT_FOR parked2'; -set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go2'; +set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go3'; --send drop table t1; --connection con2 set debug_sync='now WAIT_FOR waiting'; set debug_sync='now SIGNAL go2'; - -# Write out show processlist if the debug sync point times out -let $wait_condition= select count(*)=0 from information_schema.processlist where state like "%debug%"; -source include/wait_condition.inc; +set debug_sync='now SIGNAL go3'; --connection default --reap From 2a08b2c15c22fe1019aea00ba160f5ca7e56e231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 3 Feb 2023 14:18:32 +0200 Subject: [PATCH 09/12] sql_hset.h - include what you use uchar comes from my_global.h --- sql/sql_hset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_hset.h b/sql/sql_hset.h index 065a3181bec..c9ffc8a560b 100644 --- a/sql/sql_hset.h +++ b/sql/sql_hset.h @@ -15,6 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ +#include "my_global.h" #include "hash.h" @@ -39,7 +40,7 @@ public: Hash_set(PSI_memory_key psi_key, CHARSET_INFO *charset, ulong default_array_elements, size_t key_offset, size_t key_length, my_hash_get_key get_key, - void (*free_element)(void*), uint flags) + void (*free_element)(void*),uint flags) { my_hash_init(psi_key, &m_hash, charset, default_array_elements, key_offset, key_length, get_key, free_element, flags); From 9f16d153579eb30639b5f7e8a827d65f44475979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 3 Feb 2023 15:00:49 +0200 Subject: [PATCH 10/12] debug_sync: Print all current active signals within the trace file during wait When running with DBUG trace enabled, print all current active signals. The output looks like this with the signals present in curr: T@6 ... debug_sync_exec: wait for 'nothing' at: 'now', curr: 'something,from_function,from_myvar' --- sql/debug_sync.cc | 55 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index b7090efa01b..aa6956060b4 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -18,6 +18,7 @@ #include "mariadb.h" #include "debug_sync.h" +#include #if defined(ENABLED_DEBUG_SYNC) @@ -351,6 +352,40 @@ void debug_sync_init_thread(THD *thd) } +/** + Returns an allocated buffer containing a comma-separated C string of all + active signals. + + Buffer must be freed by the caller. +*/ +static const char *get_signal_set_as_string() +{ + mysql_mutex_assert_owner(&debug_sync_global.ds_mutex); + size_t req_size= 1; // In case of empty set for the end '\0' char. + + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + req_size+= debug_sync_global.ds_signal_set.at(i)->length + 1; + + char *buf= (char *) my_malloc(PSI_NOT_INSTRUMENTED, req_size, MYF(0)); + if (!buf) + return nullptr; + memset(buf, '\0', req_size); + + char *cur_pos= buf; + for (size_t i= 0; i < debug_sync_global.ds_signal_set.size(); i++) + { + const LEX_CSTRING *signal= debug_sync_global.ds_signal_set.at(i); + memcpy(cur_pos, signal->str, signal->length); + if (i != debug_sync_global.ds_signal_set.size() - 1) + cur_pos[signal->length]= ','; + else + cur_pos[signal->length] = '\0'; + cur_pos+= signal->length + 1; + } + return buf; +} + + /** End the debug sync facility at thread end. @@ -1581,12 +1616,22 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) restore_current_mutex = false; set_timespec(abstime, action->timeout); - // TODO turn this into a for loop printing. DBUG_EXECUTE("debug_sync_exec", { - /* Functions as DBUG_PRINT args can change keyword and line nr. */ - DBUG_PRINT("debug_sync_exec", - ("wait for '%s' at: '%s'", - sig_wait, dsp_name));}); + const char *signal_set= get_signal_set_as_string(); + if (!signal_set) + { + DBUG_PRINT("debug_sync_exec", + ("Out of memory when fetching signal set")); + } + else + { + /* Functions as DBUG_PRINT args can change keyword and line nr. */ + DBUG_PRINT("debug_sync_exec", + ("wait for '%s' at: '%s', curr: '%s'", + sig_wait, dsp_name, signal_set)); + my_free((void *)signal_set); + }}); + /* Wait until global signal string matches the wait_for string. From 29b4bd4ea9d1b7cd6a241c83ff0daf7856107c55 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 6 Feb 2023 19:16:15 +1100 Subject: [PATCH 11/12] MDEV-30573 Server doesn't build with GCOV by GCC 11+ __gcov_flush was never an external symbol in the documentation. It was removed in gcc-11. The correct function to use is __gcov_dump which is defined in the gcov.h header. --- dbug/dbug.c | 6 +++--- mysys/stacktrace.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index a6d893e3f49..30b92b22dd0 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -86,7 +86,7 @@ #include #include #ifdef HAVE_gcov -extern void __gcov_flush(); +#include #endif #ifndef DBUG_OFF @@ -2212,7 +2212,7 @@ void _db_suicide_() fprintf(stderr, "SIGKILL myself\n"); fflush(stderr); #ifdef HAVE_gcov - __gcov_flush(); + __gcov_dump(); #endif retval= kill(getpid(), SIGKILL); @@ -2262,7 +2262,7 @@ my_bool _db_my_assert(const char *file, int line, const char *msg) fprintf(stderr, "%s:%d: assert: %s\n", file, line, msg); fflush(stderr); #ifdef HAVE_gcov - __gcov_flush(); + __gcov_dump(); #endif } return a; diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 844d8a0b28f..f203bba4d8d 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -34,6 +34,9 @@ #include #endif +#ifdef HAVE_gcov +#include +#endif /** Default handler for printing stacktrace */ @@ -409,9 +412,6 @@ end: /* Produce a core for the thread */ void my_write_core(int sig) { -#ifdef HAVE_gcov - extern void __gcov_flush(void); -#endif signal(sig, SIG_DFL); #ifdef HAVE_gcov /* @@ -419,7 +419,7 @@ void my_write_core(int sig) information from this process, causing gcov output to be incomplete. So we force the writing of coverage information here before terminating. */ - __gcov_flush(); + __gcov_dump(); #endif pthread_kill(pthread_self(), sig); #if defined(P_MYID) && !defined(SCO) From 80ae69c8bc948382920b083ba203369e941cc90e Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Mon, 6 Feb 2023 10:24:21 -0500 Subject: [PATCH 12/12] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0acffd643c8..017d7bd5ba5 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=6 -MYSQL_VERSION_PATCH=12 +MYSQL_VERSION_PATCH=13 SERVER_MATURITY=stable