Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x2Ui8-005nfp-0C for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Sep 2026 14:16:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x2Ui6-007CCT-2x for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Sep 2026 14:16:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x2Ui6-007CCK-1x for pgsql-hackers@lists.postgresql.org; Fri, 04 Sep 2026 14:16:06 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x2Ui3-00000002vO5-22F5 for pgsql-hackers@lists.postgresql.org; Fri, 04 Sep 2026 14:16:06 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-c169ae1cb26so407503266b.1 for ; Fri, 04 Sep 2026 07:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788531362; x=1789136162; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=1qXJHc2cvBh8MU3+Ln8m/BUzLJRW9m8/dKy8TzQeIKk=; b=Q2fYmxi+1MNp4jpB/pCkBWISRGVbURbGkdByig+WH+OpTDHZokx1Jo3sDJoBvX1N6G YpIHSCT252Pr9uWl7JfgUzeOdC53AEEmPV8gfQOTmV53x/WHOjn8q761zDVjBTds9Ksc or36BcWkPQD34bFK9l/wC2v9ap2GJPxLIFs92YX3rFciVGS9lDyvje8aERKg9EkqwDbD xgEyKZoPcopfFhbRsLr5NsL0U38/VcEHccBv2CwiMhJodnvPDzQGAQJ+WqDKRuE24PpH /SMN1Zh+hNiTy89fQtC9UIVlHrwFIGF9SUDoG7zMvQzxYlD5SIOE2fDLGZ/WmvdUn1h3 7NHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788531362; x=1789136162; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1qXJHc2cvBh8MU3+Ln8m/BUzLJRW9m8/dKy8TzQeIKk=; b=bW0KrjrqAhF275ckwSCXUDUpy28odbMI1EItdcyh5w9tbO4nTCd+zIp0akE3lXdy07 lfLsaH6dXKer1J2aRyRVGxTrWMzBHZCGNx5zbQiGi7EPqD0yRp3Dj++Gxsu+xMqrlm8O dT0znTtzWilI50gSosQikgcW+T+YBAUjJQgqr8CXt06wiIE4Lkm4PYGBVrJsJtYYGbxt hrxBIxVcvtb0XfSFI8+fVs+w2DJkk5sT6hp//qvRumOap9O+sUcZZ9AiJcFgyXeWwG7k pk1aB1nYCkK8UThu4s8TpglGsJKoPwotjagFaYzcJY/g4d+J0uhcrOvM/FiIvhzk5MJL 7jAA== X-Gm-Message-State: AFuF++nhYmSD5xWo13/ycXvJnIqBUAoQEXHUgbSY5gBHV9ATuQhaDtqd 8VnX8UzW236bcyDri8HtGgUXc2vHYyGVa4Q+t95dom0ry7DVRf8BoUGbNB0Y82lM8FM= X-Gm-Gg: AYBFou0ccdx9HD/LMiT++n2Ltwzy80mUW6kSuLzT3Gl7MQwVN4DG5i1uTql7itdpipL 05hbJfUSy4lDrF5C3GT6C/iDSjjCErfI5lHIxfX/QtGKbmJMVnJIr+jtHyIH3BeHeTUT66rt8m7 tWW4peMyWqxwMofa1KfILOjfescuUR+Gf+egWx1OETmi8JAoGIAKnFoRCcOHh6++TbUNpYbfTPJ MWhvS2LxpQpOzcqIijUPBBLzlnL7lzbFhBkEW5JXskksI+YquzvyvzUpunY1kKkhsqEk3ChxHEk rfSM5pXuzqca+1tF/jtU3k9UwAzNmwm/h9zXRopQF2CuJNnrQWmKYV8UP/WhZZXn8vNkvdRTNh+ 0apaY4abqa5/Q22EuBq8OjhERorI+pT9qvd1u82Y4U98BTW83HpZMbriWIrkXYv+HeXEOYopWpE D8TD1oHgwvNwYqWU7n5mx6dPueYvZQcZYMWQWWAIBCRP6hnfG9pwxfu5yLJZkoGnFp/sSLfuXus bmg X-Received: by 2002:a17:907:72d2:b0:c25:f7db:4be9 with SMTP id a640c23a62f3a-c2610474cfcmr230983166b.15.1788531362188; Fri, 04 Sep 2026 07:16:02 -0700 (PDT) Received: from [192.168.23.224] ([81.200.10.246]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c260d575fccsm119811466b.37.2026.09.04.07.15.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Sep 2026 07:15:59 -0700 (PDT) Message-ID: <63b17868-7040-42bd-a85c-858a502253a9@gmail.com> Date: Fri, 4 Sep 2026 17:15:58 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Deadlock detector fails to activate on a hot standby replica To: Xuneng Zhou Cc: pgsql-hackers@lists.postgresql.org, Fujii Masao , JoongHyuk Shin References: <44c24dcf-5710-410f-b1b6-d10b315f3d51@postgrespro.ru> <5c50d50c-5a9c-4a9e-9592-183cf4de1c80@postgrespro.ru> <52971629-dcda-4687-90c8-bbba3ce05636@postgrespro.ru> <7e4f2244-4fd8-4f30-9f61-d1087e4b3292@gmail.com> Content-Language: en-US From: Vitaly Davydov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Xuneng Zhou, > * The caller must already be registered as the shared buffer's > + * BM_PIN_COUNT_WAITER. > This line of comment for PinCountWaiterCheckReadyForCleanup in v8 > seems not accurate to me. RegisterPinCountWaiter() explicitly permits > the shared bit BM_PIN_COUNT_WAITER to be absent. Agreed, thank you. Your edits to the comment for PinCountWaiterCheckReadyForCleanup() look great. > The invariante seems to be: Assert(PinCountWaitBuf == bufHdr); > This process owns the logical cleanup wait for this buffer. Yes, this invariant is checked in PinCountWaiterCheckReadyForCleanup(). > Updated this, and extended the commit message like we discussed > earlier though it might not get used at the end. Thank you very much for such an excellent commit message. Prior to it we discussed to unite the explanation in one single paragraph. It seems, I did poorly and I missed the description of changes. Your commit looks very descriptive and complete. One note about the commit message is the combining of words with a hyphen. I see, that hot-standby appears in commit messages, but the hyphen in buffer-pin, recovery-conflict or startup-progress seems excessive. I'm not sure, but the commit title ("Fix premature wakeups...") might suggest that the wakeups are being prevented entirely, rather than fixing how they are handled. > The timeout para in that message is basically a summary of the first email > in this thread. I am not that familiar with it and too tired to proof-read it. > Can you do me a favor? The paragraph looks technically sound and explains the core issue in detail. Previously, a hang could occur after just a single premature wake-up. This is now stated clearly. While interference from multiple active timeouts can lead to more complex behavior, the fundamental problem remains unchanged. > Just wondering whether we need a test for it. I have a test for issue reproduction that is attached to the first email and the patch in [1] where test/recovery/t/031_recovery_conflict.pl was updated to reproduce the issue. But it uses log_startup_progress_interval to activate a premature wakeup. There is an opinion in [2] that log_startup_progress_interval behaviour may be changed, that invalidates the test. I have no ideas about other simple alternative ways to trigger premature wakeups. May be, injection points may help. There is a concern in [2] that changes to the behavior of log_startup_progress_interval will invalidate the test. I cannot think of other simple ways to trigger premature wakeups. Perhaps injection points could help here. [1] https://www.postgresql.org/message-id/CAHGQGwFED52rRVb_a%3DbVSdbOA%3DoARVOUyw381GC_6uKoNWJAtQ%40mail.gmail.com [2] https://www.postgresql.org/message-id/CAHGQGwHh5j%3DsG3AZh%3DHyuXtPM6cmymp6MJkRAMJcJUyN2qpHrQ%40mail.gmail.com With best regards, Vitaly Davydov vitprof@gmail.com (aka v.davydov@postgrespro.ru) vitcpp@mail.ru