Re: POC: GUC option for skipping shared buffers in core dumps - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: POC: GUC option for skipping shared buffers in core dumps
Date
Msg-id 20200210203147.GA25558@alvherre.pgsql
Whole thread Raw
In response to Re: POC: GUC option for skipping shared buffers in core dumps  (Andres Freund <andres@anarazel.de>)
Responses Re: POC: GUC option for skipping shared buffers in core dumps
List 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,
thenmemory 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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: POC: GUC option for skipping shared buffers in core dumps
Next
From: Andres Freund
Date:
Subject: Re: POC: GUC option for skipping shared buffers in core dumps