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 1wF3st-004hzU-1u for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2026 05:42:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wF3ss-006PyG-2Y for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Apr 2026 05:42:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wF3ss-006Py8-1g for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2026 05:42:54 +0000 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wF3sq-000000022J0-25fm for pgsql-hackers@lists.postgresql.org; Tue, 21 Apr 2026 05:42:53 +0000 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-479d68a9063so501377b6e.0 for ; Mon, 20 Apr 2026 22:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776750172; cv=none; d=google.com; s=arc-20240605; b=MosnVrgsFrgPWGIguENmS0f4KguYK1ZtNnMNzeXCnG0ObCwZnLbDMldoSIJ0XHG9KT iSVnMr3LAPeBxYuQVKzs3DzggXBqPzI8h508v4LInmIgGgZM2kmn0UsTlvxavbygdbBy 7+6ld7xDTw+uclt8gM78Z5gpjpuMXMTP/WEF2R8YSqBR5lvVrxi7lItQmwNZeG9ZsJsp T4R98FLonHSCpaEQAh/dSmPIy5WWUC8EhQtPUbjNek4Xdc8KOE74wdQejk820vk1ao3d C8J3PH2KOiP+xzlhdAXa3FE5VrPQ4239RNYGns+nBaqXY0Lu+bLOQr2++16sPXDz/rnq I6ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EhWmdM5HYYkAwH7RXhjLpHNJcCRTkiEsNsXRyJ7CSPY=; fh=UtQqBGubi+9gZdI82wPdnL52lxGy+rGPPzICHEYnDy8=; b=glrFOuMJbqP4JuABbu4sX2Q3ZU0uMdfohZsez4BA0a24gyOuXDB4hl+pFowC6x/ZMc y6Z5ssxd1CIuti5VOVvSFJy7VVfoz8tirBQc4Kb2sKNsJjzTMD98VgU02SC8YW7USCZz odMwC/oDbe/fox2cQrJuw4y4d4Cohs21jMNpNZu8A4i2vX1sDX7+pL4HcLb2MCzPSMAs QznOqdlYvIpdBvA0f1qjJ3Kmwij+BKj9tUHcFKjwtbpjy/aBJdGRwxiYBSLZhdjuBvwW gzoVuS7kGGS4cnCB1fQ63cLXVUxX8xmt5udJvTNJvT9g+xeBpw8qmJ5bxUa+Xg6J8Z7s x7Iw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776750172; x=1777354972; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EhWmdM5HYYkAwH7RXhjLpHNJcCRTkiEsNsXRyJ7CSPY=; b=NCPjZBe3K0Hhsx/QMBRil7B9CLnOiud/pURWqK6FySXHT/cnG88AMa32yKgZueoDy5 DqQqt+B0EsZziUbrpGU2WivoEwqIWT+yiQc7De/+sIRL5eywgeT0gLJMWXDkQVzqQZB8 KioOItDyMfe2Eo7Se9oQg8AjkWaA+6D8ZnuQz3HvIqln4PGuV8UGJkWZAC9ubV3mQgV2 JHELs+XwBwpJzJ5nb6uODXopgoz0v963qzxGLa28aQJ5vdFCpCylHYAnTReWEqIlBYbx y3bArlpcXQgWvmkV7RxpXxoGV9ZoT/OXeHPJHkc52e9zA/v0ylQ6ea86tRK+LAwFZo9G AmLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776750172; x=1777354972; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=EhWmdM5HYYkAwH7RXhjLpHNJcCRTkiEsNsXRyJ7CSPY=; b=jhq3bkXSE4hggRUBNNwu/WcuLk2qr+3o/cdxw2DcQMEEpBjeOccUCevWsfvxnF7j16 Sqeh5OwG+y2EJ2hgZpHMwfIIfuCJrvVErP0o0X/h4tYJjnyspI/tTNkoeu3toBy2WvSS VKUL/yMKkofdCMv1A6tUnImgrwrxQPGlPSWYI1JXzlkfMBvN6JBdQYe6AAWBae3k77B9 wJp2hEEBgNKKxcI4vo3HlzDaShMZBXAQOu4vCDf7dktCUnsJgKnwWHL2SBanMPxID1A6 gzzWhNBv5loJ8X5kG61AGhuNZoi75H+BY8vbDaOjX7kYn3qS1DOX2IW+kKOVW3Ocyyb9 3udw== X-Gm-Message-State: AOJu0Yysuy0onNRETsIO04+bhasK1QP7qZX7BSVtWx8SJaXsaArbdsOa rulvL/kNW/u4JbYlJLJ2OAP+vHV/8F8kNLxPM6NH+VR/obxEOtyHn6QUVDin0W3vJ3Bv1XSRihg N7XYGqVGwLxp6rX21aF9BuIM8bPNy7gM= X-Gm-Gg: AeBDieudtzGv8XotM4msqEWwg+qtFhv2+Oasf/2z6IuhGvv9qFMAbdd2wE8TExwsen2 WiZ3DtDdmDPHd/iX/b+zS6AnsFHeirWwQxGQ1JhBruesndN8PyzHwbQmiz6cVjw+vdkF7EbTlHw NHYKWF088n0YlQyla0lxI4qXvjTR7Tw386ZNmdSSEImserrBfuZ6DDVfUtt4BVdBqoMB8AgHp1h e1MI/9hWvmc91aOYEKjTwVCwb/vzasFIH12NAuWI57mXaGf7rp8csmspj+emzaXcHjSrqnBCwMw ig5vB1Hqvv1yVOh/7VtK9lYiL1vEDs/raKlO8OHnV96PsxWn3d6Y X-Received: by 2002:a05:6820:2083:b0:67b:bd89:90ed with SMTP id 006d021491bc7-69462f0f2c2mr9675027eaf.41.1776750171604; Mon, 20 Apr 2026 22:42:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Fujii Masao Date: Tue, 21 Apr 2026 14:42:38 +0900 X-Gm-Features: AQROBzBQfhze9ZbyAmOHAzyMv8EgeokeFK493i1g9INqxL9vSyrRJioGTQ078FE Message-ID: Subject: Re: [PATCH] Prevent repeated deadlock-check signals in standby buffer pin waits To: JoongHyuk Shin Cc: "pgsql-hackers@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Apr 19, 2026 at 2:47=E2=80=AFPM JoongHyuk Shin wrote: > > In ResolveRecoveryConflictWithBufferPin(), when deadlock_timeout fires, > the function sends RECOVERY_CONFLICT_BUFFERPIN_DEADLOCK and returns. > The caller (LockBufferForCleanup) loops back, sets up another deadlock_ti= meout, > and the signal gets sent again every interval. > > The lock-conflict path had the same problem and was fixed in 8900b5a9d59a > by adding a second ProcWaitForSignal() after the deadlock-check signal. > The buffer-pin path was left with an XXX comment asking "should we fix th= is?". > > The attached patch applies the same fix: after sending the deadlock-check > signal, reset got_standby_deadlock_timeout and call ProcWaitForSignal() > so the startup process waits for UnpinBuffer() rather than looping > and re-signaling. > > Patch attached. Thanks for the patch! LGTM. Since this change improves recovery-conflict behavior rather than fixing a = bug, it doesn't seem to need backpatching and we may need to wait until v20 development opens (probably July) before committing it. While reading the patch and ResolveRecoveryConflictWithBufferPin(), I also noticed that got_standby_delay_timeout is not initialized to false before enabling the timeout. This is unrelated to the patch, and I think it is harmless in the current code, but would it be better to initialize it there= , as we already do for got_standby_deadlock_timeout? if (ltime !=3D 0) { + got_standby_delay_timeout =3D false; timeouts[cnt].id =3D STANDBY_TIMEOUT; timeouts[cnt].type =3D TMPARAM_AT; timeouts[cnt].fin_time =3D ltime; Regards, --=20 Fujii Masao