pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Size estimation of postgres core files
6+ messages / 4 participants
[nested] [flat]

* Size estimation of postgres core files
@ 2019-02-15 16:33  Jeremy Finzel <finzelj@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Jeremy Finzel @ 2019-02-15 16:33 UTC (permalink / raw)
  To: PostgreSQL General <pgsql-general@lists.postgresql.org>

I am trying to determine the upper size limit of a core file generated for
any given cluster.  Is it feasible that it could actually be the entire
size of the system memory + shared buffers (i.e. really huge)?

I've done a little bit of testing of this myself, but want to be sure I am
clear on this for planning to have enough free space for postgres core
files in case of potential crashes.

Thanks!
Jeremy

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Size estimation of postgres core files
@ 2019-02-15 16:36  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Jeremy Finzel <finzelj@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Alvaro Herrera @ 2019-02-15 16:36 UTC (permalink / raw)
  To: Jeremy Finzel <finzelj@gmail.com>; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>

On 2019-Feb-15, Jeremy Finzel wrote:

> I am trying to determine the upper size limit of a core file generated for
> any given cluster.  Is it feasible that it could actually be the entire
> size of the system memory + shared buffers (i.e. really huge)?

In Linux, yes.  Not sure about other OSes.

You can turn off the dumping of shared memory with some unusably
unfriendly bitwise arithmetic using the "coredump_filter" file in /proc
for the process.  (It's inherited by children, so you can just set it
once for postmaster at server start time).

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




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Size estimation of postgres core files
@ 2019-02-15 18:18  Jeremy Finzel <finzelj@gmail.com>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Jeremy Finzel @ 2019-02-15 18:18 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>

>
> In Linux, yes.  Not sure about other OSes.
>
> You can turn off the dumping of shared memory with some unusably
> unfriendly bitwise arithmetic using the "coredump_filter" file in /proc
> for the process.  (It's inherited by children, so you can just set it
> once for postmaster at server start time).
>

Yes Linux.  This is very helpful, thanks.  A follow-up question - will it
take postgres a really long time to crash (and hopefully recover) if I have
say 1T of RAM because it has to write that all out to a core file first?

Thanks,
Jeremy

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Size estimation of postgres core files
@ 2019-02-15 18:27  Andrew Gierth <andrew@tao11.riddles.org.uk>
  parent: Jeremy Finzel <finzelj@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Andrew Gierth @ 2019-02-15 18:27 UTC (permalink / raw)
  To: Jeremy Finzel <finzelj@gmail.com>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; PostgreSQL General <pgsql-general@lists.postgresql.org>

>>>>> "Jeremy" == Jeremy Finzel <finzelj@gmail.com> writes:

 Jeremy> Yes Linux. This is very helpful, thanks. A follow-up question -
 Jeremy> will it take postgres a really long time to crash (and
 Jeremy> hopefully recover) if I have say 1T of RAM because it has to
 Jeremy> write that all out to a core file first?

It doesn't write out all of RAM, only the amount in use by the
particular backend that crashed (plus all the shared segments attached
by that backend, including the main shared_buffers, unless you disable
that as previously mentioned).

And yes, it can take a long time to generate a large core file.

-- 
Andrew (irc:RhodiumToad)




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Size estimation of postgres core files
@ 2019-02-15 19:01  Jeremy Finzel <finzelj@gmail.com>
  parent: Andrew Gierth <andrew@tao11.riddles.org.uk>
  0 siblings, 1 reply; 6+ messages in thread

From: Jeremy Finzel @ 2019-02-15 19:01 UTC (permalink / raw)
  To: Andrew Gierth <andrew@tao11.riddles.org.uk>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; PostgreSQL General <pgsql-general@lists.postgresql.org>

>
> It doesn't write out all of RAM, only the amount in use by the
> particular backend that crashed (plus all the shared segments attached
> by that backend, including the main shared_buffers, unless you disable
> that as previously mentioned).
>
> And yes, it can take a long time to generate a large core file.
>
> --
> Andrew (irc:RhodiumToad)
>

Based on the Alvaro's response, I thought it is reasonably possible that
that *could* include nearly all of RAM, because that was my original
question.  If shared buffers is say 50G and my OS has 1T, shared buffers is
a small portion of that.  But really my question is what should we
reasonably assume is possible - meaning what kind of space should I
provision for a volume to be able to contain the core dump in case of
crash?  The time of writing the core file would definitely be a concern if
it could indeed be that large.

Could someone provide more information on exactly how to do that
coredump_filter?

We are looking to enable core dumps to aid in case of unexpected crashes
and wondering if there are any recommendations in general in terms of
balancing costs/benefits of enabling core dumps.

Thank you!
Jeremy

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Size estimation of postgres core files
@ 2019-02-24 12:08  Peter J. Holzer <hjp-pgsql@hjp.at>
  parent: Jeremy Finzel <finzelj@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Peter J. Holzer @ 2019-02-24 12:08 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 2019-02-15 13:01:50 -0600, Jeremy Finzel wrote:
>     It doesn't write out all of RAM, only the amount in use by the
>     particular backend that crashed (plus all the shared segments attached
>     by that backend, including the main shared_buffers, unless you disable
>     that as previously mentioned).

> Based on the Alvaro's response, I thought it is reasonably possible that that
> *could* include nearly all of RAM, because that was my original question.  If
> shared buffers is say 50G and my OS has 1T, shared buffers is a small portion
> of that.  But really my question is what should we reasonably assume is
> possible

The size of the core dump will be roughly the same as the VM used by the
process - so that will be the initial size of the process plus shared
buffers plus a (usually small) multiple of work_mem or
maintenance_work_mem plus whatever memory the process allocates.

The big unknown is that "(usually small) multiple of work_mem". I've
seen a process use 8 times work_mem for a moderately complex query, so
depending on what you do it might be worse.

The extra memory allocated by processes is usually small (after all, if
some datastructure were expected to be potentially large it would
probably be limited by work_mem), but if there is a bug (and that's what
you are looking for) it might really grow without bounds.

If you know some upper bound for a reasonable size of your processes you
could set the address space limit - not only will this limit the core
dump size, but it will also prevent a single process from consuming all
RAM and triggering the OOM killer.

You probably don't want to limit the core dump size directly (another
process limit you can set) as that will result in a truncated (and
possibly useless) core dump. For similar reasons I'm not convinced that
omitting the shared memory is a good idea.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2019-02-24 12:08 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 16:33 Size estimation of postgres core files Jeremy Finzel <finzelj@gmail.com>
2019-02-15 16:36 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2019-02-15 18:18   ` Jeremy Finzel <finzelj@gmail.com>
2019-02-15 18:27     ` Andrew Gierth <andrew@tao11.riddles.org.uk>
2019-02-15 19:01       ` Jeremy Finzel <finzelj@gmail.com>
2019-02-24 12:08         ` Peter J. Holzer <hjp-pgsql@hjp.at>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox