Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i04fK-00081q-Ig for pgsql-general@arkaria.postgresql.org; Tue, 20 Aug 2019 13:59:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i04fJ-0004Xa-68 for pgsql-general@arkaria.postgresql.org; Tue, 20 Aug 2019 13:59:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i04fI-0004RI-4K for pgsql-general@lists.postgresql.org; Tue, 20 Aug 2019 13:59:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i04fF-0006HF-Gv for pgsql-general@lists.postgresql.org; Tue, 20 Aug 2019 13:59:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x7KDx7RO005515; Tue, 20 Aug 2019 09:59:08 -0400 From: Tom Lane To: =?UTF-8?Q?Toni_C=C3=A1rdenas?= cc: pgsql-general@lists.postgresql.org Subject: Re: =?UTF-8?B?Q2FuIFNFTEVDVCDigKYgTk9XQUlUIOKAnGRlYWRsb2Nr4oCdPw==?= In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Toni_C=C3=A1rdenas?= message dated "Tue, 20 Aug 2019 12:53:50 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5513.1566309547.1@sss.pgh.pa.us> Date: Tue, 20 Aug 2019 09:59:07 -0400 Message-ID: <5514.1566309547@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?Toni_C=C3=A1rdenas?= 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