From: Peter Eisentraut <peter_e@gmx.net>
To: Andres Freund <andres@anarazel.de>
To: pgsql-committers@postgresql.org
Subject: Re: pgsql: Fix bug leading to restoring unlogged relations from empty files
Date: Mon, 14 Dec 2015 00:26:32 -0500
Message-ID: <566E5308.7060109@gmx.net> (raw)
In-Reply-To: <E1a73U7-0002z5-Pe@gemulon.postgresql.org>
References: <E1a73U7-0002z5-Pe@gemulon.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
Coverity is complaining that in
void
FlushOneBuffer(Buffer buffer)
{
BufferDesc *bufHdr;
/* currently not needed, but no fundamental reason not to support */
Assert(!BufferIsLocal(buffer));
Assert(BufferIsPinned(buffer));
bufHdr = GetBufferDescriptor(buffer - 1);
LWLockHeldByMe(bufHdr->content_lock);
FlushBuffer(bufHdr, NULL);
}
the call to LWLockHeldByMe() is useless.
On 12/10/15 10:50 AM, Andres Freund wrote:
> Fix bug leading to restoring unlogged relations from empty files.
>
> At the end of crash recovery, unlogged relations are reset to the empty
> state, using their init fork as the template. The init fork is copied to
> the main fork without going through shared buffers. Unfortunately WAL
> replay so far has not necessarily flushed writes from shared buffers to
> disk at that point. In normal crash recovery, and before the
> introduction of 'fast promotions' in fd4ced523 / 9.3, the
> END_OF_RECOVERY checkpoint flushes the buffers out in time. But with
> fast promotions that's not the case anymore.
>
> To fix, force WAL writes targeting the init fork to be flushed
> immediately (using the new FlushOneBuffer() function). In 9.5+ that
> flush can centrally be triggered from the code dealing with restoring
> full page writes (XLogReadBufferForRedoExtended), in earlier releases
> that responsibility is in the hands of XLOG_HEAP_NEWPAGE's replay
> function.
>
> Backpatch to 9.1, even if this currently is only known to trigger in
> 9.3+. Flushing earlier is more robust, and it is advantageous to keep
> the branches similar.
>
> Typical symptoms of this bug are errors like
> 'ERROR: index "..." contains unexpected zero page at block 0'
> shortly after promoting a node.
>
> Reported-By: Thom Brown
> Author: Andres Freund and Michael Paquier
> Discussion: 20150326175024.GJ451@alap3.anarazel.de
> Backpatch: 9.1-
>
> Branch
> ------
> REL9_5_STABLE
>
> Details
> -------
> http://git.postgresql.org/pg/commitdiff/5b51805fe4b9fec95274924c5733093a5f685a58
>
> Modified Files
> --------------
> src/backend/access/transam/xlogutils.c | 9 +++++++++
> src/backend/storage/buffer/bufmgr.c | 21 +++++++++++++++++++++
> src/include/storage/bufmgr.h | 1 +
> 3 files changed, 31 insertions(+)
>
>
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: peter_e@gmx.net, andres@anarazel.de
Subject: Re: pgsql: Fix bug leading to restoring unlogged relations from empty files
In-Reply-To: <566E5308.7060109@gmx.net>
References: <E1a73U7-0002z5-Pe@gemulon.postgresql.org> <566E5308.7060109@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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