Re: BUG #16676: SELECT ... FETCH FIRST ROW WITH TIES FOR UPDATE SKIP LOCKED locks rows it doesn't return

From: David Christensen <david(at)endpoint(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16676: SELECT ... FETCH FIRST ROW WITH TIES FOR UPDATE SKIP LOCKED locks rows it doesn't return
Date: 2020-10-20 16:18:20
Message-ID: C0CF9D56-0392-43D2-8577-5F8A01AF2B56@endpoint.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On Oct 20, 2020, at 9:23 AM, David Christensen <david(at)endpoint(dot)com> wrote:
>
>> On Oct 20, 2020, at 9:16 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>
>> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
>>> On 2020-Oct-19, David Christensen wrote:
>>>> Maybe splitting LockRows into two nodes, one for locking and one for
>>>> emitting unlocked nodes then interleaving Limit in between? (Or only
>>>> doing something along these lines for this admittedly narrow use case.)
>>
>>> I was having a similar idea, but the main reason I don't think it's a
>>> good fix is that we can't backpatch such a change to pg13.
>>
>> Um, why not? I don't have a position yet on whether this is a good way
>> to fix it; but if we did do it, AFAICS the only thing we'd have to be
>> careful of in v13 is not renumbering existing NodeTag values.
>>
>> If your concern is just that EXPLAIN plans will look different, the same
>> could be said of David's other proposal.
>
> If we can determine the scope to which these different nodes might be used and make it so it still uses the existing node structure for most existing cases (i.e., maybe an additional parameter to create_lockrows_plan or similar) then that might work; AFAIK, this is the first time we’ve had to consider this sort of thing (though I do wonder if there might be something in window functions which might bump into this sort of issue).
>
> I’m working on an isolation test to formalize this failure, which I can do as a separate patch if we want to have this prior to implementing a fix.

Enclosed is the (currently failing) isolation test for the expected behavior.

Attachment Content-Type Size
0001-Add-isolation-test-for-FETCH-FIRST-ROW-WITH-TIES-FOR.patch application/octet-stream 2.7 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message 1250kv 2020-10-20 16:25:36 ECPG bug: "unterminated quoted identifier"
Previous Message Tom Lane 2020-10-20 15:23:07 Re: BUG #16679: Incorrect encoding of database name