Re: MultiXacts & WAL - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: MultiXacts & WAL
Date
Msg-id Pine.OSF.4.61.0606172113310.312139@kosh.hut.fi
Whole thread Raw
In response to Re: MultiXacts & WAL  (paolo romano <paolo.romano@yahoo.it>)
Responses Re: MultiXacts & WAL  (paolo romano <paolo.romano@yahoo.it>)
List pgsql-hackers
On Sat, 17 Jun 2006, paolo romano wrote:

> The original point I was moving is if there were any concrete reason 
> (which still I can't see) to require Multixacts recoverability (by means 
> of logging).
> Concerning the prepare state of two phase commit, as I was pointing out 
> in my previous post, shared locks can safely be released once a 
> transaction gets precommitted, hence they do not have to be made 
> durable.

No, it's not safe to release them until 2nd phase commit.

Imagine table foo and table bar. Table bar has a foreign key reference to 
foo.

1. Transaction A inserts a row to bar, referencing row R in foo. This 
acquires a shared lock on R.
2. Transaction A precommits, releasing the lock.
3. Transaction B deletes R. The new row inserted by A is not visible to 
B, so the delete succeeds.
4. Transaction A and B commit. Oops, the new row in bar references R that 
doesn't exist anymore.

Holding the lock until the true end of transaction, the 2nd phase 
of commit, blocks B from deleting R.

- Heikki


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: oprofile results for stats collector test
Next
From: Josh Berkus
Date:
Subject: Re: [PERFORM] Sun Donated a Sun Fire T2000 to the PostgreSQL