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 1hbzca-0008Gj-Qs for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2019 03:44:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hbzbY-0005hB-Ow for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Jun 2019 03:43:48 +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 1hbzbY-0005h4-DD for pgsql-hackers@lists.postgresql.org; Sat, 15 Jun 2019 03:43:48 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hbzbR-0004sf-1b for pgsql-hackers@lists.postgresql.org; Sat, 15 Jun 2019 03:43:46 +0000 Received: by mail-qk1-x744.google.com with SMTP id r6so3041836qkc.0 for ; Fri, 14 Jun 2019 20:43:40 -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=Yc97tjiM293pKIZRPopg9bjNvPukjqss2B8PIRDiEDc=; b=mkSKGXoB39Bn4L62NRqAHkEc1J7AJa48E8lY1MQSuAQKfDtoa06LPRCmasHWjhFXhl PMhemPWkiTAoXWnmTdow4EBZtSz9mZSWJx8eGmvZOLq4eRlCLH8ekK66Rbrfk4Q64+nz t65k9Gvty1cbeRuIAZKMXZyRGPh/N7ZlrOfJgtFCb/Z3Oufir1Zrb6f5IrQsj0zxAiew JqdfhaHLiN0ml3FWrSkXlLo/6yqr/aM0aMQ4Hw2ozOmgmHV2uGXbS8QzB/G4SnIxqlbh i2bzrG7WDtXJKymKYuXiM3kGtNYu1tddhu8p2e20EPBF9v3a+u45pD0DfA8svDiI5mnV bnXA== 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=Yc97tjiM293pKIZRPopg9bjNvPukjqss2B8PIRDiEDc=; b=Q/kucc0gYHdMZj9y5uluC0smBP8DWjZ/LZOMcELkPLnG7zeTe7oj6kgT+ezY3I17WP HTqBdV7r3PoYkpjUjMzIqTT/Mw2/jqH89wti12K+3DSo155kOpVdKWDbnYcLkIAQoAkY Us9LUAsIhvUcqnwPQmHkJOpsdG5Xb/YRbTc7mZnPFeZQhAP7ieehM6heg6VGcDWVmyTw yKHPerCs2RyI0UkschoB3us4Kv1CMGNfzU79LQpgwnhMNjPO1Aq5vWt/attTF8aAL1I3 IZJn19cSdVZj50VvotsKP9aCxkm2yDUABo7/hYctJa1K7LxGrB24bxpl7UwTRpPhbOKc 0gJQ== X-Gm-Message-State: APjAAAVrdZ04MlKf0K+VGgqRap5KFjCOMNiyz0+jYiyf4M2H8APtXBME 3Uq/G9fR/gQfBbefG9X+Kfb5Yg== X-Google-Smtp-Source: APXvYqyz/B+2Cwu8okLJZBaR/KqCkOfWkKK+tws98gF+LWm52PTJIu4hZfRQHE2wyBmSHtSvYPuSIg== X-Received: by 2002:a37:aa8e:: with SMTP id t136mr12470089qke.222.1560570220066; Fri, 14 Jun 2019 20:43:40 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([179.56.48.227]) by smtp.gmail.com with ESMTPSA id q3sm3088168qta.74.2019.06.14.20.43.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 20:43:39 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 63FCE120247; Fri, 14 Jun 2019 23:43:37 -0400 (-04) Date: Fri, 14 Jun 2019 23:43:37 -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: <20190615034337.GA24560@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="uAKRQypu60I7Lcqm" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <28491.1560526373@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2019-Jun-14, Tom Lane wrote: > I wrote: > >> Hm, I don't get that warning. Does this patch silence it, please? > > > Uh, no patch attached? But initializing the variable where it's > > declared would certainly silence it. > > BTW, after looking around a bit I wonder if this complaint isn't > exposing an actual logic bug. Shouldn't skip_tuple_lock have > a lifetime similar to first_time? 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.) I don't think I'm going to have time to investigate this deeply over the weekend, so I think the safest course of action is to revert this for next week's set. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="with_s0.spec" setup { drop table if exists tlu_job; create table tlu_job (id integer primary key, name text); insert into tlu_job values(1, 'a'); } teardown { drop table tlu_job; } session "s0" setup { begin; } step "s0_forupdate" { select id from tlu_job where id = 1 for update; } step "s0_commit" { commit; } session "s1" setup { begin; } step "s1_keyshare" { select id from tlu_job where id = 1 for key share;} step "s1_share" { select id from tlu_job where id = 1 for share; } step "s1_update" { update tlu_job set name = 'b' where id = 1; } step "s1_delete" { delete from tlu_job where id = 1; } step "s1_rollback" { rollback; } step "s1_commit" { commit; } session "s2" setup { begin; } step "s2_for_update" { select id from tlu_job where id = 1 for update; } step "s2_update" { update tlu_job set name = 'b' where id = 1; } step "s2_delete" { delete from tlu_job where id = 1; } step "s2_rollback" { rollback; } step "s2_commit" { commit; } session "s3" setup { begin; } step "s3_keyshare" { select id from tlu_job where id = 1 for key share; } step "s3_share" { select id from tlu_job where id = 1 for share; } step "s3_for_update" { select id from tlu_job where id = 1 for update; } step "s3_update" { update tlu_job set name = 'c' where id = 1; } step "s3_delete" { delete from tlu_job where id = 1; } step "s3_rollback" { rollback; } step "s3_commit" { commit; } permutation "s0_forupdate" "s1_share" "s2_for_update" "s0_commit" "s3_share" "s3_for_update" "s1_rollback" "s3_rollback" "s2_rollback" permutation "s0_forupdate" "s1_share" "s2_for_update" "s3_share" "s0_commit" "s3_for_update" "s1_rollback" "s3_rollback" "s2_rollback" --uAKRQypu60I7Lcqm--