From e21408b7991c91878b963c98a7b8a14b7f528e45 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 23 Aug 2019 16:44:51 +0200 Subject: [PATCH] Decrease stack space usage of mysql_execute_command() - WSREP_DEBUG called WSREP_LOG which allocated a 1K variable on stack for each macro usage (at least gcc can't reuse the stack space). Move this concatenation to happen compile-time, not run-time. --- include/wsrep.h | 6 ------ sql/wsrep_mysqld.h | 16 ++++++++-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/wsrep.h b/include/wsrep.h index fde5c5226e7..dbdb746409b 100644 --- a/include/wsrep.h +++ b/include/wsrep.h @@ -46,12 +46,6 @@ if (WSREP(thd) && !thd->lex->no_write_to_binlog \ && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto wsrep_error_label; -#define WSREP_DEBUG(...) \ - if (wsrep_debug) WSREP_LOG(sql_print_information, ##__VA_ARGS__) -#define WSREP_INFO(...) WSREP_LOG(sql_print_information, ##__VA_ARGS__) -#define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) -#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) - #define WSREP_SYNC_WAIT(thd_, before_) \ { if (WSREP_CLIENT(thd_) && \ wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 8714753ba76..42808aa66c0 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -251,14 +251,14 @@ extern wsrep_seqno_t wsrep_locked_seqno; } while(0) #define WSREP_DEBUG(...) \ - if (wsrep_debug) WSREP_LOG(sql_print_information, ##__VA_ARGS__) -#define WSREP_INFO(...) WSREP_LOG(sql_print_information, ##__VA_ARGS__) -#define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) -#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) + if (wsrep_debug) sql_print_information( "WSREP: " __VA_ARGS__) +#define WSREP_INFO(...) sql_print_information( "WSREP: " __VA_ARGS__) +#define WSREP_WARN(...) sql_print_warning( "WSREP: " __VA_ARGS__) +#define WSREP_ERROR(...) sql_print_error( "WSREP: " __VA_ARGS__) #define WSREP_LOG_CONFLICT_THD(thd, role) \ - WSREP_LOG(sql_print_information, \ - "%s: \n " \ + sql_print_information( \ + "WSREP: %s: \n " \ " THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %lld\n " \ " SQL: %s", \ role, \ @@ -273,12 +273,12 @@ extern wsrep_seqno_t wsrep_locked_seqno; #define WSREP_LOG_CONFLICT(bf_thd, victim_thd, bf_abort) \ if (wsrep_debug || wsrep_log_conflicts) \ { \ - WSREP_LOG(sql_print_information, "cluster conflict due to %s for threads:", \ + sql_print_information( "WSREP: cluster conflict due to %s for threads:", \ (bf_abort) ? "high priority abort" : "certification failure" \ ); \ if (bf_thd) WSREP_LOG_CONFLICT_THD(bf_thd, "Winning thread"); \ if (victim_thd) WSREP_LOG_CONFLICT_THD(victim_thd, "Victim thread"); \ - WSREP_LOG(sql_print_information, "context: %s:%d", __FILE__, __LINE__); \ + sql_print_information("WSREP: context: %s:%d", __FILE__, __LINE__); \ } #define WSREP_PROVIDER_EXISTS \