pg_rewind : feature to rewind promoted standby is broken!

From: Mithun Cy <mithun(dot)cy(at)gmail(dot)com>
To: 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
Cc: kuntalghosh(dot)2007(at)gmail(dot)com, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: pg_rewind : feature to rewind promoted standby is broken!
Date: 2019-03-12 07:53:51
Message-ID: CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

I think pg_rewind's feature to rewind the promoted standby as a new
standby is broken in 11

STEPS:
1. create master standby setup.
Use below script for same.

2. Promote the standby
[mithuncy(at)localhost pgrewmasterbin]$ ./bin/pg_ctl -D standby promote
waiting for server to promote.... done
server promoted

3. In promoted standby create a database and a table in the new database.
[mithuncy(at)localhost pgrewmasterbin]$ ./bin/psql -p 5433 postgres
postgres=# create database db1;
CREATE DATABASE
postgres=# \c db1
You are now connected to database "db1" as user "mithuncy".
db1=# create table t1 (t int);
CREATE TABLE

4. try to rewind the newly promoted standby (with old master as source)
[mithuncy(at)localhost pgrewmasterbin]$ ./bin/pg_ctl -D standby stop
waiting for server to shut down....... done
server stopped
[mithuncy(at)localhost pgrewmasterbin]$ ./bin/pg_rewind -D standby
--source-server="host=127.0.0.1 port=5432 user=mithuncy
dbname=postgres"
servers diverged at WAL location 0/3000060 on timeline 1
rewinding from last common checkpoint at 0/2000060 on timeline 1
could not remove directory "standby/base/16384": Directory not empty
Failure, exiting

Note: dry run was successful!
[mithuncy(at)localhost pgrewmasterbin]$ ./bin/pg_rewind -D standby
--source-server="host=127.0.0.1 port=5432 user=mithuncy
dbname=postgres" -n
servers diverged at WAL location 0/3000060 on timeline 1
rewinding from last common checkpoint at 0/2000060 on timeline 1
Done!

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.

--
Thanks and Regards
Mithun Chicklore Yogendra
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
standby-server-setup.sh application/x-sh 1.9 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2019-03-12 09:23:01 Re: pg_rewind : feature to rewind promoted standby is broken!
Previous Message Sandeep Thakkar 2019-03-12 07:31:59 Re: Installation issue

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2019-03-12 07:54:16 Re: COPY FREEZE and setting PD_ALL_VISIBLE/visibility map bits
Previous Message Etsuro Fujita 2019-03-12 07:44:20 Re: Oddity with parallel safety test for scan/join target in grouping_planner