agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
From: Antonin Houska <ah@cybertec.at>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Remove page-read callback from XLogReaderState.
Date: Thu, 25 Apr 2019 13:58:20 +0200
Message-ID: <18581.1556193500@localhost> (raw)
In-Reply-To: <20190418.210257.43726183.horiguchi.kyotaro@lab.ntt.co.jp>
References: <20190418.210257.43726183.horiguchi.kyotaro@lab.ntt.co.jp>

Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> wrote:

> Hello. As mentioned before [1], read_page callback in
> XLogReaderState is a cause of headaches. Adding another
> remote-controlling stuff to xlog readers makes things messier [2].

The patch I posted in thread [2] tries to solve another problem: it tries to
merge xlogutils.c:XLogRead(), walsender.c:XLogRead() and
pg_waldump.c:XLogDumpXLogRead() into a single function,
xlogutils.c:XLogRead().

> [2]
> https://www.postgresql.org/message-id/20190412.122711.158276916.horiguchi.kyotaro@lab.ntt.co.jp

> I refactored XLOG reading functions so that we don't need the
> callback.

I was curious about the patch, so I reviewed it:

* xlogreader.c

  ** Comments mention "opcode", "op" and "expression step" - probably leftover
     from the executor, which seems to have inspired you.

  ** XLR_DISPATCH() seems to be unused

  ** Comment: "duplicatedly" -> "repeatedly" ?

  ** XLogReadRecord(): comment "All internal state need ..." -> "needs"

  ** XLogNeedData()

     *** shouldn't only the minimum amount of data needed (SizeOfXLogLongPHD)
     be requested here?

	state->loadLen = XLOG_BLCKSZ;
	XLR_LEAVE(XLND_STATE_SEGHEAD, true);

Note that ->loadLen is also set only to the minimum amount of data needed
elsewhere.

     *** you still mention "read_page callback" in a comment.

     *** state->readLen is checked before one of the calls of XLR_LEAVE(), but
     I think it should happen before *each* call. Otherwise data can be read
     from the page even if it's already in the buffer.

* xlogreader.h

  ** XLND_STATE_PAGEFULLHEAD - maybe LONG rather than FULL? And perhaps HEAD
  -> HDR, so it's clear that it's about (page) header, not e.g. list head.

  ** XLogReaderState.loadLen - why not reqLen? loadLen sounds to me like "loaded"
  as opposed to "requested". And assignemnt like this

	int reqLen	= xlogreader->loadLen;

  will also be less confusing with ->reqLen.

  Maybe also ->loadPagePtr should be renamed to ->targetPagePtr.


* trailing whitespace: xlogreader.h:130, xlogreader.c:1058


* The 2nd argument of SimpleXLogPageRead() is "private", which seems too
  generic given that the function is no longer used as a callback. Since the
  XLogPageReadPrivate structure only has two fields, I think it'd be o.k. to
  pass them to the function directly.

* I haven't found CF entry for this patch.

-- 
Antonin Houska
Web: https://www.cybertec-postgresql.com





view thread (58+ messages)  latest in thread

Message-ID: <18581.1556193500@localhost>
Permalink:  ../18581.1556193500@localhost/
Also on:    postgresql.org/message-id/18581.1556193500@localhost

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ah@cybertec.at, horiguchi.kyotaro@lab.ntt.co.jp
  Subject: Re: Remove page-read callback from XLogReaderState.
  In-Reply-To: <18581.1556193500@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox