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 1hcC4g-0005cp-N0 for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2019 17:02:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hcC3h-0003w6-8r for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2019 17:01:41 +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 1hcC3g-0003vz-Tn for pgsql-hackers@lists.postgresql.org; Sat, 15 Jun 2019 17:01:41 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hcC3e-0004ec-76 for pgsql-hackers@lists.postgresql.org; Sat, 15 Jun 2019 17:01:39 +0000 Received: by mail-qt1-x841.google.com with SMTP id i34so917181qta.6 for ; Sat, 15 Jun 2019 10:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=qDrG7blF+4ga2R0wqTCxmQ0OqjFeni29NhP1CXSMcPw=; b=sTQ89B1TzUV4/hT6gUhw0DfrnIyBiZ9libK5flZCgOd0KhpysaSbst8j9i7bvGrgb6 sUBJjz2DPob62ZudlsbYf2reL8kmF+m3WbaUJLm+J/oHAXGg3C7VC/q6NSC2gCXExWoB yfAanpwlpwWADk47lma0H9pSxxoji1J7bh6OqRG9QwypbVCuMY6j6lZeViG60TkTwHDx 8OhON9e9itZMZInLtlEv7H0nvrusZ3dtmuD/ApDlVYB2HbVlfgkujDz6LuhzMepFJquM JMEhcacl5TR4LldQ8zSl2U+E9i1oqcJau9gpE+NbanZrbIrSe540wwEGRrI2EIYJbR5G skOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=qDrG7blF+4ga2R0wqTCxmQ0OqjFeni29NhP1CXSMcPw=; b=YEh+VY5ijtBvtStJsqlBmAW8qSdqhUSW4kiAB5UhJIDmMH79xmcHxLK5UeNY7KNXdc MlAKTCmSWQ6JQD7iuhf0R6OfLzpZgmBT97OBk3ZWKQv5jzD5HQgbP0il+LuwJgHVEgTR 0yEsTExN5FAkFhtSMrsg91naBUg7+Oap7ObjtuREg38BdDZ123yKguEwlNc/XJvfRoLl GJiHIH+hTlvfxnc/092ZwcMe/qCzws5fDCQ5up1R/ATv+d8bFDK2AAlkgjuhwa94dYVz iDvtS7Cn4dDtpu4xAPbPllu13PkdgWNebO4xWht5txGsDpocGiB5Eh2OjdYs6LSq3zPs BTnQ== X-Gm-Message-State: APjAAAXVd7Lu1lwF5mCeogBagThbsD16E+kzrDFwJs7GZiRtS6a5o4MH D4OQg8tDJUtQjcZFX4LuO7xoC5Wofx9eAA== X-Google-Smtp-Source: APXvYqwipk02Hnbxls54F5ZWmdLNfX57XKzy4sxsyq3CcoCg70o1jRzCtALhiAvAXhSpHzj9ib8RAg== X-Received: by 2002:a0c:f78d:: with SMTP id s13mr13264327qvn.156.1560618097424; Sat, 15 Jun 2019 10:01:37 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([177.154.139.203]) by smtp.gmail.com with ESMTPSA id j66sm3650942qkf.86.2019.06.15.10.01.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 15 Jun 2019 10:01:36 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id AA4C3120A21; Sat, 15 Jun 2019 13:01:33 -0400 (-04) Date: Sat, 15 Jun 2019 13:01:33 -0400 From: Alvaro Herrera To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org, alexk@hintbits.com Subject: Re: pgsql: Avoid spurious deadlocks when upgrading a tuple lock Message-ID: <20190615170133.GA28251@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190615034337.GA24560@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jun-14, Alvaro Herrera wrote: > 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.) 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. I'm still trying to form a case to exercise the case of skip_tuple_lock having the wrong lifetime. 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. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services