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 1hcGul-0007Wn-K8 for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2019 22:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hcGuj-0001TM-7X for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2019 22:12:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hcGui-0001TF-1m for pgsql-hackers@lists.postgresql.org; Sat, 15 Jun 2019 22:12:44 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hcGue-0007r1-3A for pgsql-hackers@lists.postgresql.org; Sat, 15 Jun 2019 22:12:43 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 9232B21583; Sat, 15 Jun 2019 18:12:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sat, 15 Jun 2019 18:12:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hintbits.com; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=mesmtp; bh=k84dvUOjtRoaabBEo3fp+V9RMpxUd+4Rbb23TEhQgSk=; b=nEEiSxx2QhSY E5OgszfeFpIQu9oceKDOPnLs57ixVJs01ngqoyPJPnCtbLvCn07KcKThOovpFTD2 DH7mu7HL60rQmV0QobQ1nme+YDg3RC1H4fdmkMNHvyjtFudjXlfAhN4gtytyY4Gb 6wD4h22Vv/wYyGLMcFCz9ghraLTE7Qc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=k84dvUOjtRoaabBEo3fp+V9RMpxUd+4Rbb23TEhQg Sk=; b=COXidBftCU9WdstHlgBFPeE3ePM2ylxk3q2C2xxW1DUTwCUDTV2uDUAW4 9bR4z+Nne5W/TyRfrpfb0sjj71iaO9lphTUKg+Dg16eo5Che7idWSegxDLUGFcO+ plMWVpdG0jLUVJ/23u94un+aXbPuTRC3e3hg8bXmmLEMCLUXNuFwCgGNwQ4Bby8w uagX0fqyEXzg1AkmrfSxcZcjhz0KlwBHvFuA95NT5tRCUBqB9vZJArBFR7JwNPSI To02J5zbdJn3fEMyCSW0zMqvdgS+EM0pUvN9Dnp6JeOFbVDzyXmpIMElnozhGBYm C76JuIg/vS1w+/5EsAfn//bIIe2cQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudeigedguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegtggfuhfgjfffgkfhfvffosehtqh hmtdhhtdejnecuhfhrohhmpefqlhgvkhhsihhiucfmlhhiuhhkihhnuceorghlvgigkhes hhhinhhtsghithhsrdgtohhmqeenucfkphepleegrddufeegrdekkedrudeffeenucfrrg hrrghmpehmrghilhhfrhhomheprghlvgigkheshhhinhhtsghithhsrdgtohhmnecuvehl uhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from izzy.fritz.box (unknown [94.134.88.133]) by mail.messagingengine.com (Postfix) with ESMTPA id EBC9F380073; Sat, 15 Jun 2019 18:12:35 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: pgsql: Avoid spurious deadlocks when upgrading a tuple lock From: Oleksii Kliukin In-Reply-To: <20190615170133.GA28251@alvherre.pgsql> Date: Sun, 16 Jun 2019 00:12:21 +0200 Cc: Tom Lane , pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <5EF8408A-46E6-409A-96A7-DC2C27F36235@hintbits.com> References: <20190615170133.GA28251@alvherre.pgsql> To: =?utf-8?Q?=C3=81lvaro_Herrera?= X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera wrote: > On 2019-Jun-14, Alvaro Herrera wrote: >=20 >> I think there are worse problems here. I tried the attached = isolation >> spec. Note that the only difference in the two permutations is that = s0 >> finishes earlier in one than the other; yet the first one works fine = and >> the second one hangs until killed by the 180s timeout. (s3 isn't >> released for a reason I'm not sure I understand.) >=20 > Actually, those behaviors both seem correct to me now that I look > closer. So this was a false alarm. In the code before de87a084c0, = the > first permutation deadlocks, and the second permutation hangs. The = only > behavior change is that the first one no longer deadlocks, which is = the > desired change. >=20 > I'm still trying to form a case to exercise the case of = skip_tuple_lock > having the wrong lifetime. Hm=E2=80=A6 I think it was an oversight from my part not to give = skip_lock_tuple the same lifetime as have_tuple_lock or first_time (also initializing it to false at the same time). Even if now it might not break anything in an obvious way, a backward jump to l3 label will leave skip_lock_tuple uninitialized, making it very dangerous for any future code that will = rely on its value. > The fact that both permutations behave differently, even though the > only difference is where s0 commits relative to the s3_share step, is = an > artifact of our unusual tuple locking implementation. Cheers, Oleksii=