Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XlkKL-0003fG-Lr for pgsql-general@arkaria.postgresql.org; Tue, 04 Nov 2014 20:03:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XlkKL-00082I-4A for pgsql-general@arkaria.postgresql.org; Tue, 04 Nov 2014 20:03:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XlkKJ-000807-G4; Tue, 04 Nov 2014 20:03:39 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XlkKE-0006td-Ak; Tue, 04 Nov 2014 20:03:38 +0000 Received: from intern.anarazel.de (ip-80-113-20-130.ip.prioritytelecom.net [80.113.20.130]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 4377FE0969; Tue, 4 Nov 2014 21:03:30 +0100 (CET) Date: Tue, 4 Nov 2014 21:03:28 +0100 From: Andres Freund To: Tom Lane Cc: Bernd Helmle , Sven Wegener , pgsql-hackers@postgresql.org, pgsql-general@postgresql.org, pgsql-bugs@postgresql.org Subject: Re: [BUGS] [HACKERS] COPY TO returning empty result with parallel ALTER TABLE Message-ID: <20141104200328.GR28295@alap3.anarazel.de> References: <12887.1415127083@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12887.1415127083@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 2014-11-04 13:51:23 -0500, Tom Lane wrote: > Bernd Helmle writes: > > --On 3. November 2014 18:15:04 +0100 Sven Wegener > > wrote: > >> I've check git master and 9.x and all show the same behaviour. I came up > >> with the patch below, which is against curent git master. The patch > >> modifies the COPY TO code to create a new snapshot, after acquiring the > >> necessary locks on the source tables, so that it sees any modification > >> commited by other backends. > > > Well, i have the feeling that there's nothing wrong with it. The ALTER > > TABLE command has rewritten all tuples with its own XID, thus the current > > snapshot does not "see" these tuples anymore. I suppose that in > > SERIALIZABLE or REPEATABLE READ transaction isolation your proposal still > > doesn't return the tuples you'd like to see. > > Not sure. The OP's point is that in a SELECT, you do get unsurprising > results, because a SELECT will acquire its execution snapshot after it's > gotten AccessShareLock on the table. Arguably COPY should behave likewise. > Or to be even more concrete, COPY (SELECT * FROM tab) TO ... probably > already acts like he wants, so why isn't plain COPY equivalent to that? Even a plain SELECT essentially acts that way if I recall correctly if you use REPEATABLE READ+ and force a snapshot to be acquired beforehand. It's imo not very surprising. All ALTER TABLE rewrites just disregard visibility of existing tuples. Only CLUSTER/VACUUM FULL do the full hangups to keep all the necessary tuples + ctid chains around. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general