From: Stephen Frost <sfrost@snowman.net>
To: Dejan Petrovic <dejan.petrovic@islonline.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Database corruption in cascaded replica, "pg_xact/003A" doesn't exist, reading as zeroes"
Date: Wed, 5 Dec 2018 10:01:20 -0500
Message-ID: <20181205150120.GD3415@tamriel.snowman.net> (raw)
In-Reply-To: <b0b28ebd-ee8c-a9ac-17f6-41add4479a42@islonline.com>
References: <b0b28ebd-ee8c-a9ac-17f6-41add4479a42@islonline.com>
Greetings,
* Dejan Petrovic (dejan.petrovic@islonline.com) wrote:
> I believe this is a result of my "broken" procedure for setting up a
> cascaded replica. I would love to know where the issue is.
[...]
> Notes:
> Machines are running on Centos 7, Postgresql 10.2
> DB-1 = master
> DB-2 = replica of DB-1
> DB-3 = replica of DB-2
>
> --------------> DB-3 (new cascaded replica)
> systemctl disable postgresql-10
> systemctl stop postgresql-10
> --------------> DB-1 (master)
> psql -U postgres
> select pg_start_backup('clone',true);
> <------------- DB-3 (cascaded replica)
> rsync -azv -e --delete DB-2:/isl/pgsql10/data /isl/pgsql10/ --exclude pg_wal
> --exclude postgresql.pid
> assert rsync finished
> vi recovery.conf
> standby_mode = 'on'
> primary_conninfo = 'host=DB-2'
> recovery_target_timeline = 'latest'
> -------------> DB-1
> select pg_stop_backup();
> <------------- DB-3
> rsync -azv -e --delete DB-2:/isl/pgsql10/data/pg_wal /isl/pgsql10/data/
> systemctl start postgresql-10
> systemctl enable postgresql-10
If I'm reading this correctly, you're doing a pg_start_backup() on the
primary, but then making a copy of the DB-2 replica (while the primary
and the DB-2 replica are still running..).
In short, no, that doesn't work. Never has. That someone thought they
could create a replica that way is just another good reason to rip out
the broken exclusive-backup mode. I hope this isn't how your regular
backups are done.
I'd strongly suggest that you use existing tools to do this- in
partciular, you should be able to use pg_basebackup against the DB-2
replica to build out your cascaded replica and that'll do all the right
things. Alternatively, using a backup solution like pgbackrest would
allow you to quickly build a replica from your backups instead of from a
running replica.
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) 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-general@postgresql.org
Cc: sfrost@snowman.net, dejan.petrovic@islonline.com
Subject: Re: Database corruption in cascaded replica, "pg_xact/003A" doesn't exist, reading as zeroes"
In-Reply-To: <20181205150120.GD3415@tamriel.snowman.net>
References: <b0b28ebd-ee8c-a9ac-17f6-41add4479a42@islonline.com> <20181205150120.GD3415@tamriel.snowman.net>
* 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