Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZBAL7-00023H-MH for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2015 23:25:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZBAL6-0000iS-DA for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2015 23:25:48 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZBAL1-0000fJ-QI for pgsql-hackers@postgresql.org; Fri, 03 Jul 2015 23:25:43 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZBAKo-0004Iy-KY for pgsql-hackers@postgresql.org; Fri, 03 Jul 2015 23:25:42 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 92C78860002; Sat, 4 Jul 2015 01:25:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC66C2.dip0.t-ipconnect.de [93.220.102.194]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 78044860001; Sat, 4 Jul 2015 01:25:24 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 041DE100F55; Sat, 4 Jul 2015 01:25:23 +0200 (CEST) Date: Sat, 4 Jul 2015 01:25:23 +0200 From: Andres Freund To: Tom Lane Cc: Fujii Masao , Martijn van Oosterhout , PostgreSQL-development Subject: Re: WAL logging problem in 9.4.3? Message-ID: <20150703232523.GP3291@awork2.anarazel.de> References: <20150703060137.GB20285@svana.org> <28320.1435935120@sss.pgh.pa.us> <20150703164931.GI3291@awork2.anarazel.de> <20150703170229.GJ3291@awork2.anarazel.de> <20150703172605.GM3291@awork2.anarazel.de> <20150703223216.GO3291@awork2.anarazel.de> <21533.1435963117@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21533.1435963117@sss.pgh.pa.us> X-Pg-Spam-Score: -4.8 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2015-07-03 18:38:37 -0400, Tom Lane wrote: > > Why exactly? The first truncation in the (sub)xact would have assigned a > new relfilenode, why do we need another one? The file in question will > go away on crash/rollback in any case, and no other transaction can see > it yet. Consider: BEGIN; CREATE TABLE; INSERT largeval; TRUNCATE; INSERT 1; COPY; INSERT 2; COMMIT; INSERT 1 is going to be WAL logged. For that to work correctly TRUNCATE has to be WAL logged, as otherwise there'll be conflicting/overlapping tuples on the target page. But: The truncation itself is not fully wal logged, neither is the COPY. Both rely on heap_sync()/immedsync(). For that to be correct the current relfilenode's truncation may *not* be wal-logged, because the contents of the COPY or the truncation itself will only be on-disk, not in the WAL. Only being on-disk but not in the WAL is a problem if we crash and replay the truncate record. > I'm prepared to believe that some bit of logic is doing the wrong > thing in this state, but I do not agree that truncate-in-place is > unworkable. Unless we're prepared to make everything that potentially WAL logs something do the rel->rd_createSubid == mySubid && dance, I can't see that working. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers