Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFe5a-0001Mx-7j for pgsql-docs@arkaria.postgresql.org; Thu, 25 Oct 2018 11:46:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gFe5Y-0001fy-7K for pgsql-docs@arkaria.postgresql.org; Thu, 25 Oct 2018 11:46:08 +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 1gFe5Y-0001fr-1N for pgsql-docs@lists.postgresql.org; Thu, 25 Oct 2018 11:46:08 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gFe5V-000494-OO for pgsql-docs@lists.postgresql.org; Thu, 25 Oct 2018 11:46:07 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1575095D; Thu, 25 Oct 2018 07:46:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 Oct 2018 07:46:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=PUUvzDaDPx0dNsdODrS99pB+6WA aC+0kr44AGkt1UKw=; b=FHm3U5aJDbbdU5yVo+9zrGq6Tb5AiPhbYNVjiALQS8c +cvQX/O+WNLI7i/JWciWOsbDOdFAbaJe9tKLx/9p2AFP6n62I31APS27+LKaD1Sb bu0Dru6gY9O6PJ4B2+S2BVBZdwedAFhvY5kwSjnChR7Py0qnPK8Tk/tUJHE7UBNw qhCBtO/jAlXDMAgQV1OJkxoEcjh+gNgLY9DdHgoeD9SIJNL5NwXm+0bY7yN8RuvU PdEac2WL+3SQvSXgaKWmxXhzQK3+YbPSHDwZOe/f7BvkF/8TJziePZrkm6RNJ3Nx e5IKzIe385AmyAzQZar5oMIBkVxUjJtcXFYJOF30X0g== 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-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=PUUvzD aDPx0dNsdODrS99pB+6WAaC+0kr44AGkt1UKw=; b=L/7vmIr/i66AsKLDISEniE IMbST9LYLE2CV2NHaPzFpD0HYSFvLH/4UPCkcMwm+qDq5yFGaJtOrloRSqLzDnjw 5TaxPX4Nr+loR3X9b1KtHiTiHY1ehatcHnlyiCt05CKPhlCigTo1bQfi5hFjHLVz omcPdxhHQ0Zf1bHm5V3C9w4K+/FUvwbyZWT+Z2EPuLsxOhdDXaQ1GEUeXf4AZxUQ e0C7c9j+Pm0UgqLiFHRAxpmm4IZej+PFRe8Ru0AJ9DeC5wf+iSzJ3yCJ03y3z1AX qA3MZF1f0sTzHpty9ALhSy98EayWUPKkl4sjjP7U6mP9mXxoUICEGEUK7OYQP89w == X-ME-Sender: X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 6B0C0E4074; Thu, 25 Oct 2018 07:46:00 -0400 (EDT) Date: Thu, 25 Oct 2018 20:45:57 +0900 From: Michael Paquier To: Jehan-Guillaume de Rorthais Cc: Nikolay Samokhvalov , pgsql-docs@lists.postgresql.org, pgsql-hackers@postgresql.org Subject: Re: Using old master as new replica after clean switchover Message-ID: <20181025114557.GB1327@paquier.xyz> References: <20181025111551.620c6460@firost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LpQ9ahxlCli8rRTG" Content-Disposition: inline In-Reply-To: <20181025111551.620c6460@firost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --LpQ9ahxlCli8rRTG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 25, 2018 at 11:15:51AM +0200, Jehan-Guillaume de Rorthais wrote: > On Thu, 25 Oct 2018 02:57:18 -0400 > Nikolay Samokhvalov wrote: >> My research shows that some people already rely on the following when >> planned failover (aka switchover) procedure, doing it in production: >>=20 >> 1) shutdown the current master >> 2) ensure that the "master candidate" replica has received all WAL data >> including shutdown checkpoint from the old master >> 3) promote the master candidate to make it new master >> 4) configure recovery.conf on the old master node, while it's inactive >> 5) start the old master node as a new replica following the new master. >=20 > Indeed. The important point here is that the primary will wait for the shutdown checkpoint record to be replayed on the standbys before finishing to shut down. > The only additional nice step would be to be able to run some more safety= tests > AFTER the switchover process on te old master. The only way I can think of > would be to run pg_rewind even if it doesn't do much. Do you have something specific in mind here? I am curious if you're thinking about things like page-level checks for LSN matches under some threshold or such, because you should not have pages on the previous primary which have LSNs newer than the point up to which the standby has replayed. >> if so, let's add it to the documentation, making it official. The patch = is >> attached. >=20 > I suppose we should add the technical steps in a sample procedure? If an addition to the docs is done, symbolizing the steps in a list would be cleaner, with perhaps something in a dedicated section or a new sub-section. The failover flow you are mentioning is good practice because that's safe, and there is always room for improvements in the docs. -- Michael --LpQ9ahxlCli8rRTG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlvRrPUACgkQnvQgOdby QH2YEw//R9/eM3HIfverbYuff2hdOKsm3Xx4YrxHV9IG3xasRHhSg63ubqao30LM lshVDqdu7e8AcmCndtCYkqZ66Ci+xdLVbBZ5HToChlBSDGHVCK74oHd43736U0cn K/h47o16u8anVvJuB7yXdmpA3HjBOIOY/zn5B35NcAinuwSDgxZ2377I/Yz588SE 5bPtXOujEQt2yrTL7uJgln7ZquR8RxIPl4FaYdgfp+ddsqahN32vAWDNndSeBlCf EZl9tLLXjQfo9aGhsFCq7BEbNnHAUB76ZaMuoPVYWglYK/zxYbyEERBHwJ8yAOeB PxFDUzPOe2hAza2lBNFzeX5gxS5fm9i/1F4pQzBMiowhOxuvKuOQ4+7yp9u+MuO9 kmS3dNgcIsE+r198JwpkOz2T9/Yolftj+XdfkVu6oURaiP3f51Fs5gMKsgB/o2y+ TPIAxn/kdKQ+NhOtfxD9RZgE5JvHzq741ZC/Sw2KQ1LNnUSxKdUvhzglvALU2H+y 0hIaLSomF62i32TASsypQEDPz3Ico7uMUsmWDpeGPA5NfMYNeZ61SwHhGbxIzWTf gHiDuaCW+c3qc7oBH145hjICypC+ggCpf+Xeds2/mvpWPZLHAJWvDmiruuvmBBXs Ki+5H4voB7roYkjKr2VKkNpUINv4srRarkd2bI60bDhjBZ2WaWs= =4Gen -----END PGP SIGNATURE----- --LpQ9ahxlCli8rRTG--