Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aq060-0000xI-S9 for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Apr 2016 15:19:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aq060-00027K-DW for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Apr 2016 15:19:16 +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.84_2) (envelope-from ) id 1aq05N-0001QE-8o for pgsql-bugs@postgresql.org; Tue, 12 Apr 2016 15:18:37 +0000 Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1aq05K-0001Ns-5B for pgsql-bugs@postgresql.org; Tue, 12 Apr 2016 15:18:36 +0000 Received: by mail-oi0-x22a.google.com with SMTP id p188so26132918oih.2 for ; Tue, 12 Apr 2016 08:18:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hagander-net.20150623.gappssmtp.com; s=20150623; h=mime-version:date:message-id:subject:from:to:cc; bh=koh7VSQbGudZ5eVo2bGVRBVgkc123ms8uJqZTE58iW4=; b=WSdw7+PCX1GRQ43iLdD1KM6wij1PJ0w9BiMabazQHoa7rtOCpKRHmBxftiqvTCE6Cn 8+b+rSzsS4cvOoF0ZMGDUTlUeJSJ8Pz8kO34fPVPatGAJZIjrYuAapNcJGqRSmz1JvhK Nh02fCgC5cCaIPH3yZ3ztRhh+ActoAwaMxZx77/b/YcMOgBt4tq+MBkGcrhmA0sBdqph l2cdIQKoUnoXaVhFZm0Rr5AR9JEvToYT4mWzqR68gKVHbMX/WkM7W/hrukTT2wvubWTC zfLiPHBcqKYPWakewkLJcEDSEJWDwZWaI6DyBkZrgICbggnBRKdZ+v+zWB4I7y+ZeroC XobQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=koh7VSQbGudZ5eVo2bGVRBVgkc123ms8uJqZTE58iW4=; b=Cv4r9bjxeWsLG4zl/x/vTlw3aMRfP3ADGuecnFUTaaJh7fb7orbqNihiXL9wdHfsj3 l0yCZx3cL3Rwp9yGY05TKwqHeHHDwram0b15+iVEnjq8qJzRHOxY/NoawR9P1xIJDWWG KK0JzgDfPBGO4UKqOPBpbYKJdKkXL+TdoIce7/2gZ5ih9wTviTEfvdhfuCH4vUq9SeI+ xx1nvCMe8hDlcOhy+tdrRTSahadu+x4vZ2XWRmKMB++3h73ZelItchUC0zZYfWmkYlBX 7ABRw4GlIWrj4RLx1fk2HD/3f+gplDv8GxmIi2Z90U89K8ZSNOshotf5iUE8yxX9G10w PAPQ== X-Gm-Message-State: AOPr4FVA5Aj028BUa+7K6N/qynxk/sGvleN7RtXFdpNG562d45HbHnvNzv0mFCSLjRGth48sYb+MiWZbkpQiMA== MIME-Version: 1.0 X-Received: by 10.157.0.73 with SMTP id 67mr1889034ota.137.1460474312947; Tue, 12 Apr 2016 08:18:32 -0700 (PDT) Received: by 10.157.15.104 with HTTP; Tue, 12 Apr 2016 08:18:32 -0700 (PDT) Date: Tue, 12 Apr 2016 17:18:32 +0200 Message-ID: Subject: Repeated requests for feedback in logical standby From: Magnus Hagander To: pgsql-bugs Cc: Marko Tiikkaja Content-Type: multipart/alternative; boundary=94eb2c11f30ea0911e05304b2c99 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --94eb2c11f30ea0911e05304b2c99 Content-Type: text/plain; charset=UTF-8 I've been running some tests, and come across a weird behavior on shutdown with logical replication, 9.5.2. It seems that on shutdown, a lot of extra requests for feedback are sent from the walsender. On my laptop I get about 3-15 requests (different each time), and on a server with a bit more power but still very low activity, the number is simply huge. Basically what happens is: * Replication works fine * I have *zero* activity on the master since it got started, not even a single psql * I issue a fast shutdown on the master * Nothing happens at all for a while * Once pg_recvlogical times out and sends a status message things wake up * The server sends a whole bunch of requests for status, which pg_recvlogical responds to * Eventually things shut down (on the proper server, I've had to kill things because it takes too long - I'm unsure if it ever shuts down) Log output from pg_recvlogical: $ ./pg_recvlogical -v -p 5495 -S trivialslot -o include_transaction=on -v -d postgres --start -f - -P test_decoding 2>&1 | ts '[%Y-%m-%d %H:%M:%S]' [2016-04-12 17:14:31] pg_recvlogical: starting log streaming at 0/0 (slot trivialslot) [2016-04-12 17:14:31] pg_recvlogical: streaming initiated [2016-04-12 17:14:31] pg_recvlogical: confirming write up to 0/0, flush to 0/0 (slot trivialslot) [2016-04-12 17:14:41] pg_recvlogical: confirming write up to 0/18F9DE88, flush to 0/18F9DE88 (slot trivialslot) [2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DEF8, flush to 0/18F9DEF8 (slot trivialslot) [2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DFA0, flush to 0/18F9DFA0 (slot trivialslot) [2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DFA0, flush to 0/18F9DFA0 (slot trivialslot) [2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DFA0, flush to 0/18F9DFA0 (slot trivialslot) [2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DFA0, flush to 0/18F9DFA0 (slot trivialslot) [2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DFA0, flush to 0/18F9DFA0 (slot trivialslot) [2016-04-12 17:14:51] pg_recvlogical: disconnected; waiting 5 seconds to try again In this example, the server has: 2016-04-12 17:14:45 CEST LOG: received fast shutdown request 2016-04-12 17:14:45 CEST LOG: aborting any active transactions 2016-04-12 17:14:45 CEST LOG: autovacuum launcher shutting down 2016-04-12 17:14:45 CEST LOG: shutting down 2016-04-12 17:14:45 CEST LOG: database system is shut down Note how it took a while (6 seconds) for pg_recvlogical to pick up that anything was happening - looks like something might not have been flushed? When running on the server where there's more data it was very clear though - if I break the walsender with gdb, pg_recvlogical stops spitting out debugging messages, and as soon as I "cont" in gdb it starts spitting them out again, so there's a clear connection between the two. And it takes a *lot* more than a few seconds. -- Magnus Hagander Me: http://www.hagander.net/ Work: http://www.redpill-linpro.com/ --94eb2c11f30ea0911e05304b2c99 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I've been running some tests, and come across a weird = behavior on shutdown with logical replication, 9.5.2. It seems that on shut= down, a lot of extra requests for feedback are sent from the walsender.
On my laptop I get about 3-15 requests (different each time= ), and on a server with a bit more power but still very low activity, the n= umber is simply huge.

Basically what h= appens is:

* Replication works fine
* I = have *zero* activity on the master since it got started, not even a single = psql
* I issue a fast shutdown on the master
* Nothing = happens at all for a while
* Once pg_recvlogical times out and se= nds a status message things wake up
* The server sends a whole bu= nch of requests for status, which pg_recvlogical responds to
* Ev= entually things shut down (on the proper server, I've had to kill thing= s because it takes too long - I'm unsure if it ever shuts down)


Log output from pg_recvlogical:
=
$ ./pg_recvlogical -v -p 5495 -S trivialslot -o include= _transaction=3Don -v -d postgres --start -f - -P test_decoding 2>&1 = | ts '[%Y-%m-%d %H:%M:%S]'
[2016-04-12 17:14:31] pg_recvl= ogical: starting log streaming at 0/0 (slot trivialslot)
[2016-04= -12 17:14:31] pg_recvlogical: streaming initiated
[2016-04-12 17:= 14:31] pg_recvlogical: confirming write up to 0/0, flush to 0/0 (slot trivi= alslot)
[2016-04-12 17:14:41] pg_recvlogical: confirming write up= to 0/18F9DE88, flush to 0/18F9DE88 (slot trivialslot)
[2016-= 04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DEF8, flush to= 0/18F9DEF8 (slot trivialslot)
[2016-04-12 17:14:51] pg_recvlogic= al: confirming write up to 0/18F9DFA0, flush to 0/18F9DFA0 (slot trivialslo= t)
[2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0= /18F9DFA0, flush to 0/18F9DFA0 (slot trivialslot)
[2016-04-12 17:= 14:51] pg_recvlogical: confirming write up to 0/18F9DFA0, flush to 0/18F9DF= A0 (slot trivialslot)
[2016-04-12 17:14:51] pg_recvlogical: confi= rming write up to 0/18F9DFA0, flush to 0/18F9DFA0 (slot trivialslot)
<= div>[2016-04-12 17:14:51] pg_recvlogical: confirming write up to 0/18F9DFA0= , flush to 0/18F9DFA0 (slot trivialslot)
[2016-04-12 17:14:51] pg= _recvlogical: disconnected; waiting 5 seconds to try again
=

In this example, the server has:
2016-04-12 17:14:45 CEST LOG: =C2=A0received fast shutdown request
2016-04-12 17:14:45 CEST LOG: =C2=A0aborting any active transactio= ns
2016-04-12 17:14:45 CEST LOG: =C2=A0autovacuum launcher shutti= ng down
2016-04-12 17:14:45 CEST LOG: =C2=A0shutting down
2016-04-12 17:14:45 CEST LOG: =C2=A0database system is shut down


Note how it took a while (6 seconds)= for pg_recvlogical to pick up that anything was happening - looks like som= ething might not have been flushed?

When running o= n the server where there's more data it was very clear though - if I br= eak the walsender with gdb, pg_recvlogical stops spitting out debugging mes= sages, and as soon as I "cont" in gdb it starts spitting them out= again, so there's a clear connection between the two. And it takes a *= lot* more than a few seconds.

--
=C2=A0Magnus Hagander
=C2=A0Me: http://www.hagander.net/
=C2=A0Work: http://www.redpil= l-linpro.com/
--94eb2c11f30ea0911e05304b2c99--