Re: [HACKERS] CIC and deadlocks - Mailing list pgsql-patches

From Pavan Deolasee
Subject Re: [HACKERS] CIC and deadlocks
Date
Msg-id 2e78013d0704102329t19110847r819369df13cf7d30@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] CIC and deadlocks
List pgsql-patches

On 4/1/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Good point.  I'm envisioning a procarray.c function along the
lines of
        bool TransactionHasSnapshot(xid)
which returns true if the xid is currently listed in PGPROC
and has a nonzero xmin.  CIC's cleanup wait loop would check
this and ignore the xid if it returns false.  Your point means
that this function would have to take exclusive not shared lock
while scanning the procarray, which is kind of annoying, but
it seems not fatal since CIC isn't done all that frequently.


When I looked at the code, it occurred to me that possibly we are
OK with just taking shared lock on the procarray. That means that
some other transaction can concurrently set its serializable snapshot
while we are scanning the procarray. But that should not harm us:
if we see the snapshot set, we wait for the transaction. A transaction
which is setting its serializable snapshot NOW, can not see the
tuples that we did not index, isn't it ?

A patch based on the discussion is attached.

Thanks,
Pavan

--

EnterpriseDB     http://www.enterprisedb.com
Attachment

pgsql-patches by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: [HACKERS] Full page writes improvement, code update
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] CIC and deadlocks