pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of files that source server removes during pg_rewin
Date: Wed, 28 Mar 2018 19:03:27 +0000
Message-ID: <E1f1GM3-0002Ke-MW@gemulon.postgresql.org> (raw)

Fix handling of files that source server removes during pg_rewind is running.

After processing the filemap to build the list of chunks that will be
fetched from the source to rewing the target server, it is possible that
a file which was previously processed is removed from the source.  A
simple example of such an occurence is a WAL segment which gets recycled
on the target in-between.  When the filemap is processed, files not
categorized as relation files are first truncated to prepare for its
full copy of which is going to be taken from the source, divided into a
set of junks.  However, for a recycled WAL segment, this would result in
a segment which has a zero-byte size.  With such an empty file,
post-rewind recovery thinks that records are saved but they are actually
not because of the truncation which happened when processing the
filemap, resulting in data loss.

In order to fix the problem, make sure that files which are found as
removed on the source when receiving chunks of them are as well deleted
on the target server for consistency.

Back-patch to 9.5 where pg_rewind was added.

Author: Tsunakawa Takayuki
Reviewed-by: Michael Paquier
Reported-by: Tsunakawa Takayuki

Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F8DAAA2%40G01JPEXMBYT05

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/52c32d8d8d3cc29d9c2ab4a0c360fb09627231e1

Modified Files
--------------
src/bin/pg_rewind/file_ops.c    | 16 ++++++++++++----
src/bin/pg_rewind/file_ops.h    |  1 +
src/bin/pg_rewind/libpq_fetch.c | 10 +++++++---
3 files changed, 20 insertions(+), 7 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1f1GM3-0002Ke-MW@gemulon.postgresql.org>
Permalink:  ../E1f1GM3-0002Ke-MW@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1f1GM3-0002Ke-MW@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: fujii@postgresql.org
  Subject: Re: pgsql: Fix handling of files that source server removes during pg_rewin
  In-Reply-To: <E1f1GM3-0002Ke-MW@gemulon.postgresql.org>
  References: <E1f1GM3-0002Ke-MW@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