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 1wU8nx-000yJh-2B for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jun 2026 20:00:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wU8nu-00B0uo-1e for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Jun 2026 20: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.96) (envelope-from ) id 1wU8nu-00B0ug-0a for pgsql-hackers@lists.postgresql.org; Mon, 01 Jun 2026 20:00:06 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wU8ns-00000000inx-0uEb for pgsql-hackers@postgresql.org; Mon, 01 Jun 2026 20:00:05 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-45ef1629ff4so2692965f8f.0 for ; Mon, 01 Jun 2026 13:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780344003; x=1780948803; darn=postgresql.org; h=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; bh=ICuxxNdbJtih8zKN+HYu17/eK5o0DGxOLpI7Ivg7Gg8=; b=ij15ICPLrTohRndLk0uD6Vx+uNbNOh0w+8Ba1fp09jbJuAqT2UsuR40y9IuOdTiDiy mYrLoiiTxROWpNg8iAnSBIS66gMgG4z9UiMmxVRbDYAsdUq9/qOvCHzGcjdKyKfVO+Xp AouJ81YBolo6rK3odAPYtVQ4Y6gsijWrciBr4GjdGin0WWXsl3rIEKKiRDWS7jRkWRWo O2FCCRnXiUoCt8cGUqyOa4NIh8xt3uwm05ygP2/zreGHEZwKqHq4vsIlez4FtZQ12Yn7 pL2eXnsQR9XV68n3X3Y+bvGHDZIQjqA56Srd5zmMzRTeXCQQUKl+yRP6vpr+r8UJJ9V3 jEcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780344003; x=1780948803; h=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; bh=ICuxxNdbJtih8zKN+HYu17/eK5o0DGxOLpI7Ivg7Gg8=; b=nW1WjgUKHzTCLEFsj3mdqe3/nGlFEvsqAET9zNDImZlTCnICuHvHp6c0ogINcXGDWd aSTll3ExTAk++/eiIa4+V5pRR0SCWB7t37ebpMlHxVSA0MgZUYl486NRM5i4ktXBT2tI Lc/2D+LvGkYtsygSxtxZluEFRgF8UTO7mz2nFVojSI5mSrBEMQ736YbhVBO1GO4saFkN cp3hwkiFnAVA6wdlwKXzsugvqqN380q0yJtLt4AX2UMT5kha2st+ISVacxDMsfPaHyAA PR0u/e0JumIiTvECYdqfMXqE89cY6B1382bsfo8NATSVTW60W9J4Hg09R7sug92R6qK+ hoZA== X-Forwarded-Encrypted: i=1; AFNElJ/+ZzB2z+97l6m3XwrowiC2VWFAyNWCV1ViTdHq53sbykB+qTvWkZHNWVj3+AxhBDHHWiWwGslYZWkLORlD@postgresql.org X-Gm-Message-State: AOJu0YyQY/6Fb/4j7I60g7EvC8ArV7jW0Ezxk5Zdf54sgwNAdKtmIWzM PLWccLr+3GMWCff/5vthMVqvoavaCs9DDLj54AB3C7jt0JKsAugvvKOT X-Gm-Gg: Acq92OEFE/Q3tU60tNd9QWeKrsgleaFS7ZuYKHTp+JevmUpgZu6ANsUfQ1nhc4fbNnv 5OSlEI8wll9Y6nkVv0frVaDrfT4tX0hizf3j0SEJTr3LYtoFEFsWQNO26rK1cxORyl5Kurcm2/A wkE47vhN+q7VPByAOSazD6cy+/eTHeU30ufybS0xu0fEP3oMOhm4bDanc5OCbpRgIuLKB/RdOp+ u10JpWiEOx+uKCSW7e8Pu2p5fOSbTLrcc2oDTKyGDPic7q0b0vyjuR0SUsVL2nxvb3eu9oqzbZB l70calSKSZrPepu9y7E1t+qleQn/8q4JwxOHU1DoqpTr+QZ6x685TjYzHaC5Z4owdvrQJ1sxoYs BRd0E2vmoQz2RP+yGNjhAduzQxqnUYE5ZMQaYOX0N8W+8TLmMl5lElGUtT6JxvuKxGb6hxq2i5j rrQJRa5vRO82C2frGrF33GIuZjNhGJ20YtinE= X-Received: by 2002:a05:6000:26ca:b0:460:efd:c682 with SMTP id ffacd0b85a97d-4600efdccb7mr16213610f8f.24.1780344003070; Mon, 01 Jun 2026 13:00:03 -0700 (PDT) Received: from [192.168.0.50] ([89.149.68.143]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34a090dsm26875946f8f.3.2026.06.01.13.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2026 13:00:02 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------Mbqq4TnGn0pzoLhD9zataQC0" Message-ID: <74ff6252-3450-4508-9d16-1cdc891b3cb9@gmail.com> Date: Mon, 1 Jun 2026 23:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Exit walsender before confirming remote flush in logical replication To: "Hayato Kuroda (Fujitsu)" , Fujii Masao Cc: Andres Freund , Andrey Silitskiy , Alexander Korotkov , Greg Sabino Mullane , Japin Li , Ronan Dunklau , Vitaly Davydov , "Takamichi Osumi (Fujitsu)" , "pgsql-hackers@postgresql.org" , "sawada.mshk@gmail.com" , "michael@paquier.xyz" , "peter.eisentraut@enterprisedb.com" , "dilipbalaut@gmail.com" , "amit.kapila16@gmail.com" , Kyotaro Horiguchi , Peter Smith References: <8a250eda-77c2-4872-b675-35513b74b8af@postgrespro.ru> <5734c326-9051-4cda-b0d9-dd7b87b2218e@postgrespro.ru> <923f6d11-f43b-48c8-a8ed-3f7da6493374@gmail.com> 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. --------------Mbqq4TnGn0pzoLhD9zataQC0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Dear Kuroda-san, 01.06.2026 06:57, Hayato Kuroda (Fujitsu) wrote: >> 038_walsnd_shutdown_timeout_subscriber.log doesn't really contain the >> expected warning: >> 2026-05-29 21:11:58.777 CEST [2273817][logical replication apply worker][124/2:0] LOG:  logical replication apply worker for subscription "test_sub" has started >> 2026-05-29 21:12:03.232 CEST [2271870][client backend][4/6:0] LOG:  statement: BEGIN; >> 2026-05-29 21:12:03.232 CEST [2271870][client backend][4/6:0] LOG:  statement: LOCK TABLE test_tab IN EXCLUSIVE MODE; > ... > > To confirm; IIUC the warning should be contained on the publisher log, not the > subscriber side. And below log appeared on the publisher; > > ``` > 2026-05-29 21:12:03.426 CEST [2275591][walsender][26/1:0] FATAL: canceling authentication due to timeout > 2026-05-29 21:12:03.432 CEST [2273580][checkpointer][:0] LOG: shutting down > ``` I'm sorry. I switched to the wrong log file during my investigation. > > Is there a possibility that walsender was shut down during the authentication, > especially in-between BackendInitialize() and end of PerformAuthentication()? > >> I think this can be explained by the fact that walrcv->ready_to_display >> is set before WalReceiverMain's loop reached. I've reproduced this test >> failure with: > Verified it could reproduce the failure, but there were no "canceling authentication > due to timeout" in the publisher log on my env. I think the original failure can be reproduced with: --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -645,6 +645,7 @@ ClientAuthentication(Port *port)  #endif      } +if (am_walsender) pg_usleep(500 * 1000);      if ((log_connections & LOG_CONNECTION_AUTHENTICATION) &&          status == STATUS_OK &&          !MyClientConnectionInfo.authn_id) With this modification, I can see: #   Failed test 'walsender exits due to wal_sender_shutdown_timeout even when both physical and logical replication are stalled' #   at t/038_walsnd_shutdown_timeout.pl line 189. # Looks like you failed 1 test of 4. t/038_walsnd_shutdown_timeout.pl .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/4 subtests 038_walsnd_shutdown_timeout_publisher.log contains: 2026-06-01 22:32:35.166 EEST [1851879][client backend][0/0:0] FATAL:  terminating connection due to administrator command 2026-06-01 22:32:35.166 EEST [1851879][client backend][0/0:0] DETAIL:  Signal sent by PID 1851819, UID 1000. 2026-06-01 22:32:35.166 EEST [1851878][walsender][26/1:0] FATAL: canceling authentication due to timeout Best regards, Alexander --------------Mbqq4TnGn0pzoLhD9zataQC0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Dear Kuroda-san,

01.06.2026 06:57, Hayato Kuroda (Fujitsu) wrote:

      
038_walsnd_shutdown_timeout_subscriber.log doesn't really contain the
expected warning:
2026-05-29 21:11:58.777 CEST [2273817][logical replication apply worker][124/2:0] LOG:  logical replication apply worker for subscription "test_sub" has started
2026-05-29 21:12:03.232 CEST [2271870][client backend][4/6:0] LOG:  statement: BEGIN;
2026-05-29 21:12:03.232 CEST [2271870][client backend][4/6:0] LOG:  statement: LOCK TABLE test_tab IN EXCLUSIVE MODE;
...

To confirm; IIUC the warning should be contained on the publisher log, not the
subscriber side. And below log appeared on the publisher;

```
2026-05-29 21:12:03.426 CEST [2275591][walsender][26/1:0] FATAL:  canceling authentication due to timeout
2026-05-29 21:12:03.432 CEST [2273580][checkpointer][:0] LOG:  shutting down
```

I'm sorry. I switched to the wrong log file during my investigation. 


Is there a possibility that walsender was shut down during the authentication,
especially in-between BackendInitialize() and end of PerformAuthentication()?

I think this can be explained by the fact that walrcv->ready_to_display
is set before WalReceiverMain's loop reached. I've reproduced this test
failure with:
Verified it could reproduce the failure, but there were no "canceling authentication
due to timeout" in the publisher log on my env.

I think the original failure can be reproduced with:
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -645,6 +645,7 @@ ClientAuthentication(Port *port)
 #endif
     }
 
+if (am_walsender) pg_usleep(500 * 1000);
     if ((log_connections & LOG_CONNECTION_AUTHENTICATION) &&
         status == STATUS_OK &&
         !MyClientConnectionInfo.authn_id)

With this modification, I can see:
#   Failed test 'walsender exits due to wal_sender_shutdown_timeout even when both physical and logical replication are stalled'
#   at t/038_walsnd_shutdown_timeout.pl line 189.
# Looks like you failed 1 test of 4.
t/038_walsnd_shutdown_timeout.pl .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests

038_walsnd_shutdown_timeout_publisher.log contains:
2026-06-01 22:32:35.166 EEST [1851879][client backend][0/0:0] FATAL:  terminating connection due to administrator command
2026-06-01 22:32:35.166 EEST [1851879][client backend][0/0:0] DETAIL:  Signal sent by PID 1851819, UID 1000.
2026-06-01 22:32:35.166 EEST [1851878][walsender][26/1:0] FATAL:  canceling authentication due to timeout

Best regards,
Alexander
--------------Mbqq4TnGn0pzoLhD9zataQC0--