Re:Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication

Yilin Zhang <jiezhilove@126.com>

From: "Yilin Zhang" <jiezhilove@126.com>
To: "Fujii Masao" <masao.fujii@gmail.com>
Cc: "Mircea Cadariu" <cadariu.mircea@gmail.com>, "PostgreSQL Hackers" <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-04T09:40:57Z
Lists: pgsql-hackers
On 28/11/2025 02:15, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> I've made a few minor adjustments to the test patch.
> The updated version is attached.


Hi,
I was reading your code and had a question about the new code you added in the main() function of pg_recvlogical.c:
  if (outfd != -1 && strcmp(outfile, "-") != 0)
   OutputFsync(feGetCurrentTimestamp());
In the stream loop, the StreamLogicalLog() function already contains similar code:
  if (outfd != -1 &&
   feTimestampDifferenceExceeds(output_last_fsync, now,
           fsync_interval))
  {
   if (!OutputFsync(now))
    goto error;
  }


If the outfile becomes unwritable due to external reasons, would the error reporting here be redundant with the error handling in StreamLogicalLog()?


Best regards,
--
Yilin Zhang

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pg_recvlogical: remove unnecessary OutputFsync() return value checks.

  2. Add test for pg_recvlogical reconnection behavior.

  3. Add a new helper function wait_for_file() to Utils.pm.

  4. pg_recvlogical: Prevent flushed data from being re-sent.