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 1wPfft-000wK2-1S for pgsql-bugs@arkaria.postgresql.org; Wed, 20 May 2026 12:05:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wPffr-007Vdf-06 for pgsql-bugs@arkaria.postgresql.org; Wed, 20 May 2026 12:05:19 +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 1wPffq-007VdX-2V for pgsql-bugs@lists.postgresql.org; Wed, 20 May 2026 12:05:19 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wPffp-00000000U3R-1HU4 for pgsql-bugs@lists.postgresql.org; Wed, 20 May 2026 12:05:18 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-479dd56d016so3805309b6e.3 for ; Wed, 20 May 2026 05:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1779278716; cv=none; d=google.com; s=arc-20240605; b=MDC3GfWPbUoOklIt9a59xuh0gAX3knxoL+h+LG7MfJKaeA5c8RBd3t16Ev4fcD2snA wmMdodYnWHdUaybBH5aMxhgBGjd9AskUOMVeam32UIC9E0FuDGGnR1/8TcB2TA7nxq0U O0P+giWV60aFNd3Xne4UzKLzOE9jyX/2oNpt8Esi+HvBqlNVkXK5nJT9AJDRITRvvX+R 4THaQl2xUdFK8ceaPsPZSZvqZIq9FyWo8H1PsgHY1Ai7xH0qvtEZ/VeNNDPlkZ+GwcCZ Ky7GynI5edKCGhDaBXW/xHV6P1NgOQ8PFeYgv39ZAYp1yRsARe4y8/oRXkq2bRy6/Vuj sXsQ== 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=1cyG7E86vF+NkD9KK1nyQweZA7W3eTHPQlBfH/sAMoA=; fh=eFFNkTIt+PcSpSBxfl6KcLEG6chPS83WlhJwAC0qNi8=; b=id8gH0nhji5LalhM1CMxPIw1L+6UDuyqimeLzGap9u4ie5cnD4alIxM+0eoMrqyctH TI8HlB/Ry6WsO6nnp49vy+h7ULbBxUtH60PwR8SHtPBwEtO3pURd84rxPGh5TBuNXoXr lSzw+sKO692MKp52rezFLNxGrXrV70Q6xJwP1lRd3QyWkrF5MNOtRPVs/4ve5pV+NoeP IYJK3itjbFgTOmRwGusdP7YdcVyc1qSWLaf6af+tg2nxiebz+Bk/qkbCGaWoAV9fMUC9 EZr4u0RuDSDhwrBhV5J1DnH0RjbHmh/RWZJ6dGh+91oY6qIdq3CUCrG4gFD7V+OuhI+z Bxlw==; 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=1779278716; x=1779883516; 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=1cyG7E86vF+NkD9KK1nyQweZA7W3eTHPQlBfH/sAMoA=; b=hFg3k37gYcWwEYych/rVZpnvNq2HgCFIT+yn6jWM/S+iTtiHRzDx2plsn0410+8B7e FVHcqSRfWAYC2n/+ZwonJKUdGSDdTiq+HNNst6aQ4PjqhTlJs3/nEf/zGIpUAuHw+9KT tHRkEZ8yqySzE64ma3vi1bjpoBa48EmtVB7740GLTaGSvQCn6URfwe94+oGuWB8MkHpw vdeWiCCPSQgKypQfx36BwUaoqEdIKsymCJW9wyR5gX7WiJjp78XwVbso/EfYKSlC94xu +DJYvq4EcNEq0gH5hQ5rVOQj5iP1ryBE77tCKrvZ2hto+I6IuzxfHQZ1DteHg3S+6Alm USjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779278716; x=1779883516; 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=1cyG7E86vF+NkD9KK1nyQweZA7W3eTHPQlBfH/sAMoA=; b=Ui9GHtFh+DNDNs9bElXlmMU/24cXR8vmp/IZe6lB7o1N9tHRGSqTMIUr3y7Heags9n alZIjewPvbIcvCNOayMGCwfEH/QNYa0pdXMMtFoBPtTqI+nWGQvIbUkMGbHtgxlKwLBe zm0qARevNUKEHFZrC7CwlbAoHc2JjJix0RA7C4htD8buP930/UyQ1PeZy+BCPY6GkExD bRvtp6BgOJiSH6Y2nhmcVyvsuMf1EXmXJ7v0t5+IBLCjcyKRyAVcHhABChVKIvw3n+nx YLSyyvBncN8XhFATjg94rNyECjnRnW34+NBbmcPDvOkLWpXAtzZC3X+QcMJLDHope9xd G3Mw== X-Forwarded-Encrypted: i=1; AFNElJ8H/LVk8/mnoGXkG6WFvy6W8Mht8AJsAqBJUl4WozlnApygvGrnjpksPpgHfFceeQyoX66qbXocbkaT@lists.postgresql.org X-Gm-Message-State: AOJu0YwO0g54fxaNxh2laSRmWmGvmtgrVXXsg3fkQR2bjmyIL8aKL8nu mhyhgzem9LX/Z8jwkLxraXiASD7uWgXyWuySlBRbpFq03AAjb4cDztHHlFk+9+1vdRWcHzXR6H4 8zvCzG4kHLLa0PJFHZDbibB5FyPGAXTI= X-Gm-Gg: Acq92OH3cKrxBG+z2txLUv9PI3xhT6ZX3AUX7dgWsqZpII2Cu4n3VeG5QbY8jS8qTzu blc3yruAMog4K1AMbLO3FQN9aqw/YvQawXT7bN76ZjelZXXFO19EpBSpRkoa83Kjjr9T+gxe+60 N/6p/5EzvgwvfKahhZoXpbsgt2+XELHciTpyG6ORFXiqQIKCkLW5D3RbADmbY39YqqsMS8/ZTIg To+StkheAkpN8ziKSnC2YW3gGLm5lrVGL8ajVTSwq0/Ro5kglay9NiiNp6oxeAOUkPf2jgf2X5L jBxZvozg2bXW44o78WymZrsCk7BXODrWWvRk4J52tg== X-Received: by 2002:a05:6820:3101:b0:699:f575:54fb with SMTP id 006d021491bc7-69c94375ca8mr14634245eaf.34.1779278716527; Wed, 20 May 2026 05:05:16 -0700 (PDT) MIME-Version: 1.0 References: <19488-d7ccfca2bf6b74b0@postgresql.org> In-Reply-To: From: Fujii Masao Date: Wed, 20 May 2026 21:05:03 +0900 X-Gm-Features: AVHnY4IXDLftBAan2C2VNOaxWf1Cs8GBnmM-vWu_2jO50OEt_NrAdMLl-4wnNr4 Message-ID: Subject: Re: BUG #19488: Standby connection fails after dropping on login event trigger enabled always To: Alexander Korotkov Cc: Ayush Tiwari , kyzevan23@mail.ru, pgsql-bugs@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 Wed, May 20, 2026 at 8:31=E2=80=AFPM Alexander Korotkov wrote: > > On Wed, May 20, 2026 at 1:03=E2=80=AFPM Fujii Masao wrote: > > On Wed, May 20, 2026 at 1:37=E2=80=AFPM Ayush Tiwari > > wrote: > > > Thanks for the report and the precise repro. > > > > +1 > > > > > Attached patch adds a RecoveryInProgress() check to skip the cleanup > > > branch on standbys. > > > > Thanks for investigating this issue and for the patch! > > The patch looks good to me. > > > > > I think this needs to be backpatched too. > > > > Yes. Seems this should be backpatched to v17, where login event trigger= s > > were introduced. > > I've added a tap test reproducing the bug. I'm going to push and > backpatch this to v17 if no objections. +# Wait for the standby to replay the CREATE/DROP catalog state. At +# this point the standby's pg_database.dathasloginevt is still true. +$primary->wait_for_replay_catchup($standby); + +# A new connection to the standby exercises EventTriggerOnLogin()'s +# cleanup branch. With the RecoveryInProgress() guard, that branch is +# skipped on the standby and the connection succeeds. Without it the +# session aborts with a FATAL about AccessExclusiveLock. Probing the +# flag itself via safe_psql is what triggers the cleanup path. +is( $standby->safe_psql( + 'postgres', + "SELECT dathasloginevt FROM pg_database WHERE datname =3D 'postgres'"), + 't', + 'standby accepts connection and reports dangling dathasloginevt'); The test looks unstable to me. wait_for_replay_catchup() may connect to the primary to obtain the flush LSN, which could cause dathasloginevt to become false before the subsequent safe_psql() call on the standby. Regards, --=20 Fujii Masao