swapping relfilenodes (was: Re: locks in CREATE TRIGGER, ADD FK) - Mailing list pgsql-hackers

From Andrew - Supernews
Subject swapping relfilenodes (was: Re: locks in CREATE TRIGGER, ADD FK)
Date
Msg-id slrnd41s49.2a3u.andrew+nonews@trinity.supernews.net
Whole thread Raw
In response to locks in CREATE TRIGGER, ADD FK  (Neil Conway <neilc@samurai.com>)
Responses Re: swapping relfilenodes (was: Re: locks in CREATE TRIGGER,  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
On 2005-03-23, Neil Conway <neilc@samurai.com> wrote:
> - swap the relfilenodes of the old and temporary heap relations

While discussing this one further on IRC, I noticed the following:

Everywhere I could find that currently replaces the relfilenode of a
relation does so while holding an AccessExclusive lock, and assumes that
this is sufficient to ensure that the old relfilenode can be killed when
the transaction commits. This is not correct.

Example:
 - backend A begins a serializable transaction - backend B truncates a table (and commits) - backend A, still in the
sametransaction, accesses the truncated table
 

Currently backend A sees the truncated table as empty, which is obviously
not right. This is obviously related to any attempt to weaken the locking
on other operations that modify relfilenodes, because doing it right implies
a mechanism to defer the removals past the commit of the modifying
transaction and up to the point where the old data can no longer be seen by
a live transaction.

-- 
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services


pgsql-hackers by date:

Previous
From: Neil Conway
Date:
Subject: Re: locks in CREATE TRIGGER, ADD FK
Next
From: Bruce Momjian
Date:
Subject: Re: locks in CREATE TRIGGER, ADD FK