Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZC8D5-0001R3-Sl for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2015 15:21:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZC8D5-0004Ex-1n for pgsql-hackers@arkaria.postgresql.org; Mon, 06 Jul 2015 15:21:31 +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 1ZC8D3-0004Ej-Hh for pgsql-hackers@postgresql.org; Mon, 06 Jul 2015 15:21:29 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZC8Cz-0001nw-IC for pgsql-hackers@postgresql.org; Mon, 06 Jul 2015 15:21:28 +0000 Received: from intern.anarazel.de (p5DDC66D4.dip0.t-ipconnect.de [93.220.102.212]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 8565A860002; Mon, 6 Jul 2015 17:21:23 +0200 (CEST) Date: Mon, 6 Jul 2015 17:21: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: <20150706152123.GK8902@alap3.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> <27532.1436195680@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27532.1436195680@sss.pgh.pa.us> X-Pg-Spam-Score: -4.9 (----) 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-06 11:14:40 -0400, Tom Lane wrote: > BEGIN; > CREATE TABLE test (i int primary key); > INSERT INTO test VALUES(-1); > \copy test from /tmp/num.csv with csv > COMMIT; > SELECT COUNT(*) FROM test; > > The COUNT() correctly says 11 rows, but after crash-and-recover, > only the row with -1 is there. This is because the INSERT writes > out an INSERT+INIT WAL record, which we happily replay, clobbering > the data added later by COPY. ISTM any WAL logged action that touches a relfilenode essentially needs to disable further optimization based on the knowledge that the relation is new. > We might have to give up on this COPY optimization :-(. A crazy, not well though through, bandaid for the INSERT+INIT case would be to force COPY to use a new page when using the SKIP_WAL codepath. > I'm not sure what would be a safe rule for deciding that we can skip > WAL logging in this situation, but I am pretty sure that it would > require keeping information we don't currently keep about what's > happened earlier in the transaction. It'd not be impossible to add more state to the relcache entry for the relation. Whether it's likely that we'd find all the places that'd need updating that state, I'm not sure. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers