pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Antonin Houska <ah@cybertec.at>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Attempt to consolidate reading of XLOG page
Date: Tue, 26 Nov 2019 11:40:17 +0100
Message-ID: <66134.1574764817@antos> (raw)
In-Reply-To: <20191125181534.GA19210@alvherre.pgsql>
References: <20191125181534.GA19210@alvherre.pgsql>

Alvaro Herrera <alvherre@2ndquadrant.com> wrote:

> On 2019-Nov-25, Antonin Houska wrote:
> 
> > Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> 
> > > I see no reason to leave ws_off.  We can move that to XLogReaderState; I
> > > did that here.  We also need the offset in WALReadError, though, so I
> > > added it there too.  Conceptually it seems clearer to me this way.
> > > 
> > > What do you think of the attached?
> > 
> > It looks good to me. Attached is just a fix of a minor problem in error
> > reporting that Michael pointed out earlier.
> 
> Excellent, I pushed it with this change included and some other cosmetic
> changes.

Thanks!

> Now there's only XLogPageRead() ...

Hm, this seems rather specific, not sure it's worth trying to use WALRead()
here. Anyway, I notice that it uses pg_read() too.

> > I'd appreciate more background about the "partial read" that
> > Michael mentions here:
> > 
> > https://www.postgresql.org/message-id/20191125033048.GG37821%40paquier.xyz
> 
> In the current implementation, if pg_pread() does a partial read, we
> just loop one more time.
> 
> I considered changing the "if (readbytes <= 0)" with "if (readbytes <
> segbytes)", but that seemed pointless.

In the pread() documentation I see "Upon reading end-of-file, zero is
returned."  but that does not tell whether zero can be returned without
reaching EOF. However XLogPageRead() handles zero as an error, so WALRead() is
consistent with that.

> However, writing this now makes me think that we should add a
> CHECK_FOR_INTERRUPTS in this loop.  (I also wonder if we shouldn't limit
> the number of times we retry if pg_pread returns zero (i.e. no error,
> but no bytes read either).  I don't know if this is a real-world
> consideration.)

If statement above is correct, then we shouldn't need this.

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





view thread (62+ messages)  latest in thread

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

 · 

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, alvherre@2ndquadrant.com, michael@paquier.xyz, thomas.munro@gmail.com, robertmhaas@gmail.com
  Subject: Re: Attempt to consolidate reading of XLOG page
  In-Reply-To: <66134.1574764817@antos>

* 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