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 1f5yny-0000jl-7C for pgsql-general@arkaria.postgresql.org; Tue, 10 Apr 2018 19:19:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f5ynx-0000LY-8b for pgsql-general@arkaria.postgresql.org; Tue, 10 Apr 2018 19:19:45 +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 1f5ynx-0000LN-0l for pgsql-general@lists.postgresql.org; Tue, 10 Apr 2018 19:19:45 +0000 Received: from smtp5-g21.free.fr ([2a01:e0c:1:1599::14]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f5ynr-0006tV-QY for pgsql-general@postgresql.org; Tue, 10 Apr 2018 19:19:44 +0000 Received: from firost (unknown [109.9.177.220]) (Authenticated sender: ioguix) by smtp5-g21.free.fr (Postfix) with ESMTPSA id DB2905FFED; Tue, 10 Apr 2018 21:19:32 +0200 (CEST) Date: Tue, 10 Apr 2018 21:19:30 +0200 From: "Jehan-Guillaume (ioguix) de Rorthais" To: Vikas Sharma Cc: pgsql-general@postgresql.org Subject: Re: Postgresql Split Brain: Which one is latest Message-ID: <20180410211930.10fa058f@firost> In-Reply-To: References: <20ab2308-f781-ef04-3a99-7197dc83315b@aklaver.com> <2ed1cf8f-4266-6d6c-bc65-7a79a4e7f241@aklaver.com> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 10 Apr 2018 17:02:39 +0000 Vikas Sharma wrote: > Max count is one way (vague I agree), before confirming I will ask the > application owner to have a look on data in tables as well. Maybe you could compare your tables on both sides using a tool like pg_comparator? See: https://cri.ensmp.fr/people/coelho/pg_comparator/pg_comparator.html By the way, what are you using for your auto-failover? What went wrong to end-up with a split brain situation? Regards, > On Tue, Apr 10, 2018, 17:55 Adrian Klaver wrote: > > > On 04/10/2018 09:47 AM, Vikas Sharma wrote: > > > Thanks Adrian and Edison, I also think so. At the moment I have 2 > > > masters, as soon as slave is promoted to master it starts its own > > > timeline and application might have added data to either of them or > > > both, only way to find out correct master now is the instance with max > > > count of data in tables which could incur data loss as well. Correct me > > > if wrong please? > > > > Not sure max count is necessarily a valid indicator: > > > > 1) What if there was a legitimate large delete process? > > > > 2) The application/end users where looking at two different views of the > > data at different points in time. Just because the count is higher does > > not mean the data is actually valid. > > > > > > > > Thanks and Regards > > > Vikas > > > > > > On Tue, Apr 10, 2018, 17:29 Adrian Klaver > > > wrote: > > > > > > On 04/10/2018 08:04 AM, Vikas Sharma wrote: > > > > Hi Adrian, > > > > > > > > This can be a good example: Application server e.g. tomcat having > > two > > > > entries to connect to databases, one for master and 2nd for Slave > > > > (ideally used when slave becomes master). If application is not > > > able to > > > > connect to first, it will try to connect to 2nd. > > > > > > So the application server had a way of seeing the new master(old > > slave), > > > in spite of the network glitch, that the original master database > > > did not? > > > > > > If so and it was distributing data between the two masters on an > > unknown > > > schedule, then as Edison pointed out in another post, you really > > have a > > > split brain issue. Each master would have it's own view of the data > > and > > > latest update would really only be relevant for that master. > > > > > > > > > > > Regards > > > > Vikas > > > > > > > > On 10 April 2018 at 15:26, Adrian Klaver > > > > > > > > > >> wrote: > > > > > > > > On 04/10/2018 06:50 AM, Vikas Sharma wrote: > > > > > > > > Hi, > > > > > > > > We have postgresql 9.5 with streaming > > > replication(Master-slave) > > > > and automatic failover. Due to network glitch we are in > > > > master-master situation for quite some time. Please, > > > could you > > > > advise best way to confirm which node is latest in terms > > of > > > > updates to the postgres databases. > > > > > > > > > > > > It might help to know how the two masters received data when > > they > > > > where operating independently. > > > > > > > > > > > > Regards > > > > Vikas Sharma > > > > > > > > > > > > > > > > -- > > > > Adrian Klaver > > > > adrian.klaver@aklaver.com > > > > >> > > > > > > > > > > > > > > > > > -- > > > Adrian Klaver > > > adrian.klaver@aklaver.com > > > > > > > > > -- > > Adrian Klaver > > adrian.klaver@aklaver.com > > -- Jehan-Guillaume de Rorthais Dalibo