From: Michael Paquier <michael@paquier.xyz>
To: Mithun Cy <mithun.cy@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org, pgsql-hackers@lists.postgresql.org, michael.paquier@gmail.com, fujii@postgresql.org, kuntalghosh.2007@gmail.com, Robert Haas <robertmhaas@gmail.com>
Subject: Re: pg_rewind : feature to rewind promoted standby is broken!
Date: Tue, 12 Mar 2019 18:23:01 +0900
Message-ID: <20190312092301.GL13812@paquier.xyz> (raw)
In-Reply-To: <CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com>
References: <CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com>
On Tue, Mar 12, 2019 at 01:23:51PM +0530, Mithun Cy wrote:
> I think pg_rewind's feature to rewind the promoted standby as a new
> standby is broken in 11
Confirmed, it is.
> Also I have tested same in version 10 it works fine there.
>
> Did below commit has broken this feature? (Thanks to kuntal for
> identifying same)
> commit 266b6acb312fc440c1c1a2036aa9da94916beac6
> Author: Fujii Masao <fujii@postgresql.org>
> Date: Thu Mar 29 04:56:52 2018 +0900
> Make pg_rewind skip files and directories that are removed during server start.
And you are pointing out to the correct commit. The issue is that
process_target_file() has added a call to check_file_excluded(), and
this skips all the folders which it thinks can be skipped. One
problem though is that we also filter out pg_internal.init, which is
present in each database folder, and remains in the target directory
marked for deletion. Then, when the deletion happens, the failure
happens as the directory is not fully empty.
We could consider using rmtree() instead, but it is a nice sanity
check to make sure that all the entries in a path have been marked for
deletion. Just removing the filter check on the target is fine I
think, as we only should have the filters anyway to avoid copying
unnecessary files from the source. Attached is a patch. What do you
think?
(check_file_excluded() could be simplified further but it's also nice
to keep some mirroring in this API if we finish by using it for target
files at some point.)
--
Michael
Attachments:rewind-filter-fix.patch (text/x-diff, 872B) downloaddiff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.cindex bb4ffd0e38..a2cd317c72 100644--- a/src/bin/pg_rewind/filemap.c+++ b/src/bin/pg_rewind/filemap.c@@ -334,12 +334,11 @@ process_target_file(const char *path, file_type_t type, size_t oldsize,
file_entry_t *entry;
/*
- * Ignore any path matching the exclusion filters. This is not actually- * mandatory for target files, but this does not hurt and let's be- * consistent with the source processing.+ * Do not apply any exclusion filters here, the folders marked for+ * deletion on the target should be entirely empty, and we also+ * check after pg_internal.init which is present in each database+ * folder.
*/
- if (check_file_excluded(path, false))- return;
snprintf(localpath, sizeof(localpath), "%s/%s", datadir_target, path);
if (lstat(localpath, &statbuf) < 0)
signature.asc (application/pgp-signature, 832B) download
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-bugs@postgresql.org
Cc: michael@paquier.xyz, mithun.cy@gmail.com, robertmhaas@gmail.com
Subject: Re: pg_rewind : feature to rewind promoted standby is broken!
In-Reply-To: <20190312092301.GL13812@paquier.xyz>
References: <CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com> <20190312092301.GL13812@paquier.xyz>
* 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