Re: Postgresql Split Brain: Which one is latest

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: Vikas Sharma <shavikas(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgresql Split Brain: Which one is latest
Date: 2018-04-10 15:28:52
Message-ID: CANu8FiyQfa5mxj6aOc5yYsfis_ArEOiDHJOyb6jcGzi0wY6WEA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Apr 10, 2018 at 11:04 AM, Vikas Sharma <shavikas(at)gmail(dot)com> 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.
>
> Regards
> Vikas
>
> On 10 April 2018 at 15:26, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)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(dot)klaver(at)aklaver(dot)com
>>
>
>

*Vikas,*

*Presuming the the real "master" will have additional records/rows inserted
in the tables,*

*if you run ANALYZE on the database(s) in both "masters", then execute the
following query *

*on both, whichever returns the highest count would be the real
"master". SELECT sum(c.reltuples::bigint) FROM pg_stat_all_tables s
JOIN pg_class c ON c.oid = s.relid WHERE s.relname NOT LIKE 'pg_%' AND
s.relname NOT LIKE 'sql_%';*

--
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edson Carlos Ericksson Richter 2018-04-10 15:35:00 Re: Postgresql Split Brain: Which one is latest
Previous Message Vikas Sharma 2018-04-10 15:04:52 Re: Postgresql Split Brain: Which one is latest