1

We are using Postgres 12 (TimescaleDB) and managing it through Patroni.

There was some unexpected issue that happened and crash dump written in the default location /var/crash/_usr_lib_postgresql_12_bin_postgres.111.crash, and this, in turn, caused a root disk full.

I looked around so many ways how to change this location but couldn't succeed.

Would you please someone help with this? Thanks in advance

Nagarjuna D N
  • 541
  • 6
  • 26
  • Like [this](https://stackoverflow.com/questions/16048101/changing-location-of-core-dump)? –  Oct 01 '20 at 08:58
  • @a_horse_with_no_name Am specifically looking for Postgres but your referral is for Linux core dump. Will that work? – Nagarjuna D N Oct 01 '20 at 09:11

1 Answers1

0

First of all postgresql must be configured with e.g. in /etc/postgresql/12/main/pg_ctl.conf:

pg_ctl_options = '--core-files'

if you remove the -c/--core-file flag no core dump will be produced (not good for issue diagnosis).

By default postgres writes core dump to data directory path.

Check you current kernel.core_pattern configuration:

$ sysctl kernel.core_pattern
kernel.core_pattern = core

You can specify multiple variables that gets substituted:

  • %p - pid
  • %% - output one '%'
  • %u - uid
  • %g - gid
  • %s - signal number
  • %t - UNIX time of dump
  • %h - hostname
  • %e - executable filename

It's good idea to include at least %p (pid) in the path, in order to distinguish between consequent crashes.

sysctl -w kernel.core_pattern='/tmp/core.%e.%p'

in order to persist the change after reboot add the config e.g. to /etc/sysctl.conf:

kernel.core_pattern=/tmp/core.%e.%p
Tombart
  • 30,520
  • 16
  • 123
  • 136