Hi,I recently stumbled over an issue with an unintentional re-transmission. While this clearly was our fault in the output plugin code, I think the walsender's exposed API could easily be hardened to prevent the bad consequence from this mistake.
Does anything speak against the attached one line patch? Best Regards Markus
From 65dd24ed975cc513e4e0de5e175dff16b4b0f6d4 Mon Sep 17 00:00:00 2001 From: Markus Wanner <markus.wan...@enterprisedb.com> Date: Thu, 20 Feb 2025 21:01:45 +0100 Subject: [PATCH] Reset the output buffer after sending from WalSndWriteData While not strictly necessary, clearing the buffer right away after sending prevents an accidential re-delivery in case WalSndWriteData is called again. --- src/backend/replication/walsender.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 446d10c1a7d..96884ce152f 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1563,6 +1563,9 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, /* output previously gathered data in a CopyData packet */ pq_putmessage_noblock('d', ctx->out->data, ctx->out->len); + /* reset the output buffer to prevent re-sending */ + resetStringInfo(ctx->out); + CHECK_FOR_INTERRUPTS(); /* Try to flush pending output to the client */ -- 2.39.5