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 1f5vIe-00031x-Nb for pgsql-general@arkaria.postgresql.org; Tue, 10 Apr 2018 15:35:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f5vId-0000KO-8b for pgsql-general@arkaria.postgresql.org; Tue, 10 Apr 2018 15:35:11 +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 1f5vIc-0000JM-T1 for pgsql-general@lists.postgresql.org; Tue, 10 Apr 2018 15:35:11 +0000 Received: from server5.simfrete.com ([177.52.183.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f5vIX-0002j5-BV for pgsql-general@lists.postgresql.org; Tue, 10 Apr 2018 15:35:08 +0000 Received: from [192.168.10.30] (unknown [177.52.183.17]) by server5.simfrete.com (Postfix) with ESMTPSA id 7295424B409 for ; Tue, 10 Apr 2018 12:38:42 -0300 (-03) Subject: Re: Postgresql Split Brain: Which one is latest To: pgsql-general@lists.postgresql.org References: From: Edson Carlos Ericksson Richter Message-ID: <45638fd9-29c2-f3e8-4399-30f011cb2ecd@simkorp.com.br> Date: Tue, 10 Apr 2018 12:35:00 -0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: pt-BR List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Em 10/04/2018 12:28, Melvin Davidson escreveu: > > > On Tue, Apr 10, 2018 at 11: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. > > 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 > > > > *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! I'm just trying to understand the scenario... Correct me if I'm wrong, if you had two servers acting as master for a while, then you have inserted/updated records on both servers, and you will need some kind of "merge" of records into one of the databases, that will become the new updated master... If you have "sequences" (or "serial" fields), then you will get a bit trouble in your hands. Regards, Edson