pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Toni Cárdenas <toni@tcardenas.me>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Can SELECT … NOWAIT “deadlock”?
Date: Tue, 20 Aug 2019 09:59:07 -0400
Message-ID: <5514.1566309547@sss.pgh.pa.us> (raw)
In-Reply-To: <CAH+FFSwaesY0N-DfiHiFJtoSkowSoDNCxQt52Dy7b7UNU9tt9A@mail.gmail.com>
References: <CAH+FFSwaesY0N-DfiHiFJtoSkowSoDNCxQt52Dy7b7UNU9tt9A@mail.gmail.com>

=?UTF-8?Q?Toni_C=C3=A1rdenas?= <toni@tcardenas.me> writes:
> Imagine the same `SELECT ... NOWAIT` statement, which returns rows R1 and
> R2, is run from concurrent connections S1 and S2.

>  1. S1 obtains and locks R1.
>  2. S2 obtains and locks R2.
>  3. S1 tries to obtain R2, but it's locked by S2.
>  4. S2 tries to obtain R1, but it's locked by S1.
>  5. The lock on R1 is released due to S1 failing.

> The question is whether step 4 can actually happen between step 3 and 5, or
> else steps 3 and 5 are performed atomically with respect to concurrent
> selects.

I see no reason to think that 3 and 5 would appear to be atomic.

			regards, tom lane





view thread (3+ messages)

Message-ID: <5514.1566309547@sss.pgh.pa.us>
Permalink:  ../5514.1566309547@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5514.1566309547@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, toni@tcardenas.me
  Subject: Re: Can SELECT … NOWAIT “deadlock”?
  In-Reply-To: <5514.1566309547@sss.pgh.pa.us>
  References: <CAH+FFSwaesY0N-DfiHiFJtoSkowSoDNCxQt52Dy7b7UNU9tt9A@mail.gmail.com> <5514.1566309547@sss.pgh.pa.us>

* 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