1

Suddenly my postgresql service started crashing for some reason. I wanted to generate coredump file but file is not generating.
I set: "ulimit -S -c unlimited", also added line "*soft core unlimited" to /etc/security/limits.conf.

Also set my destination dir to kernel.core_pattern="/coredumps/core-%e-%s-%u-%g-%p-%t". Also executed "chmod 777" to destination path to eliminate permission issues. I was able to generate test coredump file by executing "perl -MPOSIX -e '$0="ttt"; pause' &" and then running "kill -ABRT " and file got saved to /coredumps with correct filename.

When my postgres crashes i can see in logs:

Resource limits disable core dumping for process 3607766 (postmaster).

Process 3607766 (postmaster) of user 26 dumped core.

[email protected]: Succeeded.

Also i noticed difference between outputs of "cat /proc/pid/limits" between my test process and postgres. Test process has "Max core file size" set to "unlimited" and postgresql value "0" enter image description here

1
  • 1
    Have you tried adding LimitCORE=infinity to the [service] section of the postgress unit file? Commented Oct 11, 2024 at 13:12

1 Answer 1

2

Limits are not system-wide – they are per-process, initialized and inherited similar to environment variables. Your ulimit command therefore only raises the coredump limit for the Bash instance you're entering that command in – not for anyone else and not for any service.

The limits are initialized from /etc/security/limits.conf for user logins; however, on Linux, services don't go through the "user login" procedure even if they have a service account, so the limit initialization from /etc/security will not occur.

Instead all such limits need to be set through the service manager which starts Postgres – in this case systemd, so you need to use systemctl edit to add the LimitCORE= option to the .service file.

Alternatively, you can use the prlimit command to change the resource limits of an already running process, assuming it can still run for a short while before it crashes.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.