pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of WAL segments ready to be archived during crash r
Date: Thu, 23 Apr 2020 23:51:16 +0000
Message-ID: <E1jRlci-00025N-Ov@gemulon.postgresql.org> (raw)

Fix handling of WAL segments ready to be archived during crash recovery

78ea8b5 has fixed an issue related to the recycling of WAL segments on
standbys depending on archive_mode.  However, it has introduced a
regression with the handling of WAL segments ready to be archived during
crash recovery, causing those files to be recycled without getting
archived.

This commit fixes the regression by tracking in shared memory if a live
cluster is either in crash recovery or archive recovery as the handling
of WAL segments ready to be archived is different in both cases (those
WAL segments should not be removed during crash recovery), and by using
this new shared memory state to decide if a segment can be recycled or
not.  Previously, it was not possible to know if a cluster was in crash
recovery or archive recovery as the shared state was able to track only
if recovery was happening or not, leading to the problem.

A set of TAP tests is added to close the gap here, making sure that WAL
segments ready to be archived are correctly handled when a cluster is in
archive or crash recovery with archive_mode set to "on" or "always", for
both standby and primary.

Reported-by: Benoît Lobréau
Author: Jehan-Guillaume de Rorthais
Reviewed-by: Kyotaro Horiguchi, Fujii Masao, Michael Paquier
Discussion: https://postgr.es/m/20200331172229.40ee00dc@firost
Backpatch-through: 9.5

Branch
------
master

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

Modified Files
--------------
src/backend/access/transam/xlog.c         |  57 ++++++--
src/backend/access/transam/xlogarchive.c  |  21 ++-
src/include/access/xlog.h                 |   9 ++
src/test/recovery/t/020_archive_status.pl | 214 ++++++++++++++++++++++++++++++
src/tools/pgindent/typedefs.list          |   1 +
5 files changed, 286 insertions(+), 16 deletions(-)



view thread (11+ messages)  latest in thread

Message-ID: <E1jRlci-00025N-Ov@gemulon.postgresql.org>
Permalink:  ../E1jRlci-00025N-Ov@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jRlci-00025N-Ov@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Fix handling of WAL segments ready to be archived during crash r
  In-Reply-To: <E1jRlci-00025N-Ov@gemulon.postgresql.org>
  References: <E1jRlci-00025N-Ov@gemulon.postgresql.org>

* 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