From dc782b923428db6c24cf4f53251f7a810fa0a27c Mon Sep 17 00:00:00 2001 From: Hayato Kuroda Date: Wed, 24 Jun 2026 22:16:14 +0900 Subject: [PATCH] Analyze 035_standby_logical_decoding failure --- src/backend/replication/walsender.c | 1 + src/bin/pg_basebackup/pg_recvlogical.c | 1 + src/interfaces/libpq/fe-exec.c | 7 +++++++ src/test/recovery/t/035_standby_logical_decoding.pl | 1 + 4 files changed, 10 insertions(+) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index c931d9b4fa8..3ca2327dc56 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1523,6 +1523,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/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index 0f7d7fe9429..24b65dc75e5 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.c +++ b/src/bin/pg_basebackup/pg_recvlogical.c @@ -277,6 +277,7 @@ StreamLogicalLog(void) appendPQExpBufferChar(query, ')'); res = PQexec(conn, query->data); + pg_log_info("debug: after PQexec"); if (PQresultStatus(res) != PGRES_COPY_BOTH) { pg_log_error("could not send replication command \"%s\": %s", diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 7b8edacbfde..97da4b3a472 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -2443,6 +2443,9 @@ PQexecFinish(PGconn *conn) lastResult = NULL; while ((result = PQgetResult(conn)) != NULL) { + fprintf(stderr, + "PQexecFinish loop: errMsg=%s\n", + result->errMsg ? result->errMsg : "(null)"); PQclear(lastResult); lastResult = result; if (result->resultStatus == PGRES_COPY_IN || @@ -2452,6 +2455,10 @@ PQexecFinish(PGconn *conn) break; } + fprintf(stderr, + "PQexecFinish return: errMsg=%s\n", + lastResult->errMsg ? lastResult->errMsg : "(null)"); + return lastResult; } diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test/recovery/t/035_standby_logical_decoding.pl index 88893f71350..a6abfbf8464 100644 --- a/src/test/recovery/t/035_standby_logical_decoding.pl +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -119,6 +119,7 @@ sub check_pg_recvlogical_stderr like($stderr, qr/$check_stderr/, 'slot has been invalidated'); } + print $stderr. "\n"; return 0; } -- 2.52.0