Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUYg6-0007hV-HC for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 15:01:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUYg5-0001Lz-2D for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 15:01:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUYg4-0001Ls-NF for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 15:01:28 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUYfx-0006w2-2W for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 15:01:27 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id BD6115F7AA; Wed, 5 Dec 2018 10:01:20 -0500 (EST) Date: Wed, 5 Dec 2018 10:01:20 -0500 From: Stephen Frost To: Dejan Petrovic Cc: pgsql-general@lists.postgresql.org Subject: Re: Database corruption in cascaded replica, "pg_xact/003A" doesn't exist, reading as zeroes" Message-ID: <20181205150120.GD3415@tamriel.snowman.net> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dYPoZongPzEAoiMM" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --dYPoZongPzEAoiMM Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D master > DB-2 =3D replica of DB-1 > DB-3 =3D replica of DB-2 >=20 > --------------> 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 > =A0=A0=A0 standby_mode =3D 'on' > =A0=A0=A0 primary_conninfo =3D 'host=3DDB-2' > =A0=A0=A0 recovery_target_timeline =3D '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 --dYPoZongPzEAoiMM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJcB+hAAAoJEO1sijiDR2RVJVsP/A3W5QJvcF9lC8zjZb1V1ZT7 cYNSNnYzLK6WhC6rBY01OlgioeNNvm2PbfaRpYOrLNJTq2plcrCuBZgW7ZXoczOM Y3vBAydKKc1IY+aEtT3jRZj4vwTibpELEYHN4rKLJ2Y+z5ut7pc2PMhNdJeJn67I vM5gUUf3eiDFR4bDFIeWx0gO7z8ctJCYaMRoHdBcGkKfdV0TfLiMh/0PIkK5ShSw l1TtCUGdVDGHvFA/7tgVBA/4gbKT6X0GkjkzBkiEq9B14rjMTpmf563VRG2Rl4dD TJQDNUWsX/X/spOltBL12Dvj/VLPgx4Ak30gfz8ygT7HeSjC52tAt1YjtMGp7DVu pi7mOGB9djH55OF+kTSIyjSQo57AU1dMstSrE1+3gZrQeDE07Iz2x1Lv/opG9bWt 5rB3opPditJxuXmaOL5WNpZeQDd192hy3MjRdPyeHm2hFhnVeqmBqOs7XXmZ7uYS hm1t42T66YzdWQY+SL2znA93GA7mpE08c/9tAMebkyBYkg/5S/NkoyK5NRlj5BwB ALr1dTZnnfUwUqsrsQg5Q7cTL3PzVBHAiKOzuEMk7u1kfy/0w2H1sDT2B7JyhO6c njYZF7mG/Dj19Ofto3kMmT3i2NzjP9ujrxCwWo8MGylcyV6a6qlUgbJzMny5tAz/ 6RLJgm2RxVZEgOCuteFz =4MDn -----END PGP SIGNATURE----- --dYPoZongPzEAoiMM--