Hi Hackers,

it turns out, that the code in WalSndWriteData is setting the timestamp of
the replication message just *after* it has been sent out to the client,
thus the sendtime field always reads as zero.

Attached is a trivial patch to fix this.  The physical replication path
already does the correct thing apparently.

Cheers!
--
Alex
diff --git a/src/backend/replication/walsender.c 
b/src/backend/replication/walsender.c
new file mode 100644
index eb1b89b..c9444ca
*** a/src/backend/replication/walsender.c
--- b/src/backend/replication/walsender.c
*************** static void
*** 1048,1056 ****
  WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId 
xid,
                                bool last_write)
  {
-       /* output previously gathered data in a CopyData packet */
-       pq_putmessage_noblock('d', ctx->out->data, ctx->out->len);
- 
        /*
         * Fill the send timestamp last, so that it is taken as late as 
possible.
         * This is somewhat ugly, but the protocol's set as it's already used 
for
--- 1048,1053 ----
*************** WalSndWriteData(LogicalDecodingContext *
*** 1061,1066 ****
--- 1058,1066 ----
        memcpy(&ctx->out->data[1 + sizeof(int64) + sizeof(int64)],
                   tmpbuf.data, sizeof(int64));
  
+       /* output previously gathered data in a CopyData packet */
+       pq_putmessage_noblock('d', ctx->out->data, ctx->out->len);
+ 
        /* fast path */
        /* Try to flush pending output to the client */
        if (pq_flush_if_writable() != 0)
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to