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 pg_rewind when rewinding new database with tables included
Date: Mon, 18 Mar 2019 01:36:04 +0000
Message-ID: <E1h5hC8-0000he-N4@gemulon.postgresql.org> (raw)

Fix pg_rewind when rewinding new database with tables included

This fixes an issue introduced by 266b6ac, which has added filters to
exclude file patterns on the target and source data directories to
reduce the number of files transferred.  Filters get applied to both
the target and source data files, and include pg_internal.init which is
present for each database once relations are created on it.  However, if
the target differed from the source with at least one new database with
relations, the rewind would fail due to the exclusion filters applied on
the target files, causing pg_internal.init to still be present on the
target database folder, while its contents should have been completely
removed so as there is nothing remaining inside at the time of the
folder deletion.

Applying exclusion filters on the source files is fine, because this way
the amount of data copied from the source to the target is reduced.  And
actually, not applying the filters on the target is what pg_rewind
should do, because this causes such files to be automatically removed
during the rewind on the target.  Exclusion filters apply to paths which
are removed or recreated automatically at startup, so removing all those
files on the target during the rewind is a win.

The existing set of TAP tests already stresses the rewind of databases,
but it did not include any tables on those newly-created databases.
Creating extra tables in this case is enough to reproduce the failure,
so the existing tests are extended to close the gap.

Reported-by: Mithun Cy
Author: Michael Paquier
Discussion: https://postgr.es/m/CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com
Backpatch-through: 11

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/dcf2a0db8529b81a57d421e0fd59297d10d5f0b6

Modified Files
--------------
src/bin/pg_rewind/filemap.c          | 13 +++++++------
src/bin/pg_rewind/t/002_databases.pl | 12 ++++++++++--
src/bin/pg_rewind/t/RewindTest.pm    |  6 ++++--
3 files changed, 21 insertions(+), 10 deletions(-)



view thread (2+ messages)

Message-ID: <E1h5hC8-0000he-N4@gemulon.postgresql.org>
Permalink:  ../E1h5hC8-0000he-N4@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1h5hC8-0000he-N4@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 pg_rewind when rewinding new database with tables included
  In-Reply-To: <E1h5hC8-0000he-N4@gemulon.postgresql.org>
  References: <E1h5hC8-0000he-N4@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