pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: 035_standby_logical_decoding might fail due to FATAL message lost inside libpq
Date: Wed, 27 May 2026 20:00:01 +0300
Message-ID: <c4ac949a-02cd-4bbd-b79d-8b93c11ae68b@gmail.com> (raw)
In-Reply-To: <OS9PR01MB121491B8DEDE281FF6E16AB89F5082@OS9PR01MB12149.jpnprd01.prod.outlook.com>
References: <a50ff89b-fb2c-4912-8f89-50dd0bd0916b@gmail.com>
	<OS9PR01MB121491B8DEDE281FF6E16AB89F5082@OS9PR01MB12149.jpnprd01.prod.outlook.com>

Hello Kuroda-san,

27.05.2026 08:43, Hayato Kuroda (Fujitsu) wrote:
> Hi Alexander,
>
> I applied your reproducer atop my HEAD (12d00048), but I could not reproduce.
> ...
>
> The build can be done if I restore changes in src/meson.build, but I could not
> reproduce the failure if I run 035_standby_logicaldecoding.pl. Am I missing something?

I'm sorry, it looks like I had messed up with the patch. Please try the fixed one.
It makes the unmodified 035_standby_logical_decoding.pl fail for me as below:
  CPPFLAGS="-O0" ./configure -q --enable-debug --enable-tap-tests --enable-injection-points && make -s -j8 && 
PROVE_TESTS="t/035*" make -s check -C src/test/recovery/
...
# pg_recvlogical: error: could not send replication command "START_REPLICATION SLOT "drop_db_activeslot" LOGICAL 
0/00000000 ("include-xids" '0', "skip-empty-xacts" '1')": server closed the connection unexpectedly
#       This probably means the server terminated abnormally
#       before or while processing the request.
# pg_recvlogical: error: disconnected
# '
#     doesn't match '(?^:conflict with recovery)'
t/035_standby_logical_decoding.pl .. 87/? # Looks like you failed 1 test of 89.
t/035_standby_logical_decoding.pl .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/89 subtests

Best regards,
Alexander

Attachments:

debug-035_standby_logical_decoding+.patch (text/x-patch, 1.7K) download diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index b969caae72e..53eb0d711bc 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -600,6 +600,7 @@ CreateDecodingContext(XLogRecPtr start_lsn, ctx->reorder->output_rewrites = ctx->options.receive_rewrites; +pg_usleep(100000); ereport(LogicalDecodingLogLevel(), (errmsg("starting logical decoding for slot \"%s\"", NameStr(slot->data.name)), diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 04aa770d981..687ac057afc 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1501,6 +1501,7 @@ StartLogicalReplication(StartReplicationCmd *cmd) ReplicationSlotAcquire(cmd->slotname, true, true); +pg_usleep(500000); /* * Force a disconnect, so that the decoding code doesn't need to care * about an eventual switch from running in recovery, to running in a diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index 31d5b48d3f9..c08c2987c46 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -200,6 +200,16 @@ pqsecure_raw_read(PGconn *conn, void *ptr, size_t len) n = recv(conn->sock, ptr, len, 0); +if (conn->replication && conn->replication[0]) +{ +int save_errno = SOCK_ERRNO; +char hb[1024]; +hb[0] = 0; +for (size_t i = 0; i < n && i < 256; i++) sprintf(hb + (i * 2), "%02x", ((char *)ptr)[i]); +fprintf(stderr, "!!!pqsecure_raw_read| len=%zu n=%zd errno=%d buf=%s\n", len, n, (n < 0) ? save_errno : 0, hb); +SOCK_ERRNO_SET(save_errno); +} + if (n < 0) { result_errno = SOCK_ERRNO;

view thread (12+ messages)  latest in thread

Message-ID: <c4ac949a-02cd-4bbd-b79d-8b93c11ae68b@gmail.com>
Permalink:  ../c4ac949a-02cd-4bbd-b79d-8b93c11ae68b@gmail.com/
Also on:    postgresql.org/message-id/c4ac949a-02cd-4bbd-b79d-8b93c11ae68b@gmail.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: exclusion@gmail.com, kuroda.hayato@fujitsu.com
  Subject: Re: 035_standby_logical_decoding might fail due to FATAL message lost inside libpq
  In-Reply-To: <c4ac949a-02cd-4bbd-b79d-8b93c11ae68b@gmail.com>
  References: <a50ff89b-fb2c-4912-8f89-50dd0bd0916b@gmail.com> <OS9PR01MB121491B8DEDE281FF6E16AB89F5082@OS9PR01MB12149.jpnprd01.prod.outlook.com> <c4ac949a-02cd-4bbd-b79d-8b93c11ae68b@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox