Re: [PATCH] xlogreader: do not read a file block twice

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Arthur Zakirov <a.zakirov@postgrespro.ru>
Cc: Grigory Smolkin <g.smolkin@postgrespro.ru>, pgsql-hackers@lists.postgresql.org
Date: 2019-02-14T06:51:56Z
Lists: pgsql-hackers
On Tue, Feb 12, 2019 at 11:44:14AM +0300, Arthur Zakirov wrote:
> Of course. Agree, it may be a non trivial case. Added as a bug fix:
> https://commitfest.postgresql.org/22/1994/

I have been looking at the patch, and I agree that the current coding
is a bit crazy.  If the wanted data has already been read, it makes
little sense to require reading it again if the size requested by the
caller of ReadPageInternal() exactly equals what has been read
already, and that's what the code is doing.

Now I don't actually agree that this qualifies as a bug fix.  As
things stand, a page may finish by being more than once if what has
been read previously equals what is requested, however this does not
prevent the code to work correctly.  The performance gain is also
heavily dependent on the callback reading a page and the way the WAL
reader is used.  How do you actually read WAL pages in your own
plugin with compressed data?  It begins by reading a full page once,
then it moves on to a per-record read after making sure that the page
has been read?
--
Michael

Commits

  1. Avoid some unnecessary block reads in WAL reader

  2. Split out XLog reading as an independent facility

  3. Make standby server continuously retry restoring the next WAL segment with