Re: lazy vxid locks, v3 - Mailing list pgsql-hackers

From Robert Haas
Subject Re: lazy vxid locks, v3
Date
Msg-id CA+TgmoY03sEwAHQpxrBjf+RWzGkD1QhX0rM-5wMaBZ0ssLECCg@mail.gmail.com
Whole thread Raw
In response to Re: lazy vxid locks, v3  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: lazy vxid locks, v3
List pgsql-hackers
On Sun, Jul 31, 2011 at 8:32 PM, Jeff Davis <pgsql@j-davis.com> wrote:
> fpLocalTransactionId is redundant with the lxid, and the explanation is
> that one that they have different locking semantics. That looks
> reasonable, and it avoided the need for the careful ordering while
> starting/ending a transaction that was present in v2.

...which I became fairly convinced was in fact insufficiently careful.

> However, it also looks like you're using it for another purpose:
>
> In VirtualXactLockTableCleanup():
> /*
>  * If fpVXIDLock has been cleared without touching fpLocalTransactionId,
>  * that means someone transferred the lock to the main lock table.
>  */
> if (!fastpath && LocalTransactionIdIsValid(lxid))
>
> Is the "&& LocalTransactionIdIsValid(lxid)" a guard against calling
> VirtualXactLockTableCleanup twice? Can that happen? Or is it just
> defensive coding to avoid making an additional assumption?

lxid there is just a local variable storing the value that we
extracted from fpLocalTransactionId while holding the lock.  I named
it that way just as a mnemonic for the type of value that it was, not
intending to imply that it was copied from MyProc->lxid.

> PS: In the recent sinval synch patch, you had a typo: "If we haven't
> catch up completely". Other than that, it looked good.

Ah, thanks.  Will fix.

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


pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: Access to current database from C-language function
Next
From: Heikki Linnakangas
Date:
Subject: Re: Hot standby and GiST page splits (was Re: WIP: Fast GiST index build)