Core Dump not being generated in PostgreSQL

My PostgreSQL server has started crashing unexpectedly, and I wanted to generate a core dump, but the file is not being created.

Here’s what I’ve done so far:

1. Configured:

		
ulimit -S -c unlimited

2. Added the following line to /etc/security/limits.conf:

		
* soft core unlimited

3. Set the core dump path:

		
kernel.core_pattern="/coredumps/core-%e-%s-%u-%g-%p-%t"

4. Gave permissions to the directory:

		
chmod 777 /coredumps

5. Tested it:

		
perl -MPOSIX -e '$0="test"; pause' & kill -ABRT

The file was created in the correct directory.

However, when PostgreSQL crashes, I see the following in the logs:

		
Resource limits disable core dumping for process 3607766 (postmaster). Process 3607766 (postmaster) of user 26 dumped core. [email protected]: Succeeded.

I also noticed that for my test process, the output of cat /proc/pid/limits shows “Max core file size” as “unlimited”, but for PostgreSQL, it shows “0”.

What could be wrong?

Leon Meyer

7 months ago

2 answers

119 views

Rating

05
Answer

Answers

Stéphane Claes

7 months ago

Edited

Rating

00

If you don’t want to restart the service, you can modify the core dump limits for the running process using the prlimit command:

		
sudo prlimit --pid --core=unlimited

This will set the core dump limits for the already running process. However, this is a temporary solution—after restarting PostgreSQL, you’ll need to apply the command again. It’s better to configure the limits via systemd, as described earlier.

Reply

Marie Martin

7 months ago

Rating

00

The issue is that core dump limits are not system-wide but are applied per process, similar to environment variables. When you run ulimit, it only affects the current Bash session, not other processes or services like PostgreSQL.

Since services don’t follow the normal user login process, they don’t inherit settings from /etc/security/limits.conf.

To set core dump limits for PostgreSQL, you need to add the LimitCORE=infinity option in the PostgreSQL service file via systemd.

Here’s how to do it:

		
sudo systemctl edit postgresql.service

Then, add the following lines:

		
[Service] LimitCORE=infinity

Save the file and restart the PostgreSQL service:

		
sudo systemctl restart postgresql

Reply