Re: pg_rewind : feature to rewind promoted standby is broken!

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Mithun Cy <mithun(dot)cy(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org, michael(dot)paquier(at)gmail(dot)com, fujii(at)postgresql(dot)org, kuntalghosh(dot)2007(at)gmail(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: pg_rewind : feature to rewind promoted standby is broken!
Date: 2019-03-12 09:23:01
Message-ID: 20190312092301.GL13812@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

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(at)postgresql(dot)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

Attachment Content-Type Size
rewind-filter-fix.patch text/x-diff 873 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-03-12 10:01:06 BUG #15687: incomplete profile operations
Previous Message Mithun Cy 2019-03-12 07:53:51 pg_rewind : feature to rewind promoted standby is broken!

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergei Kornilov 2019-03-12 10:06:55 Re: Offline enabling/disabling of data checksums
Previous Message Antonin Houska 2019-03-12 08:36:30 Re: Suggestions on message transfer among backends