Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nDbgp-0002mt-Of for pgsql-general@arkaria.postgresql.org; Sat, 29 Jan 2022 00:34:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nDbgo-0004cT-Md for pgsql-general@arkaria.postgresql.org; Sat, 29 Jan 2022 00:34:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nDbgo-0004cK-AO for pgsql-general@lists.postgresql.org; Sat, 29 Jan 2022 00:34:02 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nDbgl-0000FH-Cf for pgsql-general@lists.postgresql.org; Sat, 29 Jan 2022 00:34:01 +0000 Received: by mail-qt1-x82f.google.com with SMTP id h25so5760263qtm.1 for ; Fri, 28 Jan 2022 16:33:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to; bh=APIpv9ZQDQF5FDnWlw3jKu62jDoXJJy0pYbpG6KZa70=; b=K+/6b66BFJMNhKYrpjSqkUhvszitW87ZYYD/Z+OFMgH5jbCzDlCr1oiMoTQYoTMhvC pvpq9+248eKbHPrDQMftlIpoliL9JfYcHhZdcjmz4/szxUBJy6prqOq0hdFljdgMGQh4 ZXrV3iOo1ZxjdvBeh97E++4R3hxhBdtMAKOG+sKiQtOgzVkcS92jt6jw+psijdWFg8wK dbc3C4HnBJj9jC+rigRdbWIHHR7C+UNZKFiPAjQGt2HTtm/irBXEkkDa06EtyeEeAICx Ajv6tSTsSlfP3sIzL5Gn2GXFyqtSl0gIlWxSH9YP+BDdA2DUY2PYQdqMdKwyI78GcbUC y0YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to; bh=APIpv9ZQDQF5FDnWlw3jKu62jDoXJJy0pYbpG6KZa70=; b=fUR+TOqfMukhAfIGJgTRmakWoKiipTO0f5hXMsu/2VIs+GDT4g09/dN3ZE6xQA/dc0 j5w2Bced5NkOfD2OBdW6hzi89X7/Fr5xDq0OJi6vJyhNI6uJPdEB/bzLrBzUifKA8Ebb 4Qa0ZYQRJLuMwhkGtn9MKjhxOS8d4XmVr6+ggbxSkZcW81mpn7GaSFD8GyMz5tTdlR1F B8L/39Lz5mg2CcuremRerKXH5vtotrMFDcclhHv0ZH53H/TjfEr7+ieRmJ+ePuL4d/MI RIKz9HTXsl4FNJ4FasdAeQpM6TQ2bzryouWsAg+yrTLiJsvrx7qc6IZB01ZjiYpK2Ew5 lZ8A== X-Gm-Message-State: AOAM532iTJd2+FkGqWu26eq14EnLRtAxG9sg7odIXQ9OaccBStRumqpZ x32jm2Lyocewk+uGgy8qm8D1d1l7IAU5mA== X-Google-Smtp-Source: ABdhPJzyalxaXuoUslEsw/Ekkm/qB9JY0iA0JpxOAk7izp6Nj0s+B9dha5CdRna0CT5mXcyyUr0/4w== X-Received: by 2002:ac8:578e:: with SMTP id v14mr8146513qta.345.1643416437122; Fri, 28 Jan 2022 16:33:57 -0800 (PST) Received: from [192.168.2.100] (pool-72-79-19-93.nwrknj.east.verizon.net. [72.79.19.93]) by smtp.gmail.com with ESMTPSA id e9sm3379069qtx.37.2022.01.28.16.33.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jan 2022 16:33:56 -0800 (PST) Content-Type: multipart/alternative; boundary="------------eV7px5b8oXPrrWQpmBDz4XuK" Message-ID: <1b2e1d4e-298e-86ef-5875-0c89719d48f1@gmail.com> Date: Fri, 28 Jan 2022 19:33:55 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: pg_try_advisory_lock is waiting? Content-Language: en-US To: Tom Lane Cc: pgsql-general@lists.postgresql.org References: <54e6a2bc-3546-88c7-0382-c74f23e4b668@gmail.com> <2858894.1643414894@sss.pgh.pa.us> From: Mladen Gogala In-Reply-To: <2858894.1643414894@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------eV7px5b8oXPrrWQpmBDz4XuK Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/28/22 19:08, Tom Lane wrote: > I doubt it. I think the FOR UPDATE in the sub-select is blocked > because the other session has an uncommitted update on the row > it wants to lock. This command won't reach the pg_try_advisory_lock > call until that row lock comes free. Yes, I figured it out, but pg_try_advisory_lock returned TRUE even without "FOR UPDATE" clause in the subquery. Shouldn't it return false because it can't lock the row until the uncommitted update finishes? Regards -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------eV7px5b8oXPrrWQpmBDz4XuK Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
On 1/28/22 19:08, Tom Lane wrote:
I doubt it.  I think the FOR UPDATE in the sub-select is blocked
because the other session has an uncommitted update on the row
it wants to lock.  This command won't reach the pg_try_advisory_lock
call until that row lock comes free.

Yes, I figured it out, but pg_try_advisory_lock returned TRUE even without "FOR UPDATE" clause in the subquery. Shouldn't it return false because it can't lock the row until the uncommitted update finishes?

Regards

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------eV7px5b8oXPrrWQpmBDz4XuK--