From af0ff8b4553f96f18b87f7a499846c510f17c49b Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Thu, 8 Dec 2022 19:34:00 +0000 Subject: MDEV-17093: SOURCE_REVISION in log and handle_fatal_signal MariaDB MDEV-12583 added `SOURCE_REVISION` variable that exposes the SHA1 of source code commit that the current running engine was built from. This info is useful for troubleshooting and debugging. This commit does the following: - addes the `SOURCE_REVISION` value into engine error log. - when a crash triggers handle_fatal_signal, the `SOURCE_REVISION` will be included in crash report. - resolves MDEV-20344: startup messages belong in stderr/error-log not stdout All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- sql/mysqld.cc | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b1cf5ab2796..75eb2230b32 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -119,6 +119,8 @@ #include +#include + #define mysqld_charset &my_charset_latin1 /* We have HAVE_valgrind below as this speeds up the shutdown of MySQL */ @@ -4445,21 +4447,6 @@ static int init_common_variables() mysql_real_data_home_len= uint(strlen(mysql_real_data_home)); - if (!opt_abort) - { - if (IS_SYSVAR_AUTOSIZE(&server_version_ptr)) - sql_print_information("%s (mysqld %s) starting as process %lu ...", - my_progname, server_version, (ulong) getpid()); - else - { - char real_server_version[SERVER_VERSION_LENGTH]; - set_server_version(real_server_version, sizeof(real_server_version)); - sql_print_information("%s (mysqld %s as %s) starting as process %lu ...", - my_progname, real_server_version, server_version, - (ulong) getpid()); - } - } - sf_leaking_memory= 0; // no memory leaks from now on #ifndef EMBEDDED_LIBRARY @@ -5258,6 +5245,13 @@ static int init_server_components() error_handler_hook= my_message_sql; proc_info_hook= set_thd_stage_info; + /* + Print source revision hash, as one of the first lines, if not the + first in error log, for troubleshooting and debugging purposes + */ + sql_print_information("Starting MariaDB %s source revision %s as process %lu", + server_version, SOURCE_REVISION, (ulong) getpid()); + #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE /* Parsing the performance schema command line option may have reported -- cgit v1.2.1 From e64e6768e00c6ef58824b79f2009aa5668ccd538 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 8 Jan 2023 09:26:50 +1100 Subject: MDEV-17093: SOURCE_REVISION in log (postfix - not in help) Don't display the source revision in the mysqld --help output. --- sql/mysqld.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 75eb2230b32..e4a814b82dd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5249,8 +5249,9 @@ static int init_server_components()  Print source revision hash, as one of the first lines, if not the  first in error log, for troubleshooting and debugging purposes  */ - sql_print_information("Starting MariaDB %s source revision %s as process %lu", - server_version, SOURCE_REVISION, (ulong) getpid()); + if (!opt_help) + sql_print_information("Starting MariaDB %s source revision %s as process %lu", + server_version, SOURCE_REVISION, (ulong) getpid()); #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE /* -- cgit v1.2.1