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.98.2) (envelope-from ) id 1xF1mD-00000001OcI-1MZS for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Oct 2026 04:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xF1mA-0000000FWVj-3VuA for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Oct 2026 04:00: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.98.2) (envelope-from ) id 1xF1mA-0000000FWVb-2DzF for pgsql-bugs@lists.postgresql.org; Fri, 09 Oct 2026 04:00:06 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xF1m8-00000001AXG-06Ht for pgsql-bugs@lists.postgresql.org; Fri, 09 Oct 2026 04:00:06 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso61241915e9.3 for ; Thu, 08 Oct 2026 21:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791518403; x=1792123203; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=mCgHIHrCUbqL037odqQ2ZrepEcCsefqrglX4313RY+A=; b=D4ryBHrJKRDao+0NlZE80YJXei+cy50/Koz3BcMZmEPo4A+1QGpaX5pHT308CET1PE 6eFEzEp9GhrBtQVozHgPin0Z8KAETXUWKG4HgFcwPuXxQTjo0xGOcvCxUl7BGvIZbfZI l8opfPs87B14GNxaXRN1Qf6Y4kNo4YkGvecXmhS3eoeGYc9p0vXc1gGJehD8dTJfSua0 fHYpRfM8c9R6h9ytdGuwMOz/BV7Wg27/K71uVDZg0YVFZoD9i4VvDCtnebcA2Jyj4ywj 0bkQop1GNip6QKuFwV37DxdR60kF/soLSH6FEL9o5Xw1xtASfCLZbazikthyMgSDMbGp /0mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791518403; x=1792123203; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mCgHIHrCUbqL037odqQ2ZrepEcCsefqrglX4313RY+A=; b=q5iOUJgm+qSDjrgWpEh4zOC+wqiEOzhmbo+a5uown3S6CjY68Xc/DKmEPR4D2AKBAa +nD+z4+WOU+LNqezTXg1KsqiuZPSdL9rglTKOCQ5bfewHr7Z20A5onyPiaMwvEtXHvl6 96usG17o0z0MpI7hCr48k0UYXLZzocmCGgLvPtIt+ZZofYIwkGGCS2yjt7ppepdE7yhk oPwdMCoTOnEIVCivopYXwBOC0KgXe6uArWQP8rZfh+FH1sNaOtpdSDkLDtOxTqItYIzP tQatGztoR+AfLUTL7gPx03iTAcNTW183U2VCTmYMHIvLjyhEjBqJUg05EWbwkNWzE50Z giaw== X-Forwarded-Encrypted: i=1; AKwUvByPqnbWbaCCDkbDQsgx0f9X0Xowb8pLztK9mS6iliB0jhsMdcfzhnaZSQLNMDuqYxmC0LGbvEZ4I/vc@lists.postgresql.org X-Gm-Message-State: AFuF++kvNYrbS2MukmFQ4HnAQrCTF7qj7F8KzzMDanrs89A7Gja+1YjH 6BWdd9Fjwaj+XQ25RCwEuFhZSqtLTmRsyAIF245e1+BBIukrprqwuEJ3 X-Gm-Gg: AYBFou0c2Gv2EzTX+kqcYY7a9kixgzuwAwK/1/2c9F8mz/8W0ym/oAAkaBNxB/U5WHW UGStaBo83YmnVcH2PBXaLKhh5VsaidX6vKJSUNjTP8ZopRaCs+PkgMqNEKhOepPOdIp79ly5ZGA dpsr6Nm25tYG0BNa1q+n8nLUaho3Vvo3iOFqrsAF26664Dv/xwPWenPshcXcOj86juvhC2OKGTA jbLR+bmvk59eYCod8VTIpOMF2z9pia67beua9fMWcY4brRObaZfSdn/TLTCU1XB1jpbRIIuHQOb nAdVOSLVCltsNHZmjHYz/XWuJeXHVPv/xgJn7B9Ws/vLVgIOqJV0EaH4tA0vo4v5xCE4P5Itbo3 IiMPzWp4QvQJWmeRi94ezFuHD+rL4DIfwmM3n3STMmTuI+rGUJklwRc33G88lI5zHfiJyXKfWGs HezlFhNiOkH/98YRz1CIOjv8SA03rvWyiSbszET9MmOUMGRw7iUCSpIqJU2Yc29vvS3iihDYyWD g== X-Received: by 2002:a05:600c:8105:b0:4a1:83f0:7c8a with SMTP id 5b1f17b1804b1-4a18e4433d6mr8405285e9.1.1791518402417; Thu, 08 Oct 2026 21:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.120.141]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48dba1be42esm1607555f8f.5.2026.10.08.21.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Oct 2026 21:00:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------d7jP7po4IC7oQreSXibCBRKJ" Message-ID: <09561429-50c1-4d06-a262-300c7a845175@gmail.com> Date: Fri, 9 Oct 2026 07:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19488: Standby connection fails after dropping on login event trigger enabled always To: Alexander Korotkov , Ayush Tiwari Cc: Fujii Masao , kyzevan23@mail.ru, pgsql-bugs@lists.postgresql.org References: <19488-d7ccfca2bf6b74b0@postgresql.org> Content-Language: en-US From: Alexander Lakhin In-Reply-To: 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. --------------d7jP7po4IC7oQreSXibCBRKJ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Alexander, 25.05.2026 11:53, Alexander Korotkov wrote: > On Thu, May 21, 2026 at 2:48 PM Ayush Tiwari > wrote: >> I agree the approach you are suggesting is better. >> >> Patch looks good to me! > Thank you. I'm going to push and backpatch it if no objections. Please look at a failure of 053_standby_login_event_trigger.pl produced recently by skink [1]: [05:59:54.150](0.000s) ok 4 - no AccessExclusiveLock FATAL on standby login [05:59:59.905](5.755s) not ok 5 - primary clears dathasloginevt on next login after DROP [05:59:59.906](0.000s) #   Failed test 'primary clears dathasloginevt on next login after DROP' #   at /home/bf/bf-build/skink/REL_19_STABLE/pgsql/src/test/recovery/t/053_standby_login_event_trigger.pl line 109. [05:59:59.906](0.000s) #          got: 't' #     expected: 'f' Waiting for replication conn standby's replay_lsn to pass 0/04000060 on primary done [06:00:11.434](11.528s) not ok 6 - cleared dathasloginevt replicates to standby [06:00:11.434](0.000s) #   Failed test 'cleared dathasloginevt replicates to standby' #   at /home/bf/bf-build/skink/REL_19_STABLE/pgsql/src/test/recovery/t/053_standby_login_event_trigger.pl line 118. [06:00:11.434](0.000s) #          got: 't' #     expected: 'f' ... [06:00:12.023](0.588s) # Looks like you failed 2 tests of 6. I've reproduced this locally when running 5 concurrent test instances against Valgrind-instrumented build, with the following TEMP_CONFIG: log_autovacuum_min_duration = 0 autovacuum_naptime = 1 log_min_messages = DEBUG3 log_line_prefix = '%m [%p][%b][%v:%x] ' log_connections = on log_disconnections = on and diagnostic logging: --- a/src/backend/commands/event_trigger.c +++ b/src/backend/commands/event_trigger.c @@ -945,9 +945,12 @@ EventTriggerOnLogin(void)          * pg_database flag ourselves; it will be cleared via WAL replay once the          * primary's next login event trigger run clears it on the primary.          */ -       else if (!RecoveryInProgress() && - ConditionalLockSharedObject(DatabaseRelationId, MyDatabaseId, +       else if (!RecoveryInProgress()) +{ +if (!ConditionalLockSharedObject(DatabaseRelationId, MyDatabaseId, 0, AccessExclusiveLock)) +elog(LOG,  "!!!EventTriggerOnLogin| could not lock database %u", MyDatabaseId); +else         {                 /*                  * The lock is held.  Now we need to recheck that login event triggers @@ -1002,6 +1005,7 @@ EventTriggerOnLogin(void)                         list_free(runlist);                 }         } +}         CommitTransactionCommand();  } I'm getting: [23:03:51.341](0.000s) ok 4 - no AccessExclusiveLock FATAL on standby login [23:03:52.951](1.610s) not ok 5 - primary clears dathasloginevt on next login after DROP [23:03:52.951](0.000s) [23:03:52.951](0.000s) #   Failed test 'primary clears dathasloginevt on next login after DROP' #   at t/053_standby_login_event_trigger.pl line 109. [23:03:52.951](0.000s) #          got: 't' #     expected: 'f' Waiting for replication conn standby's replay_lsn to pass 0/04000000 on primary done [23:03:56.084](3.134s) not ok 6 - cleared dathasloginevt replicates to standby [23:03:56.085](0.000s) [23:03:56.085](0.000s) #   Failed test 'cleared dathasloginevt replicates to standby' #   at t/053_standby_login_event_trigger.pl line 118. [23:03:56.085](0.000s) #          got: 't' #     expected: 'f' [23:03:56.085](0.000s) 1..6 053_standby_login_event_trigger_primary.log contains: 2026-10-08 23:03:51.618 EDT [3254910][postmaster][:0] DEBUG: assigned pm child slot 1 for client backend 2026-10-08 23:03:51.619 EDT [3254910][postmaster][:0] DEBUG:  forked new client backend, pid=3255516 socket=8 2026-10-08 23:03:51.626 EDT [3255516][client backend][:0] LOG: connection received: host=[local] 2026-10-08 23:03:51.641 EDT [3255516][client backend][5/0:0] DEBUG: InitPostgres ... 2026-10-08 23:03:51.756 EDT [3254910][postmaster][:0] DEBUG: postmaster received pmsignal signal 2026-10-08 23:03:51.756 EDT [3254910][postmaster][:0] DEBUG: assigned pm child slot 42 for autovacuum worker 2026-10-08 23:03:51.757 EDT [3255516][client backend][5/1:0] LOG: connection authenticated: user="u2" method=trust (.../src/test/recovery_4/tmp_check/t_053_standby_login_event_trigger_primary_data/pgdata/pg_hba.conf:117) 2026-10-08 23:03:51.759 EDT [3255516][client backend][5/1:0] LOG: connection authorized: user=u2 database=regress_login_evt application_name=053_standby_login_event_trigger.pl ... 2026-10-08 23:03:51.852 EDT [3255516][client backend][5/2:0] LOG: !!!EventTriggerOnLogin| could not lock database 16386 2026-10-08 23:03:51.935 EDT [3255522][autovacuum worker][13/0:0] DEBUG:  autovacuum: processing database "regress_login_evt" So it looks like the test might fail due to autovacuum activity. [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2026-10-05%2002%3A20%3A34 Best regards, Alexander --------------d7jP7po4IC7oQreSXibCBRKJ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello Alexander,

25.05.2026 11:53, Alexander Korotkov wrote:
On Thu, May 21, 2026 at 2:48 PM Ayush Tiwari
<ayushtiwari.slg01@gmail.com> wrote:
I agree the approach you are suggesting is better.

Patch looks good to me!
Thank you.  I'm going to push and backpatch it if no objections.

Please look at a failure of 053_standby_login_event_trigger.pl produced
recently by skink [1]:
[05:59:54.150](0.000s) ok 4 - no AccessExclusiveLock FATAL on standby login
[05:59:59.905](5.755s) not ok 5 - primary clears dathasloginevt on next login after DROP
[05:59:59.906](0.000s) #   Failed test 'primary clears dathasloginevt on next login after DROP'
#   at /home/bf/bf-build/skink/REL_19_STABLE/pgsql/src/test/recovery/t/053_standby_login_event_trigger.pl line 109.
[05:59:59.906](0.000s) #          got: 't'
#     expected: 'f'
Waiting for replication conn standby's replay_lsn to pass 0/04000060 on primary
done
[06:00:11.434](11.528s) not ok 6 - cleared dathasloginevt replicates to standby
[06:00:11.434](0.000s) #   Failed test 'cleared dathasloginevt replicates to standby'
#   at /home/bf/bf-build/skink/REL_19_STABLE/pgsql/src/test/recovery/t/053_standby_login_event_trigger.pl line 118.
[06:00:11.434](0.000s) #          got: 't'
#     expected: 'f'
...
[06:00:12.023](0.588s) # Looks like you failed 2 tests of 6.

I've reproduced this locally when running 5 concurrent test instances
against Valgrind-instrumented build, with the following TEMP_CONFIG:
log_autovacuum_min_duration = 0
autovacuum_naptime = 1
log_min_messages = DEBUG3
log_line_prefix = '%m [%p][%b][%v:%x] '
log_connections = on
log_disconnections = on

and diagnostic logging:
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -945,9 +945,12 @@ EventTriggerOnLogin(void)
         * pg_database flag ourselves; it will be cleared via WAL replay once the
         * primary's next login event trigger run clears it on the primary.
         */
-       else if (!RecoveryInProgress() &&
-                        ConditionalLockSharedObject(DatabaseRelationId, MyDatabaseId,
+       else if (!RecoveryInProgress())
+{
+if (!ConditionalLockSharedObject(DatabaseRelationId, MyDatabaseId,
                                                                                 0, AccessExclusiveLock))
+elog(LOG,  "!!!EventTriggerOnLogin| could not lock database %u", MyDatabaseId);
+else
        {
                /*
                 * The lock is held.  Now we need to recheck that login event triggers
@@ -1002,6 +1005,7 @@ EventTriggerOnLogin(void)
                        list_free(runlist);
                }
        }
+}
        CommitTransactionCommand();
 }


I'm getting:
[23:03:51.341](0.000s) ok 4 - no AccessExclusiveLock FATAL on standby login
[23:03:52.951](1.610s) not ok 5 - primary clears dathasloginevt on next login after DROP
[23:03:52.951](0.000s)
[23:03:52.951](0.000s) #   Failed test 'primary clears dathasloginevt on next login after DROP'
#   at t/053_standby_login_event_trigger.pl line 109.
[23:03:52.951](0.000s) #          got: 't'
#     expected: 'f'
Waiting for replication conn standby's replay_lsn to pass 0/04000000 on primary
done
[23:03:56.084](3.134s) not ok 6 - cleared dathasloginevt replicates to standby
[23:03:56.085](0.000s)
[23:03:56.085](0.000s) #   Failed test 'cleared dathasloginevt replicates to standby'
#   at t/053_standby_login_event_trigger.pl line 118.
[23:03:56.085](0.000s) #          got: 't'
#     expected: 'f'
[23:03:56.085](0.000s) 1..6

053_standby_login_event_trigger_primary.log contains:
2026-10-08 23:03:51.618 EDT [3254910][postmaster][:0] DEBUG:  assigned pm child slot 1 for client backend
2026-10-08 23:03:51.619 EDT [3254910][postmaster][:0] DEBUG:  forked new client backend, pid=3255516 socket=8
2026-10-08 23:03:51.626 EDT [3255516][client backend][:0] LOG:  connection received: host=[local]
2026-10-08 23:03:51.641 EDT [3255516][client backend][5/0:0] DEBUG:  InitPostgres
...
2026-10-08 23:03:51.756 EDT [3254910][postmaster][:0] DEBUG:  postmaster received pmsignal signal
2026-10-08 23:03:51.756 EDT [3254910][postmaster][:0] DEBUG:  assigned pm child slot 42 for autovacuum worker
2026-10-08 23:03:51.757 EDT [3255516][client backend][5/1:0] LOG:  connection authenticated: user="u2" method=trust (.../src/test/recovery_4/tmp_check/t_053_standby_login_event_trigger_primary_data/pgdata/pg_hba.conf:117)
2026-10-08 23:03:51.759 EDT [3255516][client backend][5/1:0] LOG:  connection authorized: user=u2 database=regress_login_evt application_name=053_standby_login_event_trigger.pl
...
2026-10-08 23:03:51.852 EDT [3255516][client backend][5/2:0] LOG:  !!!EventTriggerOnLogin| could not lock database 16386
2026-10-08 23:03:51.935 EDT [3255522][autovacuum worker][13/0:0] DEBUG:  autovacuum: processing database "regress_login_evt"

So it looks like the test might fail due to autovacuum activity.

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2026-10-05%2002%3A20%3A34

Best regards,
Alexander
--------------d7jP7po4IC7oQreSXibCBRKJ--