Re: Fix typo about WalSndPrepareWrite - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: Fix typo about WalSndPrepareWrite
Date
Msg-id CAExHW5uKHBWdMXnzs52rZQ17BPMiNNWdZt6W3h7-M6kRSzjpqA@mail.gmail.com
Whole thread Raw
In response to Fix typo about WalSndPrepareWrite  (japin <japinli@hotmail.com>)
Responses Re: Fix typo about WalSndPrepareWrite  (Li Japin <japinli@hotmail.com>)
List pgsql-hackers
Hi Japin,
Thanks for the report.

I think that comment is correct. It refers to the following code
blocks of XLogSendPhysical()

2744     /*
2745      * OK to read and send the slice.
2746      */
2747     resetStringInfo(&output_message);
2748     pq_sendbyte(&output_message, 'w');
2749
2750     pq_sendint64(&output_message, startptr);    /* dataStart */
2751     pq_sendint64(&output_message, SendRqstPtr); /* walEnd */
2752     pq_sendint64(&output_message, 0);   /* sendtime, filled in last */

2803      * Fill the send timestamp last, so that it is taken as late
as possible.
2804      */
2805     resetStringInfo(&tmpbuf);
2806     pq_sendint64(&tmpbuf, GetCurrentTimestamp());
2807     memcpy(&output_message.data[1 + sizeof(int64) + sizeof(int64)],
2808            tmpbuf.data, sizeof(int64));
2809
2810     pq_putmessage_noblock('d', output_message.data, output_message.len);

WalSndWriteData() also fills the timestamp there but it may not always
be used with WalSndPrepareWrite, at least theoretically. So it's the
XLogSendPhysical() that it's referring to.

Maybe a better way is to separate those two codeblocks into functions
and use it in WalSndPrepareWrite, WalSndWriteData and XLogSendPhysical
appropriately. That way we don't have to add a comment like that and
the sanity of 'w' message is preserved.

On Thu, Jan 14, 2021 at 10:10 AM japin <japinli@hotmail.com> wrote:
>
>
> Hi,
>
> While reading the code about logical replication, I found that
> WalSndPrepareWrite function says it use XLogSendPhysical to fill out the
> sendtime, however, it actually done by WalSndWriteData.  It looks like a
> typo, attaching a very small patch to correct it.
>
> --
> Regrads,
> Japin Li.
> ChengDu WenWu Information Technology Co.,Ltd.
>


-- 
Best Wishes,
Ashutosh Bapat



pgsql-hackers by date:

Previous
From: japin
Date:
Subject: Fix typo about WalSndPrepareWrite
Next
From: Michael Paquier
Date:
Subject: Re: remove unneeded pstrdup in fetch_table_list