Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZB4gM-0004mS-2B for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2015 17:23:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZB4gJ-0004e4-Pt for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2015 17:23:19 +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 1ZB4eX-00039X-1K for pgsql-hackers@postgresql.org; Fri, 03 Jul 2015 17:21:29 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZB4eT-0007Ri-VL for pgsql-hackers@postgresql.org; Fri, 03 Jul 2015 17:21:28 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id D5D11860002; Fri, 3 Jul 2015 19:21:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-6.1 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 D56F9860001; Fri, 3 Jul 2015 19:21:21 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 6628C102215; Fri, 3 Jul 2015 19:21:21 +0200 (CEST) Date: Fri, 3 Jul 2015 19:21:21 +0200 From: Andres Freund To: Martijn van Oosterhout Cc: Tom Lane , Fujii Masao , PostgreSQL-development Subject: Re: WAL logging problem in 9.4.3? Message-ID: <20150703172121.GL3291@awork2.anarazel.de> References: <20150702220524.GA9392@svana.org> <20150702222102.GG30708@awork2.anarazel.de> <20150703052048.GA20285@svana.org> <20150703060137.GB20285@svana.org> <28320.1435935120@sss.pgh.pa.us> <10146.1435942436@sss.pgh.pa.us> <20150703171426.GA2841@svana.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150703171426.GA2841@svana.org> 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 19:14:26 +0200, Martijn van Oosterhout wrote: > Am I missing something. ISTM that if the truncate record was simply not > logged at all everything would work fine. The whole point is that the > table was created in this transaction and so if it exists the table on > disk must be the correct representation. That'd not work either. Consider: BEGIN; CREATE TABLE ... INSERT; TRUNCATE; INSERT; COMMIT; If you replay that without a truncation wal record the second INSERT will try to add stuff to already occupied space. And they can have different lengths and stuff, so you cannot just ignore that fact. > The broken index is just one symptom. Agreed. I think the problem is something else though. Namely that we reuse the relfilenode for heap_truncate_one_rel(). That's just entirely broken afaics. We need to allocate a new relfilenode and write stuff into that. Then we can forgo WAL logging the truncation record. > If you insert a row before commit then after replay the tuple should be there still. The insert would be WAL logged. COPY skips wal logging tho. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers