Debugging a MySQL Server
2824
•
mysqld
hangs during startup (before it writes
ready for connections
).
•
mysqld
crashes during a
pthread_mutex_lock()
or
pthread_mutex_unlock()
call.
In this case, you should set the following environment variable in the shell before starting
gdb
:
LD_ASSUME_KERNEL=2.4.1
export LD_ASSUME_KERNEL
When running
mysqld
under
gdb
, you should disable the stack trace with
--skip-stack-
trace
[422]
to be able to catch segfaults within
gdb
.
In MySQL 4.0.14 and above you should use the
--gdb
[408]
option to
mysqld
. This installs an
interrupt handler for
SIGINT
(needed to stop
mysqld
with
^C
to set breakpoints) and disable stack
tracing and core file handling.
It is very hard to debug MySQL under
gdb
if you do a lot of new connections the whole time as
gdb
doesn't free the memory for old threads. You can avoid this problem by starting
mysqld
with
thread_cache_size
[499]
set to a value equal to
max_connections
[467]
+ 1. In most cases just
using
--thread_cache_size=5'
[499]
helps a lot!
If you want to get a core dump on Linux if
mysqld
dies with a SIGSEGV signal, you can start
mysqld
with the
--core-file
[404]
option. This core file can be used to make a backtrace that may help you
find out why
mysqld
died:
shell>
gdb mysqld core
gdb> backtrace full
gdb> quit
See
Section C.5.4.2, “What to Do If MySQL Keeps Crashing”
.
If you are using
gdb
4.17.x or above on Linux, you should install a
.gdb
file, with the following
information, in your current directory:
set print sevenbit off
handle SIGUSR1 nostop noprint
handle SIGUSR2 nostop noprint
handle SIGWAITING nostop noprint
handle SIGLWP nostop noprint
handle SIGPIPE nostop
handle SIGALRM nostop
handle SIGHUP nostop
handle SIGTERM nostop noprint
If you have problems debugging threads with
gdb
, you should download gdb 5.x and try this instead.
The new
gdb
version has very improved thread handling!
Here is an example how to debug mysqld:
shell>
gdb /usr/local/libexec/mysqld
gdb> run
...
backtrace full # Do this when mysqld crashes
Include the above output in a bug report, which you can file using the instructions in
Section 1.7, “How
to Report Bugs or Problems”
.
If
mysqld
hangs you can try to use some system tools like
strace
or
/usr/proc/bin/pstack
to
examine where
mysqld
has hung.
strace /tmp/log libexec/mysqld
If you are using the Perl
DBI
interface, you can turn on debugging information by using the
trace
method or by setting the
DBI_TRACE
environment variable.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...