From: | Fujii Masao <fujii(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Ensure that a standby is able to follow a primary on a newer tim |
Date: | 2021-01-14 03:32:22 |
Message-ID: | E1kztN0-0003Bn-Sb@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Ensure that a standby is able to follow a primary on a newer timeline.
Commit 709d003fbd refactored WAL-reading code, but accidentally caused
WalSndSegmentOpen() to fail to follow a timeline switch while reading from
a historic timeline. This issue caused a standby to fail to follow a primary
on a newer timeline when WAL archiving is enabled.
If there is a timeline switch within the segment, WalSndSegmentOpen() should
read from the WAL segment belonging to the new timeline. But previously
since it failed to follow a timeline switch, it tried to read the WAL segment
with old timeline. When WAL archiving is enabled, that WAL segment with
old timeline doesn't exist because it's renamed to .partial. This leads
a primary to have tried to read non-existent WAL segment, and which caused
replication to faill with the error "ERROR: requested WAL segment ... has
already been removed".
This commit fixes WalSndSegmentOpen() so that it's able to follow a timeline
switch, to ensure that a standby is able to follow a primary on a newer
timeline even when WAL archiving is enabled.
This commit also adds the regression test to check whether a standby is
able to follow a primary on a newer timeline when WAL archiving is enabled.
Back-patch to v13 where the bug was introduced.
Reported-by: Kyotaro Horiguchi
Author: Kyotaro Horiguchi, tweaked by Fujii Masao
Reviewed-by: Alvaro Herrera, Fujii Masao
Discussion: https://postgr.es/m/20201209.174314.282492377848029776.horikyota.ntt@gmail.com
Branch
------
REL_13_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/94f52929a0c4e92c271c5a03bae782ddb0b086bd
Modified Files
--------------
src/backend/replication/walsender.c | 2 +-
src/test/recovery/t/004_timeline_switch.pl | 42 +++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 4 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Fujii Masao | 2021-01-14 03:32:52 | pgsql: Ensure that a standby is able to follow a primary on a newer tim |
Previous Message | Michael Paquier | 2021-01-14 02:15:23 | pgsql: Rework refactoring of hex and encoding routines |