From: | Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Question about WalSndWriteData |
Date: | 2018-03-16 16:08:51 |
Message-ID: | ce2bc24e-9fe4-28ad-6f9e-f8bf842a96af@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi hackes,
I confused by the following code in WalSndWriteData:
/* 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 is set as it's already
used for
* several releases by streaming physical replication.
*/
resetStringInfo(&tmpbuf);
now = GetCurrentTimestamp();
pq_sendint64(&tmpbuf, now);
memcpy(&ctx->out->data[1 + sizeof(int64) + sizeof(int64)],
tmpbuf.data, sizeof(int64));
pq_putmessage_noblock copies data from ctx->out buffer to libpq buffers.
After it we write timestamp to ctx->out buffer.
And comments says that we should do it "as late as possible".
But this timestamp is not included in the copy data packet which is
already copied to libpq connection buffer.
And next WalSndPrepareWrite call will reset ctx->out buffer.
So I wonder what is the reason of writing timestamp in ctx->out buffer
after processing it by pq_putmessage_noblock?
--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2018-03-16 16:18:08 | Re: fixing more format truncation issues |
Previous Message | Peter Eisentraut | 2018-03-16 16:07:59 | Re: SSL passphrase prompt external command |