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 1fQZJ7-0005Nx-2s for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 14:21:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQZJ5-0008FL-Nu for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 14:20:59 +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 1fQZJ5-0008FC-Fo for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 14:20:59 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQZJ2-0003bn-AF for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 14:20:59 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2987221E99; Wed, 6 Jun 2018 10:20:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 06 Jun 2018 10:20:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=kR08aZsz6n+TSbTt7D85v1HnuD1r5 5V7yn+hakayqIg=; b=mS7LmuyvHZzMjeXVg4dLWxnVzkq4MNl/c48aZszDtIW6Q EAgAwoGHf7b3nbyNboqeSZ74o2afLIfIt8Wr6MQRQQCM9bXoQZsCndnHjj4BYy/c ZcFAX4C+fU3njITzIJR9ewAXNnuBm2duyFxXBx6uM5ff2ZNr9P3NL55dZeANu2dy /ewCqKK7AlwDUl1t+P0KB57HQdrry6G8TyVmn3Py/TqR6rHA2505RXDF4hGi1UVg mSjG4W10IIuHRcEDHyixbnBZTC/Wctm1VuBfGg2n0TCrZ38kMXq0UkiQwvg28XXM FxqFULOhy50c9LfVX0KnGLywVf7svj6Wo495o6lUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding: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=kR08aZ sz6n+TSbTt7D85v1HnuD1r55V7yn+hakayqIg=; b=Gsu13pis8oHfMDyCAAmvtO 2k5vaEli2rv5ZbWj5NEZXuNeevZPAE6yd1juyOEcJvkUVGGvnd4YV701alX3Pxdr otVUBeW4vXNunibcN3z9dELrOtZxEaSgOHkvq07VWBQNjLcvMwDxNu/3DZ2JXKdE XbKkXj/cwqyhMZzk9NldgC0s+UvAwBQWMlqWJcE39EshLGt0vt9LyWtfZBqQwIGU nVWNtvbA4pS6xqdiL1C9TkwtbH/vjpiZp9xq1yXog/Q9poVIO+lFssQE5jCQVnA2 6tyx1QOqtolB2zNYT5bYXH6+pe1m0gVqpjdBa/wemnBY435jdzbe0o7EyJ0fRXsA == X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.159.209]) by mail.messagingengine.com (Postfix) with ESMTPA id 907F2E40A3; Wed, 6 Jun 2018 10:20:54 -0400 (EDT) Subject: Re: Failover replication building a new master To: Tom Loder , "pgsql-general@lists.postgresql.org" References: From: Adrian Klaver Message-ID: <32f5d09a-3989-1c68-18c2-cdf21cd7d8ad@aklaver.com> Date: Wed, 6 Jun 2018 07:20:53 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 06/05/2018 05:43 AM, Tom Loder wrote: > I am using Postgres 10.4, and using replication, I have managed to set up four servers, with one running as a master and the other three running with streaming replication from the master. > > I have used the command: > psql -c "ALTER SYSTEM SET synchronous_standby_names TO 'FIRST 1(S2,S3,S4)';" so that at least one of the three slave clusters are SYNCED to the master. > > If I run the following command I get the following back: > > SELECT pid, usename, application_name as name,state, client_addr, sent_lsn, write_lsn, flush_lsn, replay_lsn, sync_priority, sync_state FROM pg_stat_replication; > > pid | usename | name | state | sent_lsn | write_lsn | flush_lsn | replay_lsn | sync_priority | sync_state > -------+---------+-------+-----------+-------------+-----------+-----------+-----------+------------+---------------+------------ > 26215 | replica | S3 | streaming | 0/6000000 | 0/6000000 | 0/6000000 | 0/6000000 | 2 | potential > 26200 | replica | S4 | streaming | 0/6000000 | 0/6000000 | 0/6000000 | 0/6000000 | 3 | potential > 26186 | replica | S2 | streaming | 0/6000000 | 0/6000000 | 0/6000000 | 0/6000000 | 1 | sync > > When I take out my master server (S1) I setup S2 as the master using a bash script and I update the recovery.conf files on the other two servers to change the replication to run from S2. I am not sure what is going on here as I am not that familiar with synchronous replication. I do think it would aid those that can help if you provided the contents of : 1) The Bash script 2) The recovery.conf file. Also are there relevant log entries for S2, S3 and S4? > I have changed the setting for synchronouse_standby_names using: > > psql -c "ALTER SYSTEM SET synchronous_standby_names TO 'FIRST 1(S1,S3,S4)';" hoping that one of the remaining two or possibly the old master will SYNC to the new master (S2). > > However when I check on S2 I get the following output from pg_stat_replication: > > pid | usename | name | state | sent_lsn | write_lsn | flush_lsn | replay_lsn | sync_priority | sync_state > ------+---------+-------+---------+-------------+-----------+-----------+-----------+------------+---------------+------------ > 6418 | replica | S4 | startup | 0/D000098 | 0/D000098 | 0/D000098 | 0/D000098 | 3 | potential > 6417 | replica | S3 | startup | 0/D000098 | 0/D000098 | 0/D000098 | 0/D000098 | 2 | potential > > If I also get the original master (S1) running and set it up as a Slave this also will not "SYNC". How can I get the standby servers to SYNC to the new Master (S2) without doing a new BaseBackup from S2 to the other servers? > > Thanks > > Tom > > > > > > > > -- Adrian Klaver adrian.klaver@aklaver.com