From bfbc76e6a85b40e3b9000e22d1c53d06e8799a2a Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Thu, 20 Oct 2022 07:57:04 +0000 Subject: [PATCH v1] pg_recvlogical fixes --- src/bin/pg_basebackup/pg_recvlogical.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c index 5f2e6af445..4ce4ee648c 100644 --- a/src/bin/pg_basebackup/pg_recvlogical.c +++ b/src/bin/pg_basebackup/pg_recvlogical.c @@ -614,7 +614,14 @@ StreamLogicalLog(void) res = PQgetResult(conn); } - if (PQresultStatus(res) != PGRES_COMMAND_OK) + + if (time_to_abort) + { + if (verbose) + pg_log_info("received interrupt signal, exiting"); + goto error; + } + else if (PQresultStatus(res) != PGRES_COMMAND_OK) { pg_log_error("unexpected termination of replication stream: %s", PQresultErrorMessage(res)); @@ -634,6 +641,14 @@ StreamLogicalLog(void) } outfd = -1; error: + if (outfd != -1) + { + TimestampTz t; + + t = feGetCurrentTimestamp(); + /* no need to jump to error on failure here, we're finishing anyway */ + OutputFsync(t); + } if (copybuf != NULL) { PQfreemem(copybuf); -- 2.34.1