pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: emil@iggland.com, pgsql-bugs@lists.postgresql.org, Surafel Temesgen <surafel3000@gmail.com>
To: David Christensen <david.christensen@crunchydata.com>
Subject: Re: BUG #17141: SELECT LIMIT WITH TIES FOR UPDATE SKIP LOCKED returns wrong number of rows
Date: Wed, 11 Aug 2021 16:07:09 -0400
Message-ID: <202108112007.evylbmzueapg@alvherre.pgsql> (raw)
In-Reply-To: <17141-913d78b9675aac8e@postgresql.org>

On 2021-Aug-11, PG Bug reporting form wrote:

> BEGIN; 
> SELECT * FROM queue
> ORDER BY task DESC
> FETCH FIRST 1 ROWS WITH TIES
> FOR UPDATE SKIP LOCKED;
> /* Some work to be done here */
> COMMIT;
> 
> select version();
> PostgreSQL 13.3, compiled by Visual C++ build 1914, 64-bit
> 
> Expected result Worker 1: (580), (580), Actual result Worker 1: (580), (580)
> Expected result Worker 2: (480), (480), Actual result Worker 2: (480)

Ouch, we already saw this actually:
https://postgr.es/m/16676-fd62c3c835880da6@postgresql.org
The problem is that the first worker locks the first (480) row (even
though it does not return it), so the second worker skips it due to SKIP
LOCKED.

I have this on my list of things to look at, but it's not at the top
yet sadly ...

-- 
Álvaro Herrera





view thread (11+ messages)  latest in thread

Message-ID: <202108112007.evylbmzueapg@alvherre.pgsql>
Permalink:  ../202108112007.evylbmzueapg@alvherre.pgsql/
Also on:    postgresql.org/message-id/202108112007.evylbmzueapg@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@alvh.no-ip.org, surafel3000@gmail.com, david.christensen@crunchydata.com
  Subject: Re: BUG #17141: SELECT LIMIT WITH TIES FOR UPDATE SKIP LOCKED returns wrong number of rows
  In-Reply-To: <202108112007.evylbmzueapg@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox