From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: Heikki Linnakangas <hlinnaka@iki.fi>
To: PostgreSQL-Dev <pgsql-hackers@postgresql.org>
Subject: Re: [PATCH] XLogReadRecord returns pointer to currently read page
Date: Mon, 22 Oct 2018 22:54:19 +0500
Message-ID: <5f701ad0-6c3c-67f2-e5ce-dbf2f60a7d2d@postgrespro.ru> (raw)
In-Reply-To: <25cc0d31-a5c7-2b7d-e66e-f5cc9f2d4985@iki.fi>
References: <c2ea54dd-a1d3-80eb-ddbf-7e6f258e615e@postgrespro.ru>
<25cc0d31-a5c7-2b7d-e66e-f5cc9f2d4985@iki.fi>
On 22.10.2018 2:06, Heikki Linnakangas wrote:
> On 17/08/2018 06:47, Andrey Lepikhov wrote:
>> I propose the patch for fix one small code defect.
>> The XLogReadRecord() function reads the pages of a WAL segment that
>> contain a WAL-record. Then it creates a readRecordBuf buffer in private
>> memory of a backend and copy record from the pages to the readRecordBuf
>> buffer. Pointer 'record' is set to the beginning of the readRecordBuf
>> buffer.
>>
>> But if the WAL-record is fully placed on one page, the XLogReadRecord()
>> function forgets to bind the "record" pointer with the beginning of the
>> readRecordBuf buffer. In this case, XLogReadRecord() returns a pointer
>> to an internal xlog page. This patch fixes the defect.
>
> Hmm. I agree it looks weird the way it is. But I wonder, why do we even
> copy the record to readRecordBuf, if it fits on the WAL page? Returning
> a pointer to the xlog page buffer seems OK in that case. What if we
> remove the memcpy(), instead?
It depends on the PostgreSQL roadmap. If we want to compress main data
and encode something to reduce a WAL-record size, than the
representation of the WAL-record in shared buffers (packed) and in local
memory (unpacked) will be different and the patch is needed.
If something like this should not be in the PostgreSQL core, then it is
more efficient to remove memcpy(), of course.
I vote for the patch.
--
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: a.lepikhov@postgrespro.ru, hlinnaka@iki.fi
Subject: Re: [PATCH] XLogReadRecord returns pointer to currently read page
In-Reply-To: <5f701ad0-6c3c-67f2-e5ce-dbf2f60a7d2d@postgrespro.ru>
References: <c2ea54dd-a1d3-80eb-ddbf-7e6f258e615e@postgrespro.ru> <25cc0d31-a5c7-2b7d-e66e-f5cc9f2d4985@iki.fi> <5f701ad0-6c3c-67f2-e5ce-dbf2f60a7d2d@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox