Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a8Lez-00049E-56 for pgsql-committers@arkaria.postgresql.org; Mon, 14 Dec 2015 05:26:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a8Ley-0003nZ-No for pgsql-committers@arkaria.postgresql.org; Mon, 14 Dec 2015 05:26:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a8Lel-0003Zz-7H for pgsql-committers@postgresql.org; Mon, 14 Dec 2015 05:26:43 +0000 Received: from mout.gmx.net ([212.227.17.21]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.84) (envelope-from ) id 1a8Leh-0002o7-7s for pgsql-committers@postgresql.org; Mon, 14 Dec 2015 05:26:42 +0000 Received: from auth1-smtp.messagingengine.com ([66.111.4.227]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MKpQ4-1a8Led3Pe4-0003yK for ; Mon, 14 Dec 2015 06:26:36 +0100 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 3AAB62048A for ; Mon, 14 Dec 2015 00:26:34 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Mon, 14 Dec 2015 00:26:34 -0500 X-Sasl-enc: 4lEtMLRcq4pWE3pS6DoVszCsZl93BVxfbjX/cr5LMRB+ 1450070793 Received: from [10.0.0.7] (c-73-13-69-21.hsd1.pa.comcast.net [73.13.69.21]) by mail.messagingengine.com (Postfix) with ESMTPA id 5D554C016DB; Mon, 14 Dec 2015 00:26:32 -0500 (EST) Subject: Re: pgsql: Fix bug leading to restoring unlogged relations from empty files To: Andres Freund , pgsql-committers@postgresql.org References: From: Peter Eisentraut Message-ID: <566E5308.7060109@gmx.net> Date: Mon, 14 Dec 2015 00:26:32 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:rR7tnynVutC00X9ikQoEiAfKSaYx5GOJmrRKT/DTXM7QDPPUS/p rQbp47D9CALRsHga8HNl7p7XwgcG0/bw3IT/rLilmQk9kPlAIxj8DCS/zFS5aqWCK2FlGcq AniHLRB6K5wldpnr2m2nOSULJeGQC9sGJWfyid0LXSAVRG31e871FGPKHZ/Q+2bbPvxuy8K SeIPgx64uo54RhuvZGM+w== X-UI-Out-Filterresults: notjunk:1;V01:K0:YuAY2jb9y7w=:3ecWGXbg9GvQoyciFwCMPz /PnoQPoKkkEHh14SYThwRSgdIar/7erHjVIosQU2LzHTqR3HL0OqMVuNOBHIRaRrs8pi6zlAV bihYYds4T/vtGnW/uaRXAxHmH21J+Hxb/FtZ4wgpfjWGFVwNE5vpz5nQOByX/qd01GwTj0OzP QILmVtcF6ny1ifuRVTfXY8kvvi+ZsDL84MkIQMTotB1+f630QBdfmO/YqNiTs8XyelGh1GBdV hdvwfqmWCGKuHKi6Pj2+sPUZ2iWozRom0OAE9ks6V1P7n97eH8wm79t/bmpnEsSxdlTD28QM+ 2i6ps5F5asNEdX1LtOc8bqy+wDW0S5taW490+OjqOs9BAlcnwOjRKgOVRnCmAmr2w9dK8ORhn auQJcIhMlTzQD9VNhEIuLlwpS0OAGUfMKsfu5iMMGj5uym2WyRBlonirnYc47ggVMEKgrUNy6 HMYUPGN+ug9TA70I2GFyBkvRBpfD7MeXS5sAMv+AcrOhGwwcaXuO16U6+oz9UzkYmmncZPdog jz/kTBvKqXAwfdDCcQwi6MqNyN4c5QEUEstxCYawr7212d7tJFgD/7WwyTsU3vjyxrWug4DcD duLKbqdsdYlimuXE2pDkK0vmipFxYOwjOlte9ogiy+5zgSjgyB0MCyaTJFZb3F0isMM3GRpxG 9yClxntQfjHO5khl4+ViHrk2H/NaSrTzEvBa3P8LDidqJuo7rZ6bbB7KXgUNmNLkKS4ywX+jQ 88gRK0Zlfp8aOKxe0V5Bt/zbj91NHGcnd4+7n5JgMS7PJXicRviDuok9Rsbs8hSCErmQpfRHG 91VgWpZ X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org 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