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 1f5wVt-0007zZ-PI for pgsql-general@arkaria.postgresql.org; Tue, 10 Apr 2018 16:52:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f5wVs-00048Z-Ay for pgsql-general@arkaria.postgresql.org; Tue, 10 Apr 2018 16:52:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f5wVr-00048P-Oy for pgsql-general@lists.postgresql.org; Tue, 10 Apr 2018 16:52:56 +0000 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f5wVp-0004pV-5X for pgsql-general@lists.postgresql.org; Tue, 10 Apr 2018 16:52:54 +0000 Received: by mail-oi0-x244.google.com with SMTP id t16-v6so11832949oih.3 for ; Tue, 10 Apr 2018 09:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=xaYFRaE/jb7Tx0XqYDmmViSQZPogL+oUXuxxmfrLEbw=; b=fVZcvbBuqkinkJNwf0yLmre92NO2bzKNmegv9G/Or+o+d1dQVDja+gfjDMeqlce90s k02KjunC48/rSZR0m+I3AH3qcfyQSC6kd1752AypfYHTH1B/cQPWzTdU+5f5oRkwl0Sy 4buiLa2BY2oT7I4cq5+xd0FiLXkEaXawggRrgOqXeCHC5ztqg3fYdjmKmD6fqnrgKSy2 SkpUp+uh9OhlrNZv5ThzPHk5tIv+Zmt2l3CdgG799y/TYcC6j5z0quoSloFhhuEEmiuy gzh7EJ15ebA2REIJQXuk1JvgLf0mImv904qitdESrZHcb3Oi1ajBmK0mkADHbVazNjfR NfFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=xaYFRaE/jb7Tx0XqYDmmViSQZPogL+oUXuxxmfrLEbw=; b=Ies8BblPhROtlSznlf2j22EYKUQCbd+VMDvxDfahA8ojPU74wBzlgKr4/ttFRzw4fx 3niLQ+RfeNGOmSNsS0F5mHO1ld+NRwDBilp88XZwV8P8leqC1Iri0T2Jo8LNNI+JOmpH WZyJg+9iAAdCvWL5NxNVRmn58C1OK+yZxcxDLSUcOSRTui1rvVarX5jsi4gig/I6oguM Bv8Ol7r2Urew6hyKWJpzc0sFT30MzCEohqOqcqhW5grlTzpfWVqkMCmEE5k0ly0H9AFb 5D+vtkH3vu6HFay+8Yc+TQtmlrEs0Ap+AMomRytlp8OPZNfcD8sSG0eTUc+z/dIKnKVT /1GQ== X-Gm-Message-State: ALQs6tA8GVp9PEBcbkHVGhjTxPXntkgwCbrFJmv8KaDNJZBNhHqIcYBd pb/6D1+GKhZwjLg494t65wipLA== X-Google-Smtp-Source: AIpwx4+sqrioShiKhvV6zASot/YxAy2jIbWDN8bOrVD52vlIOe7V/oGaaLAOJRbgKvCb1a/iBv5i2g== X-Received: by 2002:aca:f13:: with SMTP id 19-v6mr803458oip.298.1523379171937; Tue, 10 Apr 2018 09:52:51 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id p65-v6sm721314oia.18.2018.04.10.09.52.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 09:52:50 -0700 (PDT) Subject: Re: Postgresql Split Brain: Which one is latest To: pgsql-general@lists.postgresql.org References: <20ab2308-f781-ef04-3a99-7197dc83315b@aklaver.com> From: Ron Message-ID: <374d1972-342d-2ccb-8a48-db4a1272587b@gmail.com> Date: Tue, 10 Apr 2018 11:52:50 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B065F242FEE09B8B60E2EAB4" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------B065F242FEE09B8B60E2EAB4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit You need to find out when the split happened, and whether each new master have records since then. On 04/10/2018 11: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? > > 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 > -- Angular momentum makes the world go 'round. --------------B065F242FEE09B8B60E2EAB4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit You need to find out when the split happened, and whether each new master have records since then.

On 04/10/2018 11: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?

Thanks and Regards
Vikas

On Tue, Apr 10, 2018, 17:29 Adrian Klaver <adrian.klaver@aklaver.com> 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 <adrian.klaver@aklaver.com
> <mailto:adrian.klaver@aklaver.com>> 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 <mailto:adrian.klaver@aklaver.com>
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com

--
Angular momentum makes the world go 'round.
--------------B065F242FEE09B8B60E2EAB4--