Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpDNF-00018G-CD for pgsql-general@arkaria.postgresql.org; Mon, 13 Aug 2018 13:59:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpDND-0004Ug-Im for pgsql-general@arkaria.postgresql.org; Mon, 13 Aug 2018 13:59:07 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpDND-0004UZ-78 for pgsql-general@lists.postgresql.org; Mon, 13 Aug 2018 13:59:07 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpDNA-0003q0-6g for pgsql-general@lists.postgresql.org; Mon, 13 Aug 2018 13:59:05 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id A09B15F79C; Mon, 13 Aug 2018 09:59:03 -0400 (EDT) Date: Mon, 13 Aug 2018 09:59:03 -0400 From: Stephen Frost To: Adrian Klaver Cc: Phil Endecott , pgsql-general@lists.postgresql.org Subject: Re: Replication failure, slave requesting old segments Message-ID: <20180813135903.GL3326@tamriel.snowman.net> References: <31ba3812-6a0a-4639-5386-e804e59bc322@aklaver.com> <1534162092902@dmwebmail.dmwebmail.chezphil.org> <20180813123915.GD3326@tamriel.snowman.net> <708ff81b-9f5f-9726-fec7-59e90243947d@aklaver.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Ian02MSQ7xDzAZO2" Content-Disposition: inline In-Reply-To: <708ff81b-9f5f-9726-fec7-59e90243947d@aklaver.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Ian02MSQ7xDzAZO2 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Adrian Klaver (adrian.klaver@aklaver.com) wrote: > On 08/13/2018 05:39 AM, Stephen Frost wrote: > >* Phil Endecott (spam_from_pgsql_lists@chezphil.org) wrote: > >>Adrian Klaver wrote: > >>>On 08/12/2018 02:56 PM, Phil Endecott wrote: > >>>>Anyway.=A0 Do others agree that my issue was the result of > >>>>wal_keep_segments=3D0 ? > >>> > >>>Only as a sub-issue of the slave losing contact with the master. The b= asic > >>>problem is maintaining two separate operations, archiving and streamin= g, > >>>in sync. If either or some combination of both lose synchronization th= en > >>>it is anyone's guess on what is appropriate for wal_keep_segments. > > > >Uh, no, having an archive_command and a restore_command configures > >exactly should remove the need to worry about what wal_keep_segments is > >set to because anything not on the primary really should be available > >through what's been archived and PG shouldn't have any trouble figuring > >that out and working with it. > > > >If all you've got is streaming replication then, sure, you have no idea > >what to set wal_keep_segments to because the replica could be offline > >for an indeterminate amount of time, but as long as you're keeping track > >of all the WAL through archive_command, that shouldn't be an issue. >=20 > Therein lies the rub. As I stated previously the bigger issue is syncing = two > different operations, archiving and streaming.=20 That's not correct though, there isn't a big issue regarding syncing of those two operations. > The OP got caught short > assuming the archiving would handle the situation where the streaming was > down for a period. In his particular setup and for this particular situat= ion > a wal_keep_segments of 1 would have helped. I do not see this as a default > value though as it depends on too many variables outside the reach of the > database, mostly notably the success of the archive command.=20 What's been pointed out here is that even if everything is working (archive_command, restore_command, etc) there's a possible gap in the transisition from replay-from-archive and starting streaming replication where the replica might not be able to start streaming. That's an entirely *PostgreSQL* issue, as far as I see it, and hasn't got anything to do with his particular setup except that he managed to expose the issue. > First is the > command even valid, two is the network link reliable, three is there even= a > network link, is there more then one network link, four is the restore > command valid? That is just of the top of my head, more caffeine and I co= uld > come up with more. Saying that having archiving, streaming and a > wal_keep_segments=3D1 has you covered, is misleading. I don't see it as > detrimental to performance but I do see more posts down the road from fol= ks > who are surprised when it does not cover their case. Personally I think it > better to be up front that this requires more thought or a third party > solution that has done the thinking. This is all down to "and you should also monitor to make sure things continue working" which I certainly agree with but that doesn't mean we shouldn't fix this issue. This entire side-discussion feels like it's really off in the weeds. The next steps which I outlined a while ago seem to still be entirely appropriate and we should figure out a way to solve this issue so that, when everything else is working (archive command, restore command, replica is able to connect to the primary, etc), that PG behaves sanely and is able to catch up with and connect to the primary and resume streaming. Thanks! Stephen --Ian02MSQ7xDzAZO2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJbcY6nAAoJEO1sijiDR2RVRQUP/j40h2c+mYCS2HIeMbLA0EIv mZkUGTdI+oGSbnRqhWozYbYpsbBsRD6GdJEAa/UEY1pJl2uACUp56QYsORXIfmiD /gf3mvw1J9Zo7aoz0CnbCF3vuRuOIolVWhOklzSQbbF1mBhclYkQN0+h17yIawFz q/O+jpoCCzN7pc3VVyISYC3jwLnPdJ5LrzD5fXUCZ8b1d0rZwdkHT9OYBehytN4C 6eBElB8MRG2qi8IOqcbOR81ZoBtNEe9SVwQ4Xurf6MUcLhy7njJfzK3eZJEG7Ie8 8p7YS0AaTK6V3CkIp60BeiLb28gz9vHdTBQ7crpIK94ugxMWcWdDlOcu0zJzhynD iZhmtC++53IiRcCbibzM2ZAiAy6i4i3UF/KVHsxrCTKgkujNv5s8paSBd9EKG1aB ILDrPpv1RAOLKAdUU27qPjTkkt/lQMmhl5mrJ2v7y8rWdtNXcf7aJJrjjdwCgEOd fY72qPw3SKLQCU7h2Z5HkuXJKelUnYXGEI0JTE5R+bcD7wMveOJB7pHNxWClkfJ8 ca6SXTjTD9GEiRW3JRmart5pPzYHxgz1dNzM7GF4p9iCq6M3fFY6hUZ3J9OrBCh7 HxvA/zbl2C5905jyVctAMkwpgl37nV+cJxonQF5CtjYRMCYIqALlDnlNNT1RD3Te Mz4yE/KiXIesyT1g7Q+s =WeVZ -----END PGP SIGNATURE----- --Ian02MSQ7xDzAZO2--