Re: RFC: Making TRUNCATE more "MVCC-safe" - Mailing list pgsql-hackers

From Robert Haas
Subject Re: RFC: Making TRUNCATE more "MVCC-safe"
Date
Msg-id CA+TgmobyePApYcYfyBq-g6jNQcN-QXwLpPhr68i6s=T0KCKYAw@mail.gmail.com
Whole thread Raw
In response to Re: RFC: Making TRUNCATE more "MVCC-safe"  (Noah Misch <noah@leadboat.com>)
Responses Re: RFC: Making TRUNCATE more "MVCC-safe"  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
On Wed, Mar 7, 2012 at 7:49 AM, Noah Misch <noah@leadboat.com> wrote:
> On Tue, Mar 06, 2012 at 08:36:05AM -0500, Robert Haas wrote:
>> On Tue, Mar 6, 2012 at 5:43 AM, Noah Misch <noah@leadboat.com> wrote:
>> >> Well, consider something like CLUSTER. ?It's perfectly OK for CLUSTER
>> >> to operate on a table that has been truncated since CLUSTER's snapshot
>> >> was taken, and no serialization anomaly is created that would not have
>> >> already existed as a result of the non-MVCC-safe TRUNCATE. ?On the
>> >> other hand, if CLUSTER operates on a table that was created since
>> >> CLUSTER's snapshot was taken, then you have a bona fide serialization
>> >> anomaly.
>> >
>> > Core CLUSTER does not use any MVCC snapshot. ?We do push one for the benefit
>> > of functions called during the reindex phase, but it does not appear that you
>> > speak of that snapshot. ?Could you elaborate this example?
>>
>> Imagine this:
>>
>> - Transaction #1 acquires a snapshot.
>> - Transaction #2 creates tables A, inserts a row into table B, and then commits.
>> - Transaction #1 tries to CLUSTER A and then select from B.
>>
>> The only serial execution schedules are T1 < T2, in which case the
>> transaction fails, or T2 < T1, in which case the row is seen.  But
>> what actually happens is that the row isn't seen and yet the
>> transaction doesn't fail.
>
> For the purpose of contemplating this anomaly, one could just as well replace
> CLUSTER with GRANT, COMMENT ON TABLE, or any other command that operates on a
> table, correct?
>
> I agree this test case is good to keep in mind while designing, but we could
> well conclude not to bother improving it.

All true.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: CLUSTER VERBOSE (9.1.3)
Next
From: Tom Lane
Date:
Subject: Re: Scaling XLog insertion (was Re: Moving more work outside WALInsertLock)