Skip site navigation (1) Skip section navigation (2)

Re: locks in CREATE TRIGGER, ADD FK

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: locks in CREATE TRIGGER, ADD FK
Date: 2005-03-23 14:45:40
Message-ID: 87d5tq7757.fsf@stark.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Neil Conway <neilc(at)samurai(dot)com> writes:

> Tom Lane wrote:
> > It isn't 100% MVCC, I agree.  But it works because system catalog
> > lookups are SnapshotNow, and so when another session comes and wants to
> > look at the table it will see the committed new version of the pg_class
> > row pointing at the new relfilenode file.
> 
> If by "works", you mean "provides correct transactional semantics", then that
> simply isn't true. Not making CLUSTER and similar DDL commands MVCC compliant
> isn't the end of the world, I agree, but that doesn't make it correct, either.

I think he means it works because it doesn't matter whether the serializable
transaction sees the old table or the new one. As soon as the CLUSTER commits
the serializable transaction can start using the new one since it's
functionally identical to the old one (at least it's supposed to be, Tom
points out it isn't).

> > If you want to complain about MVCC violations in CLUSTER, think about
> > the fact that it scans the table with SnapshotNow, and therefore loses
> > rows that are committed-dead but might still be visible to somebody.

Ouch. That's, er, a problem. I guess currently it's fine for any transaction
using READ COMMITTED but it's already wrong for serializable transactions. And
it'll be wrong for READ COMMITTED if CLUSTER is changed not to take an
exclusive lock. 

-- 
greg


In response to

pgsql-hackers by date

Next:From: Greg StarkDate: 2005-03-23 14:47:45
Subject: Re: swapping relfilenodes (was: Re: locks in CREATE TRIGGER,
Previous:From: Juan Pablo EspinoDate: 2005-03-23 14:26:32
Subject: Re: Another history question

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group