From d28ee189b794d3ceebd4a108da5653a1e38279e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 27 Apr 2020 09:36:31 +0300 Subject: MDEV-22271: Follow-up fix of --embedded Since commit 7198c6ab2dc8f8286f6732824ab985a76ebaaddc the ./mtr --embedded tests would fail to start innodb_plugin because of an undefined reference to the symbol wsrep_log(). Let us define a stub for that function. The embedded server is never built WITH_WSREP, but there are no separate storage engine builds for the embedded server. Hence, by default, the dynamic InnoDB storage engine plugin would be built WITH_WSREP and it would fail to load into the embedded server library due to a reference to the undefined symbol. --- sql/mysqld.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4580da89f16..e2cc7390385 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2018, MariaDB + Copyright (c) 2008, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1814,6 +1814,15 @@ static void close_server_sock() #endif } +#else /* EMBEDDED LIBRARY */ +# ifndef _WIN32 +/* Unfortunately, ha_innodb.so is by default built WITH_WSREP, and it +will be used for both the normal and the embedded server, while the +embedded server library is never built WITH_WSREP. We must define this +symbol in the embedded library, so that loading a dynamic InnoDB storage +engine plugin will work in the embedded server library. */ +void wsrep_log(void (*)(const char *, ...), const char *, ...) {} +# endif #endif /*EMBEDDED_LIBRARY*/ -- cgit v1.2.1 From 758fbec6e3dd5f640c6e2eb1a78675e369540adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 13 Mar 2020 08:37:22 +0200 Subject: Fix clang 10 warnings _ma_fetch_keypage(): Correct an assertion that used to always hold. Thanks to clang -Wint-in-bool-context for flagging this. double_to_datetime_with_warn(): Suppress -Wimplicit-int-float-conversion by adding a cast. LONGLONG_MAX converted to double will actually be LONGLONG_MAX+1. --- sql/sql_time.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/sql_time.cc b/sql/sql_time.cc index 6d94de047e8..421eb79c7a3 100644 --- a/sql/sql_time.cc +++ b/sql/sql_time.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. - Copyright (c) 2009, 2013 Monty Program Ab. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -402,7 +402,7 @@ bool double_to_datetime_with_warn(double value, MYSQL_TIME *ltime, if (neg) value= -value; - if (value > LONGLONG_MAX) + if (value > static_cast(LONGLONG_MAX)) value= static_cast(LONGLONG_MAX); longlong nr= static_cast(floor(value)); -- cgit v1.2.1 From 6be05ceb05609b1aa7382776b4e27ad134808eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 27 Apr 2020 09:40:51 +0300 Subject: MDEV-22203: WSREP_ON is unnecessarily expensive to evaluate This is a backport of the applicable part of commit 93475aff8de80a0ef53cbee924bcb70de6e86f2c and commit 2c39f69d34e64a5cf94720e82e78c0ee91bd4649 from 10.4. Before 10.4 and Galera 4, WSREP_ON is a macro that points to a global Boolean variable, so it is not that expensive to evaluate, but we will add an unlikely() hint around it. WSREP_ON_NEW: Remove. This macro was introduced in commit c863159c320008676aff978a7cdde5732678f975 when reverting WSREP_ON to its previous definition. We replace some use of WSREP_ON with WSREP(thd), like it was done in 93475aff8de80a0ef53cbee924bcb70de6e86f2c. Note: the macro WSREP() in 10.1 is equivalent to WSREP_NNULL() in 10.4. Item_func_rand::seed_random(): Avoid invoking current_thd when WSREP is not enabled. --- sql/item_func.cc | 23 ++++++++++++----------- sql/log.cc | 9 +++++---- sql/log_event.cc | 8 ++++---- sql/mysqld.cc | 2 ++ sql/slave.cc | 8 +++++--- sql/sql_base.cc | 4 ++-- sql/sql_parse.cc | 8 ++++---- sql/sql_table.cc | 4 ++-- sql/wsrep_mysqld.h | 8 +------- 9 files changed, 37 insertions(+), 37 deletions(-) (limited to 'sql') diff --git a/sql/item_func.cc b/sql/item_func.cc index 302ec58a708..8407dc881be 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2650,19 +2650,20 @@ void Item_func_rand::seed_random(Item *arg) TODO: do not do reinit 'rand' for every execute of PS/SP if args[0] is a constant. */ - uint32 tmp; + uint32 tmp= (uint32) arg->val_int(); #ifdef WITH_WSREP - THD *thd= current_thd; - if (WSREP(thd)) + if (WSREP_ON) { - if (thd->wsrep_exec_mode==REPL_RECV) - tmp= thd->wsrep_rand; - else - tmp= thd->wsrep_rand= (uint32) arg->val_int(); - } - else + THD *thd= current_thd; + if (thd->variables.wsrep_on) + { + if (thd->wsrep_exec_mode==REPL_RECV) + tmp= thd->wsrep_rand; + else + thd->wsrep_rand= tmp; + } + } #endif /* WITH_WSREP */ - tmp= (uint32) arg->val_int(); my_rnd_init(rand, (uint32) (tmp*0x10001L+55555555L), (uint32) (tmp*0x10000001L)); diff --git a/sql/log.cc b/sql/log.cc index 0efef6d1e29..076dd36a219 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1791,7 +1791,7 @@ binlog_commit_flush_stmt_cache(THD *thd, bool all, #ifdef WITH_WSREP if (thd->wsrep_mysql_replicated > 0) { - DBUG_ASSERT(WSREP_ON); + DBUG_ASSERT(WSREP(thd)); WSREP_DEBUG("avoiding binlog_commit_flush_trx_cache: %d", thd->wsrep_mysql_replicated); return 0; @@ -6612,14 +6612,15 @@ int MYSQL_BIN_LOG::rotate(bool force_rotate, bool* check_purge) int error= 0; DBUG_ENTER("MYSQL_BIN_LOG::rotate"); - if (wsrep_to_isolation) +#ifdef WITH_WSREP + if (WSREP_ON && wsrep_to_isolation) { - DBUG_ASSERT(WSREP_ON); *check_purge= false; - WSREP_DEBUG("avoiding binlog rotate due to TO isolation: %d", + WSREP_DEBUG("avoiding binlog rotate due to TO isolation: %d", wsrep_to_isolation); DBUG_RETURN(0); } +#endif /* WITH_WSREP */ //todo: fix the macro def and restore safe_mutex_assert_owner(&LOCK_log); *check_purge= false; diff --git a/sql/log_event.cc b/sql/log_event.cc index d731c39d9c5..bb3465ae9f0 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4770,7 +4770,7 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi) } } #ifdef WITH_WSREP - else if (WSREP_ON && wsrep_mysql_replication_bundle && opt_slave_domain_parallel_threads == 0 && + else if (WSREP(thd) && wsrep_mysql_replication_bundle && opt_slave_domain_parallel_threads == 0 && thd->wsrep_mysql_replicated > 0 && (is_begin() || is_commit())) { @@ -4784,7 +4784,7 @@ Query_log_event::do_shall_skip(rpl_group_info *rgi) thd->wsrep_mysql_replicated = 0; } } -#endif +#endif /* WITH_WSREP */ DBUG_RETURN(Log_event::do_shall_skip(rgi)); } @@ -7755,7 +7755,7 @@ Xid_log_event::do_shall_skip(rpl_group_info *rgi) DBUG_RETURN(Log_event::EVENT_SKIP_COUNT); } #ifdef WITH_WSREP - else if (wsrep_mysql_replication_bundle && WSREP_ON && + else if (WSREP(thd) && wsrep_mysql_replication_bundle && opt_slave_domain_parallel_threads == 0) { if (++thd->wsrep_mysql_replicated < (int)wsrep_mysql_replication_bundle) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e2cc7390385..ff3faaa92bc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5781,8 +5781,10 @@ int mysqld_main(int argc, char **argv) set_user(mysqld_user, user_info); } +#ifdef WITH_WSREP if (WSREP_ON && wsrep_check_opts()) global_system_variables.wsrep_on= 0; +#endif if (opt_bin_log && !global_system_variables.server_id) { diff --git a/sql/slave.cc b/sql/slave.cc index cbfc3fd8413..26fabc2cc52 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB Corporation + Copyright (c) 2009, 2020, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4998,8 +4998,10 @@ pthread_handler_t handle_slave_sql(void *arg) if (!sql_slave_killed(serial_rgi)) { slave_output_error_info(serial_rgi, thd); - if (WSREP_ON && rli->last_error().number == ER_UNKNOWN_COM_ERROR) + if (WSREP(thd) && rli->last_error().number == ER_UNKNOWN_COM_ERROR) + { wsrep_node_dropped= TRUE; + } } goto err; } @@ -5131,7 +5133,7 @@ err_during_init: If slave stopped due to node going non primary, we set global flag to trigger automatic restart of slave when node joins back to cluster. */ - if (WSREP_ON && wsrep_node_dropped && wsrep_restart_slave) + if (WSREP(thd) && wsrep_node_dropped && wsrep_restart_slave) { if (wsrep_ready_get()) { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 1c4e7600d87..1dbed8c55d1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2016, MariaDB + Copyright (c) 2010, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4784,7 +4784,7 @@ restart: } } - if (WSREP_ON && + if (WSREP(thd) && wsrep_replicate_myisam && (*start) && (*start)->table && diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e5626ccbd7c..d19cbf5ad9b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB + Copyright (c) 2008, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1493,7 +1493,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (parser_state.init(thd, thd->query(), thd->query_length())) break; - if (WSREP_ON) + if (WSREP(thd)) wsrep_mysql_parse(thd, thd->query(), thd->query_length(), &parser_state); else mysql_parse(thd, thd->query(), thd->query_length(), &parser_state); @@ -1574,13 +1574,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, */ statistic_increment(thd->status_var.questions, &LOCK_status); - if(!WSREP(thd)) + if (!WSREP(thd)) thd->set_time(); /* Reset the query start time. */ parser_state.reset(beginning_of_next_stmt, length); /* TODO: set thd->lex->sql_command to SQLCOM_END here */ - if (WSREP_ON) + if (WSREP(thd)) wsrep_mysql_parse(thd, beginning_of_next_stmt, length, &parser_state); else mysql_parse(thd, beginning_of_next_stmt, length, &parser_state); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e694c52e272..ef6a8c01843 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB + Copyright (c) 2010, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -5338,7 +5338,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, DBUG_ENTER("mysql_create_like_table"); #ifdef WITH_WSREP - if (WSREP_ON && !thd->wsrep_applier && + if (WSREP(thd) && !thd->wsrep_applier && wsrep_create_like_table(thd, table, src_table, create_info)) DBUG_RETURN(res); #endif diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index a5ec69268d4..1531abe78f8 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -179,13 +179,7 @@ extern void wsrep_prepend_PATH (const char* path); /* Other global variables */ extern wsrep_seqno_t wsrep_locked_seqno; -#define WSREP_ON \ - (global_system_variables.wsrep_on) - -#define WSREP_ON_NEW \ - ((global_system_variables.wsrep_on) && \ - wsrep_provider && \ - strcmp(wsrep_provider, WSREP_NONE)) +#define WSREP_ON unlikely(global_system_variables.wsrep_on) #define WSREP(thd) \ (WSREP_ON && thd->variables.wsrep_on) -- cgit v1.2.1 From dd4124c22430dd2f245afbf9a20cfea303de3320 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 22 Apr 2020 13:21:43 +0200 Subject: MDEV-22271 Excessive stack memory usage due to WSREP_LOG fix embedded innodb_plugin tests followup for 7198c6ab2dc --- sql/mysqld.cc | 9 --------- sql/wsrep_dummy.cc | 4 ++++ 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ff3faaa92bc..594f50b72f2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1814,15 +1814,6 @@ static void close_server_sock() #endif } -#else /* EMBEDDED LIBRARY */ -# ifndef _WIN32 -/* Unfortunately, ha_innodb.so is by default built WITH_WSREP, and it -will be used for both the normal and the embedded server, while the -embedded server library is never built WITH_WSREP. We must define this -symbol in the embedded library, so that loading a dynamic InnoDB storage -engine plugin will work in the embedded server library. */ -void wsrep_log(void (*)(const char *, ...), const char *, ...) {} -# endif #endif /*EMBEDDED_LIBRARY*/ diff --git a/sql/wsrep_dummy.cc b/sql/wsrep_dummy.cc index 43cea8bad42..364ef2d3e7a 100644 --- a/sql/wsrep_dummy.cc +++ b/sql/wsrep_dummy.cc @@ -141,3 +141,7 @@ void wsrep_unlock_rollback() void wsrep_set_data_home_dir(const char *) { } + +void wsrep_log(void (*)(const char *, ...), const char *, ...) +{ +} -- cgit v1.2.1