From: | Peter Geoghegan <pg(at)heroku(dot)com> |
---|---|
To: | Andres Freund <andres(at)2ndquadrant(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: INSERT...ON DUPLICATE KEY LOCK FOR UPDATE |
Date: | 2013-09-18 05:54:38 |
Message-ID: | CAM3SWZS==VF5-OOEbt+gjWsnZFxH-=UZLx91RzWvDfiy9xK-9Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Sep 17, 2013 at 6:20 PM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
>> I agree that unpredictable deadlocks are bad. I think the fundamental
>> problem with UPSERT, MERGE, and this proposal is what happens when the
>> conflicting tuple is present but not visible to your scan, either
>> because it hasn't committed yet or because it has committed but is not
>> visible to your snapshot. I'm not clear on how you handle that in
>> your approach.
>
> Hm. I think it should be handled exactly the way we handle it for unique
> indexes today. Wait till it's clear whether you can proceed.
That's what I do, although getting those details right has been of
secondary concern for obvious reasons.
> At some point we might to extend that logic to more cases, but that
> should be separate discussion imo.
This is essentially why I went and added a row locking component over
your objections. Value locks (regardless of implementation)
effectively stop an insertion from finishing, but not from starting.
ISTM that locking the row with value locks held can cause deadlock.
So, unfortunately, we cannot really discuss value locking and row
locking separately, even though I see the appeal of trying to. Gaining
an actual representative notion of the expense of releasing and
re-acquiring the locks is too tightly coupled with how this is handled
and how frequently we need to restart. Plus there may well be other
issues in the same vein that we've yet to consider.
--
Peter Geoghegan
From | Date | Subject | |
---|---|---|---|
Next Message | Sergey Konoplev | 2013-09-18 06:12:24 | System catalog bloat removing safety |
Previous Message | Sameer Thakur | 2013-09-18 05:41:25 | Re: pg_stat_statements: calls under-estimation propagation |