Re: CLUSTER FREEZE - Mailing list pgsql-hackers

From Andres Freund
Subject Re: CLUSTER FREEZE
Date
Msg-id 20131223115359.GA19795@alap2.anarazel.de
Whole thread Raw
In response to Re: CLUSTER FREEZE  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: CLUSTER FREEZE
List pgsql-hackers
On 2013-12-22 20:45:02 -0500, Robert Haas wrote:
> I suspect we ought to extend this to rewriting variants of ALTER TABLE
> as well, but a little thought is needed there.  ATRewriteTables()
> appears to just call heap_insert() for each updated row, which if I'm
> not mistaken is an MVCC violation - offhand, it seems like a
> transaction with an older MVCC snapshot could access the table for
> this first time after the rewriter commits, and fail to see rows which
> would have appeared to be there before the rewrite. (I haven't
> actually tested this, so watch me be wrong.)  If we're OK with an MVCC
> violation here, we could just pass HEAP_INSERT_FROZEN and have a
> slightly different flavor of violation; if not, this needs some kind
> of more extensive surgery quite apart from what we do about freezing.

Yes, rewriting ALTER TABLEs certainly aren't MVCC safe. I thought that
was documented, but apparently not.
I am not sure it can be fixed easily using the tricks CLUSTER plays,
there might be nasty edge-cases because of the changes in the column
definition. Certainly not a trivial project.

I think we should leave ALTER TABLE as a completely separate project and
just improve CLUSTER for now. The practical impact of rewriting ALTER
TABLEs not freezing is far smaller, because they are very seldomly
performed in bigger databases.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: nested hstore patch
Next
From: Robert Haas
Date:
Subject: Re: preserving forensic information when we freeze