Re: pg15b3: recovery fails with wal prefetch enabled
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>, "Shinoda, Noriyoshi (PN Japan FSIP)" <noriyoshi.shinoda@hpe.com>,
Tomas Vondra <tomas.vondra@enterprisedb.com>, Stephen Frost <sfrost@snowman.net>, Andres Freund <andres@anarazel.de>, Jakub Wartak <Jakub.Wartak@tomtom.com>,
Alvaro Herrera <alvherre@2ndquadrant.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>,
Dmitry Dolgov <9erthalion6@gmail.com>, David Steele <david@pgmasters.net>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-09-05T09:08:16Z
Lists: pgsql-hackers
Attachments
- v3-0001-Fix-recovery_prefetch-with-low-maintenance_io_con.patch (text/x-patch) patch v3-0001
On Mon, Sep 5, 2022 at 5:34 PM Kyotaro Horiguchi
<horikyota.ntt@gmail.com> wrote:
> At Mon, 05 Sep 2022 14:15:27 +0900 (JST), Kyotaro Horiguchi <horikyota.ntt@gmail.com> wrote in
> me> +1 for showing any message for the failure, but I think we shouldn't
> me> hide an existing message if any.
>
> At Mon, 5 Sep 2022 16:54:07 +1200, Thomas Munro <thomas.munro@gmail.com> wrote in
> > On reflection, it'd be better not to clobber any pre-existing error
> > there, but report one only if there isn't one already queued. I've
> > done that in this version, which I'm planning to do a bit more testing
> > on and commit soonish if there are no comments/objections, especially
> > for that part.
>
> It looks fine in this regard. I still think that the message looks
> somewhat internal.
Thanks for looking!
> me> And the error messages around are
> me> just telling that "<some error happened> at RecPtr". So I think
> me> "missing contrecord at RecPtr" is sufficient here.
Ok, I've updated it like that.
> > I'll have to check whether a doc change is necessary somewhere to
> > advertise that maintenance_io_concurrency=0 turns off prefetching, but
> > IIRC that's kinda already implied.
> >
> > I've tested quite a lot of scenarios including make check-world with
> > maintenance_io_concurrency = 0, 1, 10, 1000, and ALTER SYSTEM for all
> > relevant GUCs on a standby running large pgbench to check expected
> > effect on pg_stat_recovery_prefetch view and generate system calls.
>
> + if (likely(record = prefetcher->reader->record))
>
> Isn't this confusing a bit?
>
>
> + if (likely(record = prefetcher->reader->record))
> + {
> + XLogRecPtr replayed_up_to = record->next_lsn;
> +
> + XLogReleasePreviousRecord(prefetcher->reader);
> +
>
> The likely condition is the prerequisite for
> XLogReleasePreviousRecord. But is is a little hard to read the
> condition as "in case no previous record exists". Since there is one
> in most cases, can't call XLogReleasePreviousRecord() unconditionally
> then the function returns true when the previous record exists and
> false if not?
We also need the LSN that is past that record.
XLogReleasePreviousRecord() could return it (or we could use
reader->EndRecPtr I suppose). Thoughts on this version?
Commits
-
Fix recovery_prefetch with low maintenance_io_concurrency.
- adb466150b44 16.0 landed
- dd38ff28addc 15.0 landed
-
doc: warn of SECURITY DEFINER schemas for non-sql_body functions
- a2039b1f8e90 15.0 cited