Re: [GENERAL] Re: [HACKERS] COPY TO returning empty result with parallel ALTER TABLE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Bernd Helmle <mailings(at)oopsware(dot)de>, Sven Wegener <sven(dot)wegener(at)stealer(dot)net>, pgsql-hackers(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [GENERAL] Re: [HACKERS] COPY TO returning empty result with parallel ALTER TABLE
Date: 2014-11-04 22:18:14
Message-ID: 20002.1415139494@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2014-11-04 13:51:23 -0500, Tom Lane wrote:
>> 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.

"It doesn't fail in a non-default isolation mode" is hardly much of an
argument for this being okay in READ COMMITTED.

> 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.

Yeah, and I think that it's entirely reasonable for rewriting ALTER TABLEs
to update the xmin of the rewritten tuples; after all, the output data
could be arbitrarily different from what the previous transactions put
into the table. But that is not the question here. If the COPY blocks
until the ALTER completes --- as it must --- why is its execution snapshot
not taken *after* the lock is acquired?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bernd Helmle 2014-11-04 23:14:42 Re: [GENERAL] Re: [BUGS] COPY TO returning empty result with parallel ALTER TABLE
Previous Message Tom Lane 2014-11-04 21:40:14 Re: PostgreSQL 9.3 Segfault in "hstore_to_json" function

Browse pgsql-general by date

  From Date Subject
Next Message Bernd Helmle 2014-11-04 23:14:42 Re: [GENERAL] Re: [BUGS] COPY TO returning empty result with parallel ALTER TABLE
Previous Message memtec 2014-11-04 20:54:27 Re: Incomplete startup packet help needed

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2014-11-04 22:28:22 Re: BRIN indexes - TRAP: BadArgument
Previous Message Peter Eisentraut 2014-11-04 21:52:50 Re: pg_receivelog completion command