Enable Core Dumps

You are viewing an old version of this article. View the current version here.

Enabling in your configuration file

Add the following to the end of your ~/.my.cnf (or whatever configuration file you use):

[mysqld]
stack-trace
core-file
disable-gdb
[mysqld-safe]
--core-file-size=unlimited

These options are safe to leave there.

You can check your current values by executing:

my_print_defaults --defaults-file=my.cnf mysqld
my_print_defaults --defaults-file=my.cnf mysqld-safe

If you are not using mysqld-safe, then you should ensure that you don't have a system limit for the size of your core file. You can ensure this by doing the following in the shell script that start mysqld.

ulimit -c unlimited

Note: If you are using mysqld_safe and running mysqld as the root user, then no core file is created on some systems. The solution is to run mysqld as another user.

What To Do If You Don't Get a Core File When mysqld Crashes

On some systems there is a limit of the size of the core file. You can check and increase the limit with:

ulimit -c
ulimit -c unlimited

The above are shell limits and you should do this before you start mysqld again.

If the mysqld server is built with ASAN (Address Sanitizer) then it will not be able to generate a core file.

On some Linux systems the core files are disabled in the kernel. You can check this with:

sysctl -a | grep k.*core
sysctl -a | grep dumpable

Ensure that fs.suid_dumpable=2. You can set it with:

/sbin/sysctl -w fs.suid_dumpable=2

Ensure that you have enough free disk space in the path pointed to by kernel.core_pattern. When MariaDB is writing a core dump, the error log contains a message indicating that a core file is written in the data_dir, but it also might be written in the directory pointed to by the previously mentioned kernel parameter (see MDEV-15775).

Another solution is to start the server while logged in as the mysql user. This is because on some systems a process that changes uid is not allowed to dump core.

If you are still struggling to get a core file, you can test and adjust your setup. See "Forcing a Core File" below.

See also http://www.cyberciti.biz/tips/linux-core-dumps.html#comments

See also https://www.percona.com/blog/2011/08/26/getting-mysql-core-file-on-linux/

Getting a Core File Under systemd

Systems using systemd write by default (using kernel.core_pattern) core files to the journal that you can retrieve with coredumpctl list, if you are lucky. This is the case with openSUSE 42.3.

To get the core files in the current directory of the application, which is what mysql-test-run expects, you can execute as root:

sudo sysctl kernel.core_pattern=core kernel.core_uses_pid=1

To make this setting permanent, you have to also edit the file /etc/sysctl.d/50-coredump.conf and change this to say:

kernel.core_pattern = core
kernel.core_uses_pid = 1

Forcing a Core File

To force a core file for mysqld you can send the process the sigabrt (6) signal. This is very useful to get the state of the unresponsive mysqld process. Note that this will crash mysqld (like a kill -9) and crash recovery will be run on restart.

kill -6 `pidof mysqld`

As an alternative to `pidof mysqld`, you can find the process number either with ps or in the *.pid file that is in the datadir directory.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.