Re: POC: GUC option for skipping shared buffers in core dumps

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: POC: GUC option for skipping shared buffers in core dumps
Date: 2020-02-10 20:31:47
Message-ID: 20200210203147.GA25558@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-Feb-10, Andres Freund wrote:

> Have you considered postmaster (or even just the GUC processing in each
> process) adjusting /proc/self/coredump_filter instead?
>
> From the man page:
>
> The value in the file is a bit mask of memory mapping types (see mmap(2)). If a bit is set in the mask, then memory mappings of the corresponding
> type are dumped; otherwise they are not dumped. The bits in this file have the following meanings:
>
> bit 0 Dump anonymous private mappings.
> bit 1 Dump anonymous shared mappings.
> bit 2 Dump file-backed private mappings.
> bit 3 Dump file-backed shared mappings.
> bit 4 (since Linux 2.6.24)
> Dump ELF headers.
> bit 5 (since Linux 2.6.28)
> Dump private huge pages.
> bit 6 (since Linux 2.6.28)
> Dump shared huge pages.
> bit 7 (since Linux 4.4)
> Dump private DAX pages.
> bit 8 (since Linux 4.4)
> Dump shared DAX pages.
>
> You can also incorporate this into the start script for postgres today.

Yeah. Maybe we should file bug reports against downstream packages to
include a corefilter tweak.

My development helper script uses this

runpg_corefilter() {
pid=$(head -1 $PGDATADIR/postmaster.pid)
if [ ! -z "$pid" ]; then
echo 0x01 > /proc/$pid/coredump_filter
fi
}

I don't know how easy is it to teach systemd to do this on its service
files.

FWIW I've heard that some people like to have shmem in core files to
improve debuggability, but it's *very* infrequent. But maybe we should have
a way to disable the corefiltering.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-02-10 21:03:31 Re: POC: GUC option for skipping shared buffers in core dumps
Previous Message Andres Freund 2020-02-10 19:56:59 Re: POC: GUC option for skipping shared buffers in core dumps