Re: serializable lock consistency

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: fgp(at)phlo(dot)org
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: serializable lock consistency
Date: 2010-12-19 16:01:08
Message-ID: AANLkTinkRccH_8MUGU31SvxncTdgVwJjL67V2PeCPgQc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 19, 2010 at 9:12 AM, Florian Pflug <fgp(at)phlo(dot)org> wrote:
>> On Sun, Dec 19, 2010 at 4:02 AM, Florian Pflug <fgp(at)phlo(dot)org> wrote:
>>> Note that it's sufficient to check if B can see the effects of the
>>> *latest* locker of T. If it can see those, it must also see the
>>> effects of any previous locker. But because of this, B cannot
>>> distinguish different lock strengths on T - even if A locked T
>>> in exclusive mode, some transaction A2 may lock T in shared mode
>>> after A has committed but before B inspects T.
>>
>> This seems to point to a rather serious problem, though.  If B sees
>> that the last locker A1 aborted, correctness requires that it roll
>> back B, because there might have been some other transaction A2 which
>> locked locked T and committed before A1 touched it.  Implementing that
>> behavior could lead to a lot of spurious rollbacks, but NOT
>> implementing it isn't fully correct.
>
> Certainly seems serios. How on earth did I manage to miss that one, I
> wonder :-(
>
> If only shared locks are invovled, the patch probably works correctly,
> though, since they don't remove all traces of previous lockers, they
> merely add themselves to the multi-xid holding the lock. That'd also
> explain why my concurrency test-suite didn't trip over this. So we may
> only need to do what you propose for exclusive locks.

I'd be willing to bet, without checking, that if the previous shared
locker is no longer running by the time the next one comes along, we
don't create a multixact in the first place. And even if it does,
what about this: exclusive lock, commit, shared lock, abort.

As unhappy as I am with the present behavior, this cure sounds like it
might be worse than the disease.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-12-19 16:02:48 Re: Re: Proposed Windows-specific change: Enable crash dumps (like core files)
Previous Message Magnus Hagander 2010-12-19 15:49:15 Re: Re: Proposed Windows-specific change: Enable crash dumps (like core files)