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 1wRtI5-002mVK-31 for pgsql-hackers@arkaria.postgresql.org; Tue, 26 May 2026 15:01:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wRtI3-004gvr-2R for pgsql-hackers@arkaria.postgresql.org; Tue, 26 May 2026 15:01:56 +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 1wRtI3-004gvi-1a for pgsql-hackers@lists.postgresql.org; Tue, 26 May 2026 15:01:56 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wRtI2-00000001X4G-2FJu for pgsql-hackers@lists.postgresql.org; Tue, 26 May 2026 15:01:56 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-369002b26f4so6190424a91.3 for ; Tue, 26 May 2026 08:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779807712; cv=none; d=google.com; s=arc-20240605; b=B0XQbk42sycJuRjHxU+zBUmuweK75Z+93cTqATXGEzE2lS0NtBQWX5Cef9uGVZ81Cs KjQOK2xVC+zU1U9NRQ60vTyfZUDIPIwWI1ux5NHNxfNI+IMtDpDP9sTbzps5N1YRvzUI nsdAD0QkUVgocmBXz2qb5INcWxUd4Df3CizMelgxxvq3AR/8l4mnYiK1n7VV1jdOEKNL 99VPf33pWUbbYTD6DewjVD3DBa6xcwyFg+lyqH6sMl5ZAMRP7Wxzs6sXRhRsgGej2hPp yLgzYwmtjsm0DDh08cn+MswglO+Gcb52H9DYVIhZL5MYN5a3XSUy2KcuTA8WkR66oTnb u+mA== 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=szcRhzOa7hqDcbhTxPA9PNAjcUM68+eusmksDZki8e0=; fh=TWOW6pcG+2B//k4gBj/tL1xzyXmOsQD52mW4JZgqdwY=; b=BGLh0//2TO7uApKD5YjOeCMxnHkMOG/WOZzCMIAs+shQOYnLllMM8RhmUe4mTHm3Yj g2m6rc0ze5Swpp6rs5P302reSjs3mXeh6v8CP67ME1/af67WuZgtKka0SJ3/NySbbkYa i7sGjKBR2VoOout8MozuUmXCpxT9z6HPqDC1eyrTeQDwSWsh9EeFUxke5trdjMlKFbKF /Y2gaTNgiO7RUTkRUAeq1GzN/IkFodsIjkji2Ed7WR3GFoNOZ6seL5mbLTxSAFuWkCPW EMGsv92usaiyZhb8kbeWqx/majDwLYE+UUtT2pW93Dkoh84xOi7BjnfM0hrHoOHbYxfz wgWw==; 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=1779807712; x=1780412512; 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=szcRhzOa7hqDcbhTxPA9PNAjcUM68+eusmksDZki8e0=; b=PXvXHuiueuIUv0mOKU7rcInKVN/hMvnnFVKz7/z8u6XpHzQbJaD2IbQL63xvSOMWur wWkPgzKkDNnda1FVoduOmHscrkjehWC16lu3VqNWQOqC3BejuL/P9uPjguSvr3YoOlKO oSUG4lI1KYb9dyE2Io1U5M6cEgray5lnhCHT0vaAzerGL4CWDb0uPsYv6ASqMJkTA0UN rkkA3+NDSxoOXHybi8tFz4FJZ7e70zgWGbuVQpwSEsXHKVNEIqmGG/OIEdLQHIbmOt9y c5t5F7C1V4xRLqh1oMyQbtU4+rzMLhqxDHX8ZfYu2IfciLOZZHvSUz3tTW9i+3eLU1BL Grow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779807712; x=1780412512; 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=szcRhzOa7hqDcbhTxPA9PNAjcUM68+eusmksDZki8e0=; b=p5MK3GnGSsnhnBJxReT031e+iRPuP/5hKgs9FPcjyS72dzeebRr5NzpIf14JLj/xr7 TKKjBS5l7AzZB6QOGjLKvURkWIxkLvC7cohlVjsMoer+/Gdc/0iBLR1z+ZnZy1vi7VUI Ux2lGR72Iv7E5bhIx1nAg2pjs+LfGVPrgSFMNw97n0rU+78p7brjjkULBTzldfk8JcpY laj4QZhgUsuAdwczk18GBrm5JeggYrEwjMdJGhykvhuoYFJxWfg5io3Y20GceT+op9xX /Oz3hxvqwDbqCSy6EO6i+yj6ixjHlGWcN3k9RgJ6CD04AGEJIc1hQ4vALiqrtG132SeC O4vw== X-Gm-Message-State: AOJu0YzKOGigXyIBLlBy+WE3+jU+OEOu+ouvjNfXGtvXR5nSlFzkbj/0 Uz3VRj8oTZYm8/tPAM3jx0YvCSBLb9NTBXfOUNYOSq30a4vWaS9woTG3Hu8QeLfHo/nwXC89vKR GEsH2+qRVLJcZwp82pM/w7MqLUkqPtJ3UTaoqgoU= X-Gm-Gg: Acq92OH1uFbvMn5mQKl0Mdd/Jzaz7OAUY0BjCDTJeGoJrNnYe0HoMrCJUt3H/C55lVw mCWzvR0XYX6/4r8k3nxUE0UHEaF4TrHRIYFAaAh5O0KwOCG29m8NR4w7coTSoDItj2IZ695uUMJ wdmpGrgwYZWhXjSSFWLCak946681XAmAkQzYdFPyV9EB6PPlj3R6bGj0k30m6X/76Dd9mY3GdJI 13Ixy4qAav2WLzbzMhKxYuaWEtwM1D5hq0+e/1t+W7UFP70vYY281FHrXNAwzsS5Pn+MLZyYyg1 +j09LAxxo6RbMGvhRPosvOwu6IynzSJjaK/n4kbCf5vUiU5wu3az X-Received: by 2002:a17:90a:dfce:b0:368:ed92:6f6 with SMTP id 98e67ed59e1d1-36a676f0280mr15912152a91.1.1779807711163; Tue, 26 May 2026 08:01:51 -0700 (PDT) MIME-Version: 1.0 References: <44c24dcf-5710-410f-b1b6-d10b315f3d51@postgrespro.ru> <25cba756-9459-4811-aeaf-4a8715735c82@postgrespro.ru> In-Reply-To: <25cba756-9459-4811-aeaf-4a8715735c82@postgrespro.ru> From: Fujii Masao Date: Wed, 27 May 2026 00:01:38 +0900 X-Gm-Features: AVHnY4LU-QQQ2FHGrHDqvZHb7TJNu9_C604IbsThE1P4PPKsT7Ja_EGoQkgOTxM Message-ID: Subject: Re: Deadlock detector fails to activate on a hot standby replica To: Vitaly Davydov 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 Mon, May 25, 2026 at 11:20=E2=80=AFPM Vitaly Davydov wrote: > > Dear Fujii Masao, > > Thank you for the review of the patch. Based on your comments I propose > a new version of the patch. Thanks for updating the patch! + if (got_standby_delay_timeout) + SendRecoveryConflictWithBufferPin(RECOVERY_CONFLICT_BUFFERPIN); + else if (got_standby_deadlock_timeout) + { Shouldn't we break out of the loop when either got_standby_delay_timeout or got_standby_deadlock_timeout becomes true? Otherwise, the loop continues wi= th those flags still set, which could cause SendRecoveryConflictWithBufferPin(= ) to be called unnecessarily in the subsequent cycles. + if (BufferGetRefCount(buffer) <=3D 1) Should this be "BufferGetRefCount(buffer) =3D=3D 1" instead? I don't think BufferGetRefCount(buffer) should ever return 0 here. If that's correct, would it make sense to explicitly detect that case, for example: ----------------- uint32 refcount =3D BufferGetRefCount(buffer); Assert(refcount > 0); if (refcount =3D=3D 0) elog(ERROR, "buffer refcount dropped to zero while waiting for cleanup lock"); if (refcount =3D=3D 1) break; ----------------- > I also added a new tap-test as a part of the patch. I did some changes in= the > tap test to make it stable. Let me know, please, if it should be in a sep= arate > commit. Do we really need a new TAP test file for this? We already have a startup/backend deadlock test in t/031_recovery_conflict.pl. Extending the deadlock section there to cover this test case seems simpler and easier= to follow than introducing a new t/053_* test. Regards, --=20 Fujii Masao