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 1wTdtr-000f3Z-2Q for pgsql-hackers@arkaria.postgresql.org; Sun, 31 May 2026 11:00:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wTdtq-007MDR-0I for pgsql-hackers@arkaria.postgresql.org; Sun, 31 May 2026 11:00:10 +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 1wTdtp-007MDI-2S for pgsql-hackers@lists.postgresql.org; Sun, 31 May 2026 11:00:10 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wTdtl-00000000SIO-41MG for pgsql-hackers@postgresql.org; Sun, 31 May 2026 11:00:09 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-49048e043e5so71629385e9.1 for ; Sun, 31 May 2026 04:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780225204; x=1780830004; 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=F1RAl7WKMPqAYHb2QjJAxqGeQjuJsV3lJbKY+bHUU2s=; b=O1aHX2/NdjQQKp5LvCjxAv8GXjjjuqiQONsoVrZG7MrrnscjPvlS2lbprrbdloa+5z M/Z8F4lTpmUBkyitu8Pz0XBGUQMgcGiZg9T+rW60dzdeT2u25ERb1lNVYula00/loJ0M 2BngEFKALOUq8teKzdfr4uiVcR0gVMpxqbVdeoyVxXUFJd3BilRbeJY5fXr4eVkaLIo0 2UjUmaytQrmDacBxfKghT2UAYf2ii6fNzZjmILnWNJA2Ddcm4MTp9/0LoeBO+FOrY57Q ykqlp26qLlDfKqTbyENyI/c7KWZfy/EGRR0wSjfgT2vWWSNgzmizl4tyj2Go7Xr+lUub Ay1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780225204; x=1780830004; 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=F1RAl7WKMPqAYHb2QjJAxqGeQjuJsV3lJbKY+bHUU2s=; b=A0O/oSijq1CeEVQWD+MEwuF1uvROxfo9BSYDYv6z0aAAdu9OuS8BNGjPo0H+Gvdh94 ySVO8sRzATCYWjMDI7iAc4AyRZzU4aPll08eqJ1xYPvGQLbE8ziFvUVQ5+vIbHr39OXX 6lP2JG+R9ascnWkvOdLdhWLjwr7GveESrxEHk5teHRI/WNF1bhl+5KNrVsyZF7OS1PD7 MQs/P1gfOnyoVYlJaBOkeGIyHo0MYmsMe6SCnCG3mtwKlQqa6TxT9r5KR61VehEf2Dro xGIZ1FjsyQ5g1WdbCRTCP+8B9rvUCQKoSDJny7AUMTAVHRlHuLfw4tm3zDD4y3uBej0+ C8jQ== X-Forwarded-Encrypted: i=1; AFNElJ/EXUXFsd6QWt1Wd2IvfGUrDvbediURutIEzDdF/brj9wo7KfYfL+4bX2ChpBKpBXyYQm1+4dPj7C88t6Pr@postgresql.org X-Gm-Message-State: AOJu0YwGDXUPYlpch0Cu7yUs7ESUUxVARMDKI215pNnY/h4uc8SnCNZ9 cbJlv0f9vZoWoT0yPjcR6vPFuyUtCIgoaTBgpFsoepfH2qtM//h+evUz X-Gm-Gg: Acq92OGedOwju2vQynvXvh2XsSMhb/VclAgBFMIm9/gqgj1OX1i1iDglg0p9c6Fmyp8 c+Ia6nrkR20xDmH2PDho6mVhNlpUERSvtsSTu+p4nXJlbZ+O4zxf6NcdU50aSXZIr9X9J7OsA4s LfdU238I6x9C1mrhZdSVNgaFH/Gi4v3BGnk184p9NcL2ZL067kdt74RF9PaYJdtOb35KZxKHcWl 0k8Y6PJuWih5AqRppucRaoSFX44OI90ICEXlKrbaqbPuPAjGAXSYbV0gp888vsxwESBg++G8zBX PbYxlaGpUFRiGW+tRc9SQz4+ypMto/T3bP+1ik5pw8XB/Rhvv1cnoWZ7kaF6vBq0zI88lsY6Cv2 nZSAUWcCTrmtTNRQadyenEnhTK0oXrclDkaLt/ORwcow3gCRIlCiUSyNuqvcjMnyGr3kpDylIcU vC7zRArMT/aj2C5J0rjgTDppKfiKg9isdxApPkc8+VUcCZ8Q== X-Received: by 2002:a05:600c:1c0a:b0:490:846d:e2de with SMTP id 5b1f17b1804b1-490a293fcfcmr134226835e9.28.1780225204042; Sun, 31 May 2026 04:00:04 -0700 (PDT) Received: from [192.168.0.50] ([89.149.68.143]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4909d6a0e42sm168883125e9.8.2026.05.31.04.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 31 May 2026 04:00:02 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------AnvyfELGeRtVE94oOS8BLF6N" Message-ID: <923f6d11-f43b-48c8-a8ed-3f7da6493374@gmail.com> Date: Sun, 31 May 2026 14:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Exit walsender before confirming remote flush in logical replication To: Fujii Masao Cc: Andres Freund , Andrey Silitskiy , Alexander Korotkov , Greg Sabino Mullane , Japin Li , Ronan Dunklau , Vitaly Davydov , "Hayato Kuroda (Fujitsu)" , "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> 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. --------------AnvyfELGeRtVE94oOS8BLF6N Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Fujii-san, 06.04.2026 18:32, Andres Freund wrote: > Hi, > > On 2026-04-06 11:40:24 +0900, Fujii Masao wrote: >> I've pushed the patch. Thanks! > Failed on CI just now: > > https://cirrus-ci.com/task/6745359004729344?logs=test_world#L410 > https://api.cirrus-ci.com/v1/artifact/task/6745359004729344/testrun/build/testrun/subscription/038_walsnd_shutdown_timeout/log/regress_log_038_walsnd_shutdown_timeout A recent failure occurred on the buildfarm [1] indicates another stability issue, this time with the test itself, I guess: [21:12:03.301](0.068s) ok 3 - have walreceiver pid 2275585 ### Stopping node "publisher" using mode fast # Running: pg_ctl --pgdata /home/bf/bf-build/tamandua/HEAD/pgsql.build/testrun/subscription/038_walsnd_shutdown_timeout/data/t_038_walsnd_shutdown_timeout_publisher_data/pgdata --mode fast stop waiting for server to shut down.... done server stopped # No postmaster PID for node "publisher" [21:12:03.752](0.452s) not ok 4 - walsender exits due to wal_sender_shutdown_timeout even when both physical and logical replication are stalled [21:12:03.753](0.001s) #   Failed test 'walsender exits due to wal_sender_shutdown_timeout even when both physical and logical replication are stalled' #   at /home/bf/bf-build/tamandua/HEAD/pgsql/src/test/subscription/t/038_walsnd_shutdown_timeout.pl line 189. ### Stopping node "subscriber" using mode fast 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; 2026-05-29 21:12:03.232 CEST [2271870][client backend][4/6:0] LOG: statement: ; 2026-05-29 21:12:03.268 CEST [2273817][logical replication apply worker][124/0:0] LOG:  received message via replication: WARNING: replication slot "test_slot" specified in parameter "synchronized_standby_slots" does not have active_pid     DETAIL:  Logical replication is waiting on the standby associated with replication slot "test_slot".     HINT:  Start the standby associated with the replication slot "test_slot", or amend parameter "synchronized_standby_slots". 2026-05-29 21:12:03.433 CEST [2273817][logical replication apply worker][124/0:0] ERROR:  could not receive data from WAL stream: ERROR:  replication slot "test_slot" specified in parameter "synchronized_standby_slots" does not have active_pid     DETAIL:  Logical replication is waiting on the standby associated with replication slot "test_slot".     HINT:  Start the standby associated with the replication slot "test_slot", or amend parameter "synchronized_standby_slots". 2026-05-29 21:12:03.437 CEST [2271017][postmaster][:0] LOG: background worker "logical replication apply worker" (PID 2273817) exited with exit code 1 2026-05-29 21:12:03.439 CEST [2275785][logical replication apply worker][125/2:0] LOG:  logical replication apply worker for subscription "test_sub" has started 2026-05-29 21:12:03.441 CEST [2275785][logical replication apply worker][125/0:0] ERROR:  apply worker for subscription "test_sub" could not connect to the publisher: connection to server on socket "/tmp/3gDgOpAsXL/.s.PGSQL.27739" failed: FATAL:  the database system is shutting down 2026-05-29 21:12:03.445 CEST [2271017][postmaster][:0] LOG: background worker "logical replication apply worker" (PID 2275785) exited with exit code 1 2026-05-29 21:12:03.763 CEST [2271870][client backend][:0] LOG: disconnection: session time: 0:00:08.180 user=bf database=postgres host=[local] 2026-05-29 21:12:03.767 CEST [2271017][postmaster][:0] LOG: received fast shutdown request 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: --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -280,6 +280,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)      walrcv->sender_port = 0;      walrcv->ready_to_display = true;      SpinLockRelease(&walrcv->mutex); +pg_usleep(500 * 1000);      /* Establish the connection to the primary for XLOG streaming */      appname = cluster_name[0] ? cluster_name : "walreceiver"; Could you please look if this can be improved? [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=tamandua&dt=2026-05-29%2019%3A03%3A21 Best regards, Alexander --------------AnvyfELGeRtVE94oOS8BLF6N Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello Fujii-san,

06.04.2026 18:32, Andres Freund wrote:
Hi,

On 2026-04-06 11:40:24 +0900, Fujii Masao wrote:
I've pushed the patch. Thanks!
Failed on CI just now:

https://cirrus-ci.com/task/6745359004729344?logs=test_world#L410
https://api.cirrus-ci.com/v1/artifact/task/6745359004729344/testrun/build/testrun/subscription/038_walsnd_shutdown_timeout/log/regress_log_038_walsnd_shutdown_timeout

A recent failure occurred on the buildfarm [1] indicates another stability
issue, this time with the test itself, I guess:
[21:12:03.301](0.068s) ok 3 - have walreceiver pid 2275585
### Stopping node "publisher" using mode fast
# Running: pg_ctl --pgdata /home/bf/bf-build/tamandua/HEAD/pgsql.build/testrun/subscription/038_walsnd_shutdown_timeout/data/t_038_walsnd_shutdown_timeout_publisher_data/pgdata --mode fast stop
waiting for server to shut down.... done
server stopped
# No postmaster PID for node "publisher"
[21:12:03.752](0.452s) not ok 4 - walsender exits due to wal_sender_shutdown_timeout even when both physical and logical replication are stalled
[21:12:03.753](0.001s) #   Failed test 'walsender exits due to wal_sender_shutdown_timeout even when both physical and logical replication are stalled'
#   at /home/bf/bf-build/tamandua/HEAD/pgsql/src/test/subscription/t/038_walsnd_shutdown_timeout.pl line 189.
### Stopping node "subscriber" using mode fast

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;
2026-05-29 21:12:03.232 CEST [2271870][client backend][4/6:0] LOG:  statement: ;
2026-05-29 21:12:03.268 CEST [2273817][logical replication apply worker][124/0:0] LOG:  received message via replication: WARNING:  replication slot "test_slot" specified in parameter "synchronized_standby_slots" does not have active_pid
    DETAIL:  Logical replication is waiting on the standby associated with replication slot "test_slot".
    HINT:  Start the standby associated with the replication slot "test_slot", or amend parameter "synchronized_standby_slots".
2026-05-29 21:12:03.433 CEST [2273817][logical replication apply worker][124/0:0] ERROR:  could not receive data from WAL stream: ERROR:  replication slot "test_slot" specified in parameter "synchronized_standby_slots" does not have active_pid
    DETAIL:  Logical replication is waiting on the standby associated with replication slot "test_slot".
    HINT:  Start the standby associated with the replication slot "test_slot", or amend parameter "synchronized_standby_slots".
2026-05-29 21:12:03.437 CEST [2271017][postmaster][:0] LOG:  background worker "logical replication apply worker" (PID 2273817) exited with exit code 1
2026-05-29 21:12:03.439 CEST [2275785][logical replication apply worker][125/2:0] LOG:  logical replication apply worker for subscription "test_sub" has started
2026-05-29 21:12:03.441 CEST [2275785][logical replication apply worker][125/0:0] ERROR:  apply worker for subscription "test_sub" could not connect to the publisher: connection to server on socket "/tmp/3gDgOpAsXL/.s.PGSQL.27739" failed: FATAL:  the database system is shutting down
2026-05-29 21:12:03.445 CEST [2271017][postmaster][:0] LOG:  background worker "logical replication apply worker" (PID 2275785) exited with exit code 1
2026-05-29 21:12:03.763 CEST [2271870][client backend][:0] LOG:  disconnection: session time: 0:00:08.180 user=bf database=postgres host=[local]
2026-05-29 21:12:03.767 CEST [2271017][postmaster][:0] LOG:  received fast shutdown request

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:
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -280,6 +280,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
     walrcv->sender_port = 0;
     walrcv->ready_to_display = true;
     SpinLockRelease(&walrcv->mutex);
+pg_usleep(500 * 1000);
 
     /* Establish the connection to the primary for XLOG streaming */
     appname = cluster_name[0] ? cluster_name : "walreceiver";


Could you please look if this can be improved?

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=tamandua&dt=2026-05-29%2019%3A03%3A21

Best regards,
Alexander
--------------AnvyfELGeRtVE94oOS8BLF6N--