Skip to content

Commit 801587c

Browse files
committed
MDEV-32686: minimise crash information
Provide bug url in addition to how to report the bug. Remove obsolete information like key_buffers and used connections as they haven't meaningfully added value to a bug report for quite a while. Remove information that comes from long fixed interfaces in glibc/kernel. Encourage the use of a full backtrace from the core with debug symbols. Lets be realistic about the error messages, its the users we are addressing not developers so wording around getting the information communicated is the key aspect. All the user readable text and instructions are in on place, as non-understandable is the end of the reading process for the user. Remove the duplicate printing of the query. Use my_progname rather than "mysqld" to reflex the program name. So the signal handler output is now in the form: 1. User instructions 2. Server Information 3. Stacktrace 4. connection/query/optimizer_switch 5. Core information and resource limits 6. Kernel information
1 parent 7181ea5 commit 801587c

File tree

1 file changed

+17
-105
lines changed

1 file changed

+17
-105
lines changed

sql/signal_handler.cc

Lines changed: 17 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ extern "C" sig_handler handle_fatal_signal(int sig)
144144
We will try and print the query at the end of the signal handler, in case
145145
we're wrong.
146146
*/
147-
bool print_invalid_query_pointer= false;
148147
#endif
149148

150149
if (segfaulted)
@@ -173,57 +172,19 @@ extern "C" sig_handler handle_fatal_signal(int sig)
173172
goto end;
174173
}
175174

176-
my_safe_printf_stderr("[ERROR] mysqld got " SIGNAL_FMT " ;\n",sig);
175+
my_safe_printf_stderr("[ERROR] %s got " SIGNAL_FMT " ;\n", my_progname, sig);
177176

178177
my_safe_printf_stderr("%s",
179178
"Sorry, we probably made a mistake, and this is a bug.\n\n"
180179
"Your assistance in bug reporting will enable us to fix this for the next release.\n"
181-
"To report this bug, see https://mariadb.com/kb/en/reporting-bugs\n\n");
182-
183-
my_safe_printf_stderr("%s",
184-
"We will try our best to scrape up some info that will hopefully help\n"
185-
"diagnose the problem, but since we have already crashed, \n"
186-
"something is definitely wrong and this may fail.\n\n");
180+
"To report this bug, see https://mariadb.com/kb/en/reporting-bugs about how to report\n"
181+
"a bug on https://jira.mariadb.org/.\n\n"
182+
"Please include the information from the server start above, to the end of the\n"
183+
"information below.\n\n");
187184

188185
set_server_version(server_version, sizeof(server_version));
189-
my_safe_printf_stderr("Server version: %s source revision: %s\n",
190-
server_version, SOURCE_REVISION);
191-
192-
if (dflt_key_cache)
193-
my_safe_printf_stderr("key_buffer_size=%zu\n",
194-
dflt_key_cache->key_cache_mem_size);
195-
196-
my_safe_printf_stderr("read_buffer_size=%lu\n",
197-
global_system_variables.read_buff_size);
198-
199-
my_safe_printf_stderr("max_used_connections=%lu\n",
200-
max_used_connections);
201-
202-
if (thread_scheduler)
203-
my_safe_printf_stderr("max_threads=%lu\n",
204-
thread_scheduler->max_threads +
205-
extra_max_connections);
206-
207-
my_safe_printf_stderr("thread_count=%u\n", THD_count::value());
208-
209-
if (dflt_key_cache && thread_scheduler)
210-
{
211-
size_t used_mem=
212-
(dflt_key_cache->key_cache_mem_size +
213-
(global_system_variables.read_buff_size +
214-
(size_t) global_system_variables.sortbuff_size) *
215-
(thread_scheduler->max_threads + extra_max_connections) +
216-
(max_connections + extra_max_connections) * sizeof(THD)) / 1024;
217-
218-
my_safe_printf_stderr("It is possible that mysqld could use up to \n"
219-
"key_buffer_size + "
220-
"(read_buffer_size + sort_buffer_size)*max_threads = "
221-
"%zu K bytes of memory\n", used_mem);
222-
223-
my_safe_printf_stderr("%s",
224-
"Hope that's ok; if not, decrease some variables in "
225-
"the equation.\n\n");
226-
}
186+
my_safe_printf_stderr("Server version: %s source revision: %s\n\n",
187+
server_version, SOURCE_REVISION);
227188

228189
#ifdef WITH_WSREP
229190
Wsrep_server_state::handle_fatal_signal();
@@ -234,12 +195,14 @@ extern "C" sig_handler handle_fatal_signal(int sig)
234195

235196
if (opt_stack_trace)
236197
{
237-
my_safe_printf_stderr("Thread pointer: %p\n", thd);
238198
my_safe_printf_stderr("%s",
239-
"Attempting backtrace. You can use the following "
240-
"information to find out\n"
241-
"where mysqld died. If you see no messages after this, something went\n"
242-
"terribly wrong...\n");
199+
"The information page at "
200+
"https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mariadbd/\n"
201+
"contains instructions to obtain a better version of the backtrace below.\n"
202+
"Following these instructions will help MariaDB developers provide a fix quicker.\n\n"
203+
"Attempting backtrace. Include this in the bug report.\n"
204+
"(note: Retrieving this information may fail)\n\n");
205+
my_safe_printf_stderr("Thread pointer: %p\n", thd);
243206
my_print_stacktrace(thd ? (uchar*) thd->thread_stack : NULL,
244207
(ulong)my_thread_stack_size, 0);
245208
}
@@ -287,20 +250,12 @@ extern "C" sig_handler handle_fatal_signal(int sig)
287250
kreason= "KILL_WAIT_TIMEOUT";
288251
break;
289252
}
290-
my_safe_printf_stderr("%s", "\n"
291-
"Trying to get some variables.\n"
292-
"Some pointers may be invalid and cause the dump to abort.\n");
293-
294-
my_safe_printf_stderr("Query (%p): ", thd->query());
295-
if (my_safe_print_str(thd->query(), MY_MIN(65536U, thd->query_length())))
296-
{
297-
// Query was found invalid. We will try to print it at the end.
298-
print_invalid_query_pointer= true;
299-
}
300253

301254
my_safe_printf_stderr("\nConnection ID (thread ID): %lu\n",
302255
(ulong) thd->thread_id);
303-
my_safe_printf_stderr("Status: %s\n\n", kreason);
256+
my_safe_printf_stderr("Status: %s\n", kreason);
257+
my_safe_printf_stderr("Query (%p): ", thd->query());
258+
my_safe_print_str(thd->query(), MY_MIN(65536U, thd->query_length()));
304259
my_safe_printf_stderr("%s", "Optimizer switch: ");
305260
ulonglong optsw= thd->variables.optimizer_switch;
306261
for (uint i= 0; optimizer_switch_names[i+1]; i++, optsw >>= 1)
@@ -312,52 +267,9 @@ extern "C" sig_handler handle_fatal_signal(int sig)
312267
}
313268
my_safe_printf_stderr("%s", "\n\n");
314269
}
315-
my_safe_printf_stderr("%s",
316-
"The manual page at "
317-
"https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mariadbd/ contains\n"
318-
"information that should help you find out what is causing the crash.\n");
319270

320271
#endif /* HAVE_STACKTRACE */
321272

322-
#ifdef HAVE_INITGROUPS
323-
if (calling_initgroups)
324-
{
325-
my_safe_printf_stderr("%s", "\n"
326-
"This crash occurred while the server was calling initgroups(). This is\n"
327-
"often due to the use of a mysqld that is statically linked against \n"
328-
"glibc and configured to use LDAP in /etc/nsswitch.conf.\n"
329-
"You will need to either upgrade to a version of glibc that does not\n"
330-
"have this problem (2.3.4 or later when used with nscd),\n"
331-
"disable LDAP in your nsswitch.conf, or use a "
332-
"mysqld that is not statically linked.\n");
333-
}
334-
#endif
335-
336-
if (locked_in_memory)
337-
{
338-
my_safe_printf_stderr("%s", "\n"
339-
"The \"--memlock\" argument, which was enabled, "
340-
"uses system calls that are\n"
341-
"unreliable and unstable on some operating systems and "
342-
"operating-system versions (notably, some versions of Linux).\n"
343-
"This crash could be due to use of those buggy OS calls.\n"
344-
"You should consider whether you really need the "
345-
"\"--memlock\" parameter and/or consult the OS distributer about "
346-
"\"mlockall\" bugs.\n");
347-
}
348-
349-
#ifdef HAVE_STACKTRACE
350-
if (print_invalid_query_pointer)
351-
{
352-
my_safe_printf_stderr(
353-
"\nWe think the query pointer is invalid, but we will try "
354-
"to print it anyway. \n"
355-
"Query: ");
356-
my_write_stderr(thd->query(), MY_MIN(65536U, thd->query_length()));
357-
my_safe_printf_stderr("\n\n");
358-
}
359-
#endif
360-
361273
output_core_info();
362274
#ifdef HAVE_WRITE_CORE
363275
if (test_flags & TEST_CORE_ON_SIGNAL)

0 commit comments

Comments
 (0)