Re: COPY TO returning empty result with parallel ALTER TABLE

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: 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: COPY TO returning empty result with parallel ALTER TABLE
Date: 2014-11-04 19:33:07
Message-ID: 545929F3.5030408@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general pgsql-hackers


On 11/04/2014 01:51 PM, Tom Lane wrote:
> Bernd Helmle <mailings(at)oopsware(dot)de> writes:
>> --On 3. November 2014 18:15:04 +0100 Sven Wegener
>> <sven(dot)wegener(at)stealer(dot)net> 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?

Yes, that seems like an outright bug.

cheers

andrew

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sven Wegener 2014-11-04 19:33:32 Re: COPY TO returning empty result with parallel ALTER TABLE
Previous Message drickner 2014-11-04 19:21:05 BUG #11873: home and end keys do not move the selected cell in results grid

Browse pgsql-general by date

  From Date Subject
Next Message Sven Wegener 2014-11-04 19:33:32 Re: COPY TO returning empty result with parallel ALTER TABLE
Previous Message Alejandro Carrillo 2014-11-04 19:09:16 Re: Tablespace limit feature

Browse pgsql-hackers by date

  From Date Subject
Next Message Sven Wegener 2014-11-04 19:33:32 Re: COPY TO returning empty result with parallel ALTER TABLE
Previous Message Alvaro Herrera 2014-11-04 19:32:52 Re: WAL replay bugs