Re: postgresql latency & bgwriter not doing its job - Mailing list pgsql-hackers

From Robert Haas
Subject Re: postgresql latency & bgwriter not doing its job
Date
Msg-id CA+TgmoakiQSFHb8BhoKeiM8Akz6k-oiQG05tx+npP4f6e19b1Q@mail.gmail.com
Whole thread Raw
In response to Re: postgresql latency & bgwriter not doing its job  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: postgresql latency & bgwriter not doing its job
List pgsql-hackers
On Sat, Aug 30, 2014 at 2:04 PM, Andres Freund <andres@2ndquadrant.com> wrote:
> If the sort buffer is allocated when the checkpointer is started, not
> everytime we sort, as you've done in your version of the patch I think
> that risk is pretty manageable. If we really want to be sure nothing is
> happening at runtime, even if the checkpointer was restarted, we can put
> the sort array in shared memory.

I don't think that allocating the array at checkpointer start time
helps.  If it works, then you're strictly worse off than if you
allocate it at every checkpoint, because you're holding onto the
memory all the time instead of only when it's being used.  And if it
fails, what then?  Sure, you can have that copy of the checkpointer
process exit, but that does nothing good.  The postmaster will keep on
restarting it and it will keep on dying for lack of memory, and no
checkpoints will complete.  Oops.

So it seems to me that the possibly-sensible approaches are:

1. Allocate an array when we need to sort, and if the allocation
fails, have some kind of fallback strategy, like logging a WARNING an
writing the buffers out without sorting them.  If it succeeds, do the
checkpoint and then free the memory until we need it again.

2. Putting the array in shared_memory, so that once the server is
started, we can be sure the memory is allocated and the sort will
work.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Stepan Rutz
Date:
Subject: Re: Patch for psql History Display on MacOSX
Next
From: Robert Haas
Date:
Subject: Re: COPY and heap_sync