Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yb9Nz-0002mr-NU for pgsql-admin@arkaria.postgresql.org; Thu, 26 Mar 2015 15:07:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yb9Nx-0000Oa-Tj for pgsql-admin@arkaria.postgresql.org; Thu, 26 Mar 2015 15:07:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yb9Nv-0000OQ-RC for pgsql-admin@postgresql.org; Thu, 26 Mar 2015 15:07:51 +0000 Received: from mailout.easymail.ca ([64.68.201.169]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Yb9Nr-00034b-HD for pgsql-admin@postgresql.org; Thu, 26 Mar 2015 15:07:50 +0000 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id C850DE33E; Thu, 26 Mar 2015 11:07:40 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at mailout.easymail.ca X-Spam-Flag: NO X-Spam-Score: -3.936 X-Spam-Level: X-Spam-Status: No, score=-3.936 required=5 tests=[ALL_TRUSTED=-1.8, AWL=-0.229, BAYES_00=-2.599, DNS_FROM_AHBL_RHSBL=0.692] Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (easymail-mailout.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5ZoJMo9UiWYE; Thu, 26 Mar 2015 11:07:40 -0400 (EDT) Received: from [192.168.2.16] (unknown [8.39.228.5]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 2A4CEE2AB; Thu, 26 Mar 2015 11:07:40 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Subject: Re: postgres hot-standby questions. From: Scott Ribe In-Reply-To: <848F3721-4A21-4260-9640-8F698E3EE376@skogoglandskap.no> Date: Thu, 26 Mar 2015 09:07:37 -0600 Cc: "pgsql-admin@postgresql.org" , Simon Riggs Content-Transfer-Encoding: quoted-printable Message-Id: <3C08D5DD-0702-4136-BBE3-21CBE064ADDE@elevated-dev.com> References: <848F3721-4A21-4260-9640-8F698E3EE376@skogoglandskap.no> To: "Graeme B. Bell" X-Mailer: Apple Mail (2.2070.6) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org On Mar 26, 2015, at 8:17 AM, Graeme B. Bell wrote: >=20 > shutdown A (Master) > shutdown B (Standby) > (A and B should be identical in terms of WAL and logical data at this po= int). > swap M/S configurations around > start B (Master) First, note that you don't actually have to shut down B and swap master/sla= ve configs. You can use trigger_file in recovery.conf. In general, with async replication, you don't know that every last transact= ion is replicated at any moment. (And of course with synch replication, you= add points of failure.) I don't actually know the answer to your questions= , because in my use, the connection between server & replica is high-bandwi= dth low-latency. My routine is to shut down all services that access the db= , then shut down the db. The progression of service shutdown pretty much gu= arantees that if the connection is up, the replica is up to date well befor= e the master is shut down. So all I have to do is, after access is shut dow= n use one of the many methods to check replication lag, just as a double-ch= eck that replication was working. It does seem to me it would be a good idea to 1) document explicitly in 17.= 5 "Shutting Down the Server" what happens with async replication (I suspect= all your guesses are correct) and 2) provide some option to wait for repli= cation to finish. The thing about 2 is that we probably don't want it to be automatic or defa= ult, because the nature of asynch replicas is that it's not uncommon to hav= e ones far away, over slower less-reliable links, which may take an unknown= amount of time to come up to date. It's not uncommon to want to bring the = master down for a point update or some config change, and immediately bring= it back up, in which case we don't want the shutdown delayed. It's also no= t uncommon to have multiple replicas, some close by that should probably be= always up-to-date, and some far away for protection against big disasters,= which may lag. So the "wait for replica" option to shut down would need a = way to specify *which* replica/s we wanted to wait for. --=20 Scott Ribe scott_ribe@elevated-dev.com http://www.elevated-dev.com/ https://www.linkedin.com/in/scottribe/ (303) 722-0567 voice --=20 Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin