pgsql: Fix scenario where streaming standby gets stuck at a continuatio

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix scenario where streaming standby gets stuck at a continuatio
Date: 2018-05-04 22:37:13
Message-ID: E1fEjKD-00057S-Pe@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix scenario where streaming standby gets stuck at a continuation record.

If a continuation record is split so that its first half has already been
removed from the master, and is only present in pg_wal, and there is a
recycled WAL segment in the standby server that looks like it would
contain the second half, recovery would get stuck. The code in
XLogPageRead() incorrectly started streaming at the beginning of the
WAL record, even if we had already read the first page.

Backpatch to 9.4. In principle, older versions have the same problem, but
without replication slots, there was no straightforward mechanism to
prevent the master from recycling old WAL that was still needed by standby.
Without such a mechanism, I think it's reasonable to assume that there's
enough slack in how many old segments are kept around to not run into this,
or you have a WAL archive.

Reported by Jonathon Nelson. Analysis and patch by Kyotaro HORIGUCHI, with
some extra comments by me.

Discussion: https://www.postgresql.org/message-id/CACJqAM3xVz0JY1XFDKPP%2BJoJAjoGx%3DGNuOAshEDWCext7BFvCQ%40mail.gmail.com

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4ea8f7d4553e1b90974766ab6e9a32726e80badc

Modified Files
--------------
src/backend/access/transam/xlog.c | 44 +++++++++++++++++++++++++++++++--
src/backend/access/transam/xlogreader.c | 27 +++++++++++---------
src/include/access/xlogreader.h | 4 +++
3 files changed, 62 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2018-05-04 22:44:19 Re: pgsql: Provide for testing on python3 modules when under MSVC
Previous Message Mike Blackwell 2018-05-04 22:26:24 Re: perlcritic (was Re: pgsql: Fix precedence problem in new Perl code.)