Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNByY-0003MP-3H for pgsql-general@arkaria.postgresql.org; Tue, 29 Sep 2020 09:31:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNByX-0007kV-0r for pgsql-general@arkaria.postgresql.org; Tue, 29 Sep 2020 09:31:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNByW-0007kO-Gg for pgsql-general@lists.postgresql.org; Tue, 29 Sep 2020 09:31:08 +0000 Received: from mail1.dalibo.net ([212.83.143.11] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNByR-0000Jh-L3 for pgsql-general@postgresql.org; Tue, 29 Sep 2020 09:31:08 +0000 Received: from firost (larco.ioguix.net [82.66.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id E10A220435; Tue, 29 Sep 2020 11:31:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1601371860; bh=KksfITYrRIVKFzHidlaq0G+K5pr9aws8VELYQIIpwBQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=q78TYBoWsIrTcR+IKBVa6qDsqBeSTy5f/DGWeP5B+qGwB45aUafOja2gHsCWsv+r3 V5E+jVpfgjhowTSkwv1QyNNk2bX3JuhJLDCGZp2rhDr2AsTKLMGe+QmcUOby4KtUl7 lgjsDHGdOlhacvaZeb1IYOvZ3qWQ1WblPXkDJ1zM= Date: Tue, 29 Sep 2020 11:31:00 +0200 From: Jehan-Guillaume de Rorthais To: =?UTF-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= Cc: pgsql-general Subject: Re: BUG? Slave don't reconnect to the master Message-ID: <20200929113100.70b57e60@firost> In-Reply-To: <2045A2B7-E972-44EF-B1D3-B86618FC9780@ya.ru> References: <60590EC6-4062-4F25-A49C-3948ED2A7D47@ya.ru> <20200819150713.326c3532@firost> <52BADD0F-E348-43BB-8992-FDE86F3B1A65@ya.ru> <20200821162642.4245add6@firost> <253962B4-CB29-4A90-A995-17B6047D3876@ya.ru> <20200903133915.1850e955@firost> <8323CF21-D316-4529-BFC3-77C97F8E341B@ya.ru> <20200909171931.64fce7bb@firost> <2045A2B7-E972-44EF-B1D3-B86618FC9780@ya.ru> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 24 Sep 2020 15:22:46 +0300 =D0=9E=D0=BB=D0=B5=D0=B3 =D0=A1=D0=B0=D0=BC=D0=BE=D0=B9=D0=BB=D0=BE=D0=B2 <= splarv@ya.ru> wrote: > Hi, Jehan. >=20 > > On 9 Sep 2020, at 18:19, Jehan-Guillaume de Rorthais > > wrote: > >=20 > > On Mon, 7 Sep 2020 23:46:17 +0300 > > =D0=9E=D0=BB=D0=B5=D0=B3 =D0=A1=D0=B0=D0=BC=D0=BE=D0=B9=D0=BB=D0=BE=D0= =B2 wrote: > > =20 > >>> [...] =20 > >>>>>> 10:30:55.965 FATAL: terminating walreceiver process dpue to > >>>>>> administrator cmd 10:30:55.966 LOG: redo done at 0/1600C4B0 > >>>>>> 10:30:55.966 LOG: last completed transaction was at log time > >>>>>> 10:25:38.76429 10:30:55.968 LOG: selected new timeline ID: 4 > >>>>>> 10:30:56.001 LOG: archive recovery complete > >>>>>> 10:30:56.005 LOG: database system is ready to accept connections = =20 > >>>>> =20 > >>>>>> The slave with didn't reconnected replication, tuchanka3c. Also I > >>>>>> separated logs copied from the old master by a blank line: > >>>>>>=20 > >>>>>> [...] > >>>>>>=20 > >>>>>> 10:20:25.168 LOG: database system was interrupted; last known up = at > >>>>>> 10:20:19 10:20:25.180 LOG: entering standby mode > >>>>>> 10:20:25.181 LOG: redo starts at 0/11000098 > >>>>>> 10:20:25.183 LOG: consistent recovery state reached at 0/11000A68 > >>>>>> 10:20:25.183 LOG: database system is ready to accept read only > >>>>>> connections 10:20:25.193 LOG: started streaming WAL from primary = at > >>>>>> 0/12000000 on tl 3 10:25:05.370 LOG: could not send data to clien= t: > >>>>>> Connection reset by peer 10:26:38.655 FATAL: terminating walrecei= ver > >>>>>> due to timeout 10:26:38.655 LOG: record with incorrect prev-link > >>>>>> 0/1200C4B0 at 0/1600C4D8 =20 > >>>>>=20 > >>>>> This message appear before the effective promotion of tuchanka3b. D= o you > >>>>> have logs about what happen *after* the promotion? =20 > >>>>=20 > >>>> This is end of the slave log. Nothing. Just absent replication. =20 > >>>=20 > >>> This is unusual. Could you log some more details about replication > >>> tryouts to your PostgreSQL logs? Set log_replication_commands and low= er > >>> log_min_messages to debug ? =20 > >>=20 > >> Sure, this is PostgreSQL logs for the cluster tuchanka3. > >> Tuchanka3a is an old (failed) master. =20 > >=20 > > According to your logs: > >=20 > > 20:29:41 tuchanka3a: freeze > > 20:30:39 tuchanka3c: wal receiver timeout (default 60s timeout) > > 20:30:39 tuchanka3c: switched to archives, and error'ed (expected) > > 20:30:39 tuchanka3c: switched to stream again (expected) > > no more news from this new wal receiver=20 > > 20:34:21 tuchanka3b: promoted > >=20 > > I'm not sure where your floating IP is located at 20:30:39, but I suppo= se it > > is still on tuchanka3a as the wal receiver don't hit any connection err= or > > and tuchanka3b is not promoted yet. =20 >=20 > I think so. >=20 > >=20 > > So at this point, I suppose the wal receiver is stuck in libpqrcv_conne= ct > > waiting for frozen tuchanka3a to answer, with no connection timeout. You > > might track tcp sockets on tuchanka3a to confirm this. =20 >=20 > I don't know how to do this. Use ss, see its manual page. Hare is an example, using standard 5432 pgsql = port: ss -tapn 'dport =3D 5432 or sport =3D 5432' Look for Local and Peer addresses and their status. > > To avoid such a wait, try to add eg. connect_timeout=3D2 to your > > primary_conninfo parameter. See: > > https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMK= EYWORDS =20 >=20 > Nope, this was not enough. But I went further and I added tcp keepalive > options too. So now paf file, for instance in tuchanka3c, is: >=20 > # recovery.conf for krogan3, pgsqlms pacemaker module > primary_conninfo =3D 'host=3Dkrogan3 user=3Dreplicant application_name=3D= tuchanka3c > connect_timeout=3D5 keepalives=3D1 keepalives_idle=3D1 keepalives_interva= l=3D3 > keepalives_count=3D3' recovery_target_timeline =3D 'latest' standby_mode = =3D 'on' >=20 > And now the problem with PostgreSQL-STOP is solved. But I surprised, why = this > was needed? I though that wal_receiver_timeout must be enough for this ca= se. Because wal_receiver_timeout apply on already established and streaming connections, when the server end streaming becomes silent. The timeout you have happen during the connection establishment, where connect_timeout takes effect. In regards with keepalive parameters, I am a bit surprised. According to the source code, parameters defaults are: keepalives=3D1 keepalives_idle=3D1 keepalives_interval=3D1 keepalives_count=3D1 But I just had a quick look there, so I probably miss something. Regards,