v4-0004-pg_recvlogical-remove-unnecessary-OutputFsync-ret.patch

application/octet-stream

Filename: v4-0004-pg_recvlogical-remove-unnecessary-OutputFsync-ret.patch
Type: application/octet-stream
Part: 0
Message: Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v4-0004
Subject: pg_recvlogical: remove unnecessary OutputFsync() return value checks.
File+
src/bin/pg_basebackup/pg_recvlogical.c 7 16
From 73ddddc90f96994f9fb63be5abbcb34675b1e060 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Thu, 25 Dec 2025 19:41:03 +0900
Subject: [PATCH v4 4/4] pg_recvlogical: remove unnecessary OutputFsync()
 return value checks.

Commit 1e2fddfa33d changed OutputFsync() so that it always returns true.
However, pg_recvlogical.c still contained checks of its boolean return
value, which are now redundant.

This commit removes those checks and changes the type of return value of
OutputFsync() to void, simplifying the code.
---
 src/bin/pg_basebackup/pg_recvlogical.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c
index eb7068c0ef5..2b11c125f5f 100644
--- a/src/bin/pg_basebackup/pg_recvlogical.c
+++ b/src/bin/pg_basebackup/pg_recvlogical.c
@@ -184,7 +184,7 @@ disconnect_atexit(void)
 		PQfinish(conn);
 }
 
-static bool
+static void
 OutputFsync(TimestampTz now)
 {
 	output_last_fsync = now;
@@ -199,21 +199,19 @@ OutputFsync(TimestampTz now)
 	startpos = output_fsync_lsn;
 
 	if (fsync_interval <= 0)
-		return true;
+		return;
 
 	if (!output_needs_fsync)
-		return true;
+		return;
 
 	output_needs_fsync = false;
 
 	/* can only fsync if it's a regular file */
 	if (!output_isfile)
-		return true;
+		return;
 
 	if (fsync(outfd) != 0)
 		pg_fatal("could not fsync file \"%s\": %m", outfile);
-
-	return true;
 }
 
 /*
@@ -314,10 +312,7 @@ StreamLogicalLog(void)
 		if (outfd != -1 &&
 			feTimestampDifferenceExceeds(output_last_fsync, now,
 										 fsync_interval))
-		{
-			if (!OutputFsync(now))
-				goto error;
-		}
+			OutputFsync(now);
 
 		if (standby_message_timeout > 0 &&
 			feTimestampDifferenceExceeds(last_status, now,
@@ -334,8 +329,7 @@ StreamLogicalLog(void)
 		if (outfd != -1 && output_reopen && strcmp(outfile, "-") != 0)
 		{
 			now = feGetCurrentTimestamp();
-			if (!OutputFsync(now))
-				goto error;
+			OutputFsync(now);
 			close(outfd);
 			outfd = -1;
 		}
@@ -654,9 +648,7 @@ StreamLogicalLog(void)
 	{
 		TimestampTz t = feGetCurrentTimestamp();
 
-		/* no need to jump to error on failure here, we're finishing anyway */
 		OutputFsync(t);
-
 		if (close(outfd) != 0)
 			pg_log_error("could not close file \"%s\": %m", outfile);
 	}
@@ -1065,8 +1057,7 @@ static bool
 flushAndSendFeedback(PGconn *conn, TimestampTz *now)
 {
 	/* flush data to disk, so that we send a recent flush pointer */
-	if (!OutputFsync(*now))
-		return false;
+	OutputFsync(*now);
 	*now = feGetCurrentTimestamp();
 	if (!sendFeedback(conn, *now, true, false))
 		return false;
-- 
2.51.2