Re: Fix typo about WalSndPrepareWrite

From: japin <japinli(at)hotmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: ashutosh(dot)bapat(dot)oss(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, ashutosh(dot)bapat(at)enterprisedb(dot)com
Subject: Re: Fix typo about WalSndPrepareWrite
Date: 2021-01-14 12:18:35
Message-ID: MEYP282MB16690C6939AC594A61B81442B6A80@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Thu, 14 Jan 2021 at 15:32, Kyotaro Horiguchi wrote:
> At Thu, 14 Jan 2021 06:46:35 +0000, Li Japin <japinli(at)hotmail(dot)com> wrote in
>>
>> On Jan 14, 2021, at 12:56 PM, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com<mailto:ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>> wrote:
>>
>> 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);
>>
>>
>> After a quick search, I found that WalSndPrepareWrite and WalSndWriteData are always pairs [1].
>> IIUC the space of sendtime leave by WalSndPrepareWrite, it always fill out by WalSndWriteData.
>>
>>
>> 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.
>
> The two functions are the body of two logical-decoding API
> functions. They are assumed to be called in that order. See
> OutputPluginWrite() for the restriction. The sequence of the two
> logica-decoding funcitons and the code block in XLogSendPhysical are
> parallels in (theoretically) different protocols.
>

Is that mean the sendtime of WalSndPrepareWrite always fill out by WalSndWriteData?
If it is, I think we should modify the comment in WalSndPrepareWrite.

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-01-14 12:19:48 Re: Logical Replication - behavior of ALTER PUBLICATION .. DROP TABLE and ALTER SUBSCRIPTION .. REFRESH PUBLICATION
Previous Message Li Japin 2021-01-14 12:06:01 Re: Logical Replication - behavior of ALTER PUBLICATION .. DROP TABLE and ALTER SUBSCRIPTION .. REFRESH PUBLICATION