Re: [PATCH] XLogReadRecord returns pointer to currently read page

Andrei Lepikhov <a.lepikhov@postgrespro.ru>

From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: Michael Paquier <michael@paquier.xyz>
Cc: PostgreSQL-Dev <pgsql-hackers@postgresql.org>
Date: 2018-08-17T04:25:57Z
Lists: pgsql-hackers

17.08.2018 08:55, Michael Paquier пишет:
> On Fri, Aug 17, 2018 at 08:47:15AM +0500, Andrey Lepikhov wrote:
>> Previously, in all cases of using WAL this was not a problem. However if you
>> plan to perform some decoding operations before returning the WAL record to
>> the caller (this is my case), this can lead to bugs that are difficult to
>> catch.
> 
> What kind of cases with logical decoding are you referring to?  If
> any of them can be reproduced with upstream, could you send a
> reproducer, or a way to see it?
> --
> Michael
> 

I'm working on the problem of a WAL-record size reducing. One of the 
PostgreSQL experimental extensions uses a 64-bit xid, and the XLogRecord 
size is increased to 32 bytes.
Representing a 64-bit xid in WAL Segment as a pair (16-bit base, 8-bit 
offset) reduces the size of the WAL record header and its body.
So, I encode a WAL-record in XLogInsertRecord() (decreasing the size) 
just before writing to a shared memory pages and performs the decoding 
just before processing DecodeXLogRecord() operation.
It looks like a layer in the xlog subsystem for additional WAL 
compression. However, this is a long story ...

-- 
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company


Commits

  1. Improve description of buffer used to store records in WAL reader

  2. Remove unnecessary memcpy when reading WAL record fitting on page