Re: change in LOCK behavior

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tomas Vondra <tv(at)fuzzy(dot)cz>, Thom Brown <thom(at)linux(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: change in LOCK behavior
Date: 2012-10-11 18:23:56
Message-ID: CA+U5nMLkHys0NJNhu7YkOPGGVKhPFqZ=24-cyUvtGHsxhL6DBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11 October 2012 18:22, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

>> I suggested a way to automatically trigger a second snapshot. I think
>> that would be acceptable to backpatch.
>
> If it worked, I might be amenable to that, but it doesn't. You can't
> trigger taking a new snapshot off whether we waited for a lock; that
> still has race conditions, just ones that are not so trivial to
> demonstrate manually. (The other transaction might have committed
> microseconds before you reach the point of waiting for the lock.)
> It would have to be a rule like "take a new snapshot if we acquired
> any new lock since the previous snapshot". While that would work,
> we'd end up with no performance gain worth mentioning, since there
> would almost always be some lock acquisitions during parsing.

So where's the race?

AFAICS it either waits or it doesn't - the code isn't vague on that
point. If we wait we set the flag.

The point is that lock waits are pretty rare since most locks are
compatible, so triggering a second snap if we waited is not any kind
of problem, even if we waited for a very short time.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-10-11 18:36:00 Re: change in LOCK behavior
Previous Message Magnus Hagander 2012-10-11 18:22:44 Re: September 2012 commitfest