From be5698265a4195586142d1a34fdd1cce9d95d8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 27 Jun 2018 12:37:21 +0300 Subject: MDEV-15607: mysqld crashed few after node is being joined with sst This is a typical systemd response where it tries to shutdown the joiner (due to "timeout") before the joiner manages to complete SST. wsrep_sst_wait wsrep_SE_init_wait While waiting the operation to finish use mysql_cond_timedwait instead of mysql_cond_wait and if operation is not finished extend systemd timeout (if needed). --- sql/wsrep_sst.cc | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 4df969496bc..60683bf740c 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -30,6 +30,10 @@ #include #include +#if MYSQL_VERSION_ID < 100200 +# include +#endif + static char wsrep_defaults_file[FN_REFLEN * 2 + 10 + 30 + sizeof(WSREP_SST_OPT_CONF) + sizeof(WSREP_SST_OPT_CONF_SUFFIX) + @@ -186,6 +190,9 @@ bool wsrep_before_SE() static bool sst_complete = false; static bool sst_needed = false; +#define WSREP_EXTEND_TIMEOUT_INTERVAL 30 +#define WSREP_TIMEDWAIT_SECONDS 10 + void wsrep_sst_grab () { WSREP_INFO("wsrep_sst_grab()"); @@ -197,11 +204,25 @@ void wsrep_sst_grab () // Wait for end of SST bool wsrep_sst_wait () { - if (mysql_mutex_lock (&LOCK_wsrep_sst)) abort(); + struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0}; + uint32 total_wtime = 0; + + if (mysql_mutex_lock (&LOCK_wsrep_sst)) + abort(); + + WSREP_INFO("Waiting for SST to complete."); + while (!sst_complete) { - WSREP_INFO("Waiting for SST to complete."); - mysql_cond_wait (&COND_wsrep_sst, &LOCK_wsrep_sst); + mysql_cond_timedwait (&COND_wsrep_sst, &LOCK_wsrep_sst, &wtime); + + if (!sst_complete) + { + total_wtime += wtime.tv_sec; + WSREP_DEBUG("Waiting for SST to complete. waited %u secs.", total_wtime); + service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL, + "WSREP state transfer ongoing, current seqno: %ld", local_seqno); + } } if (local_seqno >= 0) @@ -1298,10 +1319,22 @@ void wsrep_SE_init_grab() void wsrep_SE_init_wait() { + struct timespec wtime = {WSREP_TIMEDWAIT_SECONDS, 0}; + uint32 total_wtime=0; + while (SE_initialized == false) { - mysql_cond_wait (&COND_wsrep_sst_init, &LOCK_wsrep_sst_init); + mysql_cond_timedwait (&COND_wsrep_sst_init, &LOCK_wsrep_sst_init, &wtime); + + if (!SE_initialized) + { + total_wtime += wtime.tv_sec; + WSREP_DEBUG("Waiting for SST to complete. waited %u secs.", total_wtime); + service_manager_extend_timeout(WSREP_EXTEND_TIMEOUT_INTERVAL, + "WSREP SE initialization ongoing."); + } } + mysql_mutex_unlock (&LOCK_wsrep_sst_init); } -- cgit v1.2.1 From bf4244d1a0d921defbd92deb1e54b59ee1ce35b4 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 27 Jun 2018 17:01:09 +0400 Subject: MDEV-8540 - Crash on server shutdown since 10.0.16 Only close stdin if it was open initinally. Otherwise we may close file descriptor which is reused for different puprose (specifically for binlog index file in case of this bug). --- sql/mysqld.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index fb49c05def5..d760986a303 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5149,6 +5149,9 @@ int win_main(int argc, char **argv) int mysqld_main(int argc, char **argv) #endif { + /* We can't close stdin just now, because it may be booststrap mode. */ + bool please_close_stdin= fcntl(STDIN_FILENO, F_GETFD) >= 0; + /* Perform basic thread library and malloc initialization, to be able to read defaults files and parse options. @@ -5492,7 +5495,9 @@ int mysqld_main(int argc, char **argv) (char*) "" : mysqld_unix_port), mysqld_port, MYSQL_COMPILATION_COMMENT); - fclose(stdin); + /* Only close stdin if it was open initinally. */ + if (please_close_stdin) + fclose(stdin); #if defined(_WIN32) && !defined(EMBEDDED_LIBRARY) Service.SetRunning(); #endif -- cgit v1.2.1 From 3d4beee1a98cebd6eb566e38569e19599c2b9a98 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 28 Jun 2018 11:59:25 +0200 Subject: remove double-counting rnd_pos_by_record calls ha_rnd_pos, which does the counting --- sql/sql_class.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index ec94f6c45d2..9428f6f6ce5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5012,8 +5012,6 @@ inline int handler::ha_ft_read(uchar *buf) inline int handler::ha_rnd_pos_by_record(uchar *buf) { int error= rnd_pos_by_record(buf); - if (!error) - update_rows_read(); table->status=error ? STATUS_NOT_FOUND: 0; return error; } -- cgit v1.2.1 From 16c14d7ba05ed3ad6ce1f3a8e0447d6304a7e636 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 21 Jun 2018 09:43:05 +0200 Subject: mark ed25519 stable --- mysql-test/suite/plugins/r/auth_ed25519.result | 2 +- plugin/auth_ed25519/server_ed25519.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/plugins/r/auth_ed25519.result b/mysql-test/suite/plugins/r/auth_ed25519.result index a3b85a11dea..371d20befeb 100644 --- a/mysql-test/suite/plugins/r/auth_ed25519.result +++ b/mysql-test/suite/plugins/r/auth_ed25519.result @@ -32,7 +32,7 @@ PLUGIN_AUTHOR Sergei Golubchik PLUGIN_DESCRIPTION Elliptic curve ED25519 based authentication PLUGIN_LICENSE GPL LOAD_OPTION ON -PLUGIN_MATURITY Beta +PLUGIN_MATURITY Stable PLUGIN_AUTH_VERSION 1.0-alpha create user test1@localhost identified via ed25519 using 'ZIgUREUg5PVgQ6LskhXmO+eZLS0nC8be6HPjYWR4YJY'; show grants for test1@localhost; diff --git a/plugin/auth_ed25519/server_ed25519.c b/plugin/auth_ed25519/server_ed25519.c index ac443b43b09..7720a0a4074 100644 --- a/plugin/auth_ed25519/server_ed25519.c +++ b/plugin/auth_ed25519/server_ed25519.c @@ -102,7 +102,7 @@ maria_declare_plugin(ed25519) NULL, NULL, "1.0-alpha", - MariaDB_PLUGIN_MATURITY_BETA + MariaDB_PLUGIN_MATURITY_STABLE } maria_declare_plugin_end; -- cgit v1.2.1 From 8ca18294d59e4df82dacba69f9853e568ab2e0eb Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Sun, 18 Mar 2018 21:01:41 +0200 Subject: MDEV-14014 Multi-Slave Replication Fail: bogus data in log event MDEV-7257 made a dump thread to read from binlog concurrently with writers as long as the read bytes are below a water-mark (MYSQL_BIN_LOG::binlog_end_pos). However it appeared to be possible a dump thread reader reach out for bytes past the water mark through a feature of IO_CACHE that fills in the internal buffer and while doing so it could read what the reader is not supposed to see (the bytes above MYSQL_BIN_LOG::binlog_end_pos). The issue is fixed with constraining the IO_CACHE buffer fill to respect the watermark. An added unit test proves reading from file is bound to an external parameter passed to {IO_CACHE::end_of_file} cache member. --- sql/sql_repl.cc | 1 + unittest/sql/mf_iocache-t.cc | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 569c3d2c4ef..db608de5147 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -2546,6 +2546,7 @@ static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo, linfo->pos= my_b_tell(log); info->last_pos= my_b_tell(log); + log->end_of_file= end_pos; while (linfo->pos < end_pos) { if (should_stop(info)) diff --git a/unittest/sql/mf_iocache-t.cc b/unittest/sql/mf_iocache-t.cc index 1b04f8eb0d3..2cd5b678700 100644 --- a/unittest/sql/mf_iocache-t.cc +++ b/unittest/sql/mf_iocache-t.cc @@ -253,10 +253,43 @@ void mdev10259() } +void mdev14014() +{ + int res; + uchar buf_o[200]; + uchar buf_i[200]; + memset(buf_i, 0, sizeof( buf_i)); + memset(buf_o, FILL, sizeof(buf_o)); + + diag("MDEV-14014 Dump thread reads past last 'officially' written byte"); + + init_io_cache_encryption(); + + res= open_cached_file(&info, 0, 0, CACHE_SIZE, 0); + ok(res == 0, "open_cached_file" INFO_TAIL); + + res= my_b_write(&info, buf_o, sizeof(buf_o)); + ok(res == 0, "buffer is written" INFO_TAIL); + + res= my_b_flush_io_cache(&info, 1); + ok(res == 0, "flush" INFO_TAIL); + + res= reinit_io_cache(&info, READ_CACHE, 0, 0, 0); + ok(res == 0, "reinit READ_CACHE" INFO_TAIL); + + info.end_of_file= 100; + res= my_b_read(&info, buf_i, sizeof(buf_i)); + ok(res == 1 && buf_i[100] == 0 && buf_i[200-1] == 0, + "short read leaves buf_i[100..200-1] == 0"); + + close_cached_file(&info); +} + + int main(int argc __attribute__((unused)),char *argv[]) { MY_INIT(argv[0]); - plan(46); + plan(51); /* temp files with and without encryption */ encrypt_tmp_files= 1; @@ -272,6 +305,8 @@ int main(int argc __attribute__((unused)),char *argv[]) mdev10259(); encrypt_tmp_files= 0; + mdev14014(); + my_end(0); return exit_status(); } -- cgit v1.2.1 From 45cabf10175da1ae2d158ea17ccd6e19f461d6f4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 28 Jun 2018 16:17:21 +0200 Subject: MDEV-16615 ASAN SEGV in handler::print_error or server crash after error upon CREATE TABLE table->in_use is not always set and a KILL signal can arrive anytime. --- mysql-test/r/max_statement_time.result | 3 +++ mysql-test/t/max_statement_time.test | 8 ++++++++ sql/handler.cc | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/max_statement_time.result b/mysql-test/r/max_statement_time.result index 44ee03b813a..a87a899b575 100644 --- a/mysql-test/r/max_statement_time.result +++ b/mysql-test/r/max_statement_time.result @@ -181,3 +181,6 @@ ERROR 70100: Query execution was interrupted (max_statement_time exceeded) set max_statement_time = 0; drop procedure pr; drop table t1; +SET max_statement_time= 1; +CREATE TABLE t ENGINE=InnoDB SELECT * FROM seq_1_to_50000; +ERROR 70100: Query execution was interrupted (max_statement_time exceeded) diff --git a/mysql-test/t/max_statement_time.test b/mysql-test/t/max_statement_time.test index 0882daff139..24b6d9311f2 100644 --- a/mysql-test/t/max_statement_time.test +++ b/mysql-test/t/max_statement_time.test @@ -5,6 +5,7 @@ --source include/not_embedded.inc --source include/have_innodb.inc +--source include/have_sequence.inc --source include/not_valgrind.inc --echo @@ -226,3 +227,10 @@ call pr(); set max_statement_time = 0; drop procedure pr; drop table t1; + +# +# MDEV-16615 ASAN SEGV in handler::print_error or server crash after error upon CREATE TABLE +# +SET max_statement_time= 1; +--error ER_STATEMENT_TIMEOUT +CREATE TABLE t ENGINE=InnoDB SELECT * FROM seq_1_to_50000; diff --git a/sql/handler.cc b/sql/handler.cc index 35b0814ef79..9c319b995da 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3413,8 +3413,8 @@ void handler::print_error(int error, myf errflag) break; case HA_ERR_ABORTED_BY_USER: { - DBUG_ASSERT(table->in_use->killed); - table->in_use->send_kill_message(); + DBUG_ASSERT(ha_thd()->killed); + ha_thd()->send_kill_message(); DBUG_VOID_RETURN; } case HA_ERR_WRONG_MRG_TABLE_DEF: -- cgit v1.2.1