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 1fHpRd-0001xt-47 for pgsql-general@arkaria.postgresql.org; Sun, 13 May 2018 11:45:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fHpRb-0003jh-1B for pgsql-general@arkaria.postgresql.org; Sun, 13 May 2018 11:45:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fHpRa-0003jY-Pp for pgsql-general@lists.postgresql.org; Sun, 13 May 2018 11:45:38 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fHpRT-0002BG-Oc for pgsql-general@lists.postgresql.org; Sun, 13 May 2018 11:45:37 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0D5C12264D; Sun, 13 May 2018 07:45:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 13 May 2018 07:45:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=h5+jN2Jzd4lz53FpMZ1xw2yKV+N7ZwH2KFgEa1VONWQ=; b=kvYHijP1 xdYFVyBSmLqUlLqTcLeBqFXL+OK2TRO+nK2zZquwLHH2EC67nQB5PkVSW5xy/mIa jwsHTeTMOmTdRab//PopHbmDUYDdEKl0XXFaddP8XnZQRZgQzu0jG2wEz2iD7Jz+ iXrbBCgosSNdSjoS0H/1aVSI5qN410SgEuR15M+QGv+603K1HkA4x3wLdRV2CfVQ efS5YPBqGOt0458DIp0H0EnU3x1NDAbbpzDL0PjYTO5F+1CM/WyNjZABjni+kS3D LWkkjV+eIYMhUCryCWEGruVYL3uL0mFaf/DJ8zjvGOFRRP/45AOq07V0GUSINCkW R5hlEPFUW46Lmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=h5+jN2Jzd4lz53FpMZ1xw2yKV+N7Z wH2KFgEa1VONWQ=; b=IbNzNyCHRnqX6KWLcjupEb8WdPG/jI51yjsjPZDW6Mx9b iugwbXKixpAzfpMItzhum+tPRKFRBYnT2OPx0Nc9AB3GmSDXktcHvae4r5UB9u3F xcarXJnD6XHzveV+zbYE2HymujGdOEuAwXnSAwBQr58rgdTCqh57bR7g8F5wGRL2 bhy8Z0aDPrbiFNCzWLNoCNxYOyjhF+02J+xmZXC4EMQTknvH8Cl89OhifYO1cQ0u 0DMJlXxTAIJGsbyVMCoaL2xiAl6PtPYpwk7tCDjxI4O+7EHRiTd8sQ8R0MTVlTSn cDJkaUcB9xgHtI0SxHB1pCvQ6aFEP9+lOl658mJDg== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 8128410261; Sun, 13 May 2018 07:45:28 -0400 (EDT) Date: Sun, 13 May 2018 20:45:24 +0900 From: Michael Paquier To: Hannes Erven Cc: pgsql-general@lists.postgresql.org Subject: Re: recovery_target_time and WAL fetch with streaming replication Message-ID: <20180513114524.GD2481@paquier.xyz> References: <20180513062355.GA2481@paquier.xyz> <1ecbd33f-ed2b-fd27-78c1-ac7a43657185@erven.at> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5gxpn/Q6ypwruk0T" Content-Disposition: inline In-Reply-To: <1ecbd33f-ed2b-fd27-78c1-ac7a43657185@erven.at> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --5gxpn/Q6ypwruk0T Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 13, 2018 at 09:42:42AM +0200, Hannes Erven wrote: > But when new WAL is needed, the standby will fetch /all/ WAL present on t= he > master. Fetching as much WAL as possible when recovery happens is wanted by design, so as it recovers as much as possible. And that's documented. > I'd say, the standby should either: > - always connect to the primary and fetch any WAL present This is what a hot standby does. It keeps waiting for WAL to become available whichever the source used (archive, local pg_xlog or stream) and switches between one or the other. You can look at WaitForWALToBecomeAvailable to get an idea of the details. =20 > - stop fetching/streaming WAL when it is not needed for the current > recovery_target The startup process is in charge of recovery (WAL replay and definition of from where to get the WAL available), and is the one which decides if using streaming is necessary or not. if streaming is used, then it starts a WAL receiver. If a switch from streaming to another WAL source (local pg_xlog or archives is done), then it shuts down the WAL receiver, consisting in sending SIGTERM to the WAL receiver and stopping it immediately with a FATAL message (stops process immediately). The key point is that WAL receiver is designed to be a light-weight transport layer for WAL data. In short, to be simple, it receives a set of WAL bytes and writes them. It does not include any logic to decode WAL records, so it cannot know when a stop point happens or not. It also has no idea of the configuration within recovery.conf, which is loaded by the startup process. > Yes, but thats far less simple than just setting restore_target_time . It seems to me that archiving provides the control you are looking for. -- Michael --5gxpn/Q6ypwruk0T Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlr4JVQACgkQnvQgOdby QH2oLxAAhToN/3fkxUpiWyTPQAPzF3a+O1NHFYafoBsc3Yqim1bv43iwz/R7mQ8u vIzBFRxZc/ZtvbpLDGMOp4TS3p/NYp2zLXv3VVKuawsGhojGFbBSAZVcu3W3fry1 yreParVpKkHNEpO96Zjc6GY8G3JymzaFm4D+rESfezsbgNhzjRoOP2DAakdeJYWV XkmVieSO0Je6sfN7qvhAfOzeV9cKyDgBK+OlYL/bz3McvI5BGIxnyZc+eLv1Ooyl T55VGExbbCvol0yJN6ts4pKM2tOXb25yiNV5nQKoFtC7H78jepgWjhZT6NXc9B0G AAaKntpy1rnhwHVr0lj4MGvYyDN5aAU1o4UU4wHYSi9CKKppghKuXo7IsTyX9uy8 oHvKoSNfxQ0R8GFVnCIyn2YhLSESlK302GlcHPVLyg9fBDGyKVgEe2ixskE93Kon hZpYEJmwEzYv579vglSTKR81GmEGpBKBdvf/srBknue60Sd+kuSgXrclwsjBXRZn vLa0p/V2goztv7t4vNeZLUZZ02p/zz1H0zKFKTKu5NS568uwS7dzWZKss5PK+99K RLQl7iTFZYVwRNgzP5F/31di2/7tKVQnPaACnDjB9J4A+goJEZW2Ucey+Fv8pt4z dUUALIqHVRveO4bxqrIeDKiEDNGp0prJbo3JUhZSbttJ975R3ss= =JHvV -----END PGP SIGNATURE----- --5gxpn/Q6ypwruk0T--