Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3Q6m-0002gy-O7 for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Jan 2014 13:02:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W3Q6l-0000bS-DB for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Jan 2014 13:02:11 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3Q6c-0000Nv-81 for pgsql-bugs@postgresql.org; Wed, 15 Jan 2014 13:02:02 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W3Q6Z-0006VV-2c for pgsql-bugs@postgresql.org; Wed, 15 Jan 2014 13:02:01 +0000 Received: from anarazel.de (p5DDC7722.dip0.t-ipconnect.de [93.220.119.34]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0Lgw8E-1VWsaM1Ada-00oPXC; Wed, 15 Jan 2014 14:01:53 +0100 Received: by anarazel.de (Postfix, from userid 1000) id 75BBE100AAA; Wed, 15 Jan 2014 14:01:50 +0100 (CET) Date: Wed, 15 Jan 2014 14:01:50 +0100 From: Andres Freund To: PostgreSQL Bugs , Heikki Linnakangas , Amit Kapila Subject: hot_standby_feedback doesn't work on busy servers in 9.3+ Message-ID: <20140115130150.GB8653@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Provags-ID: V02:K0:sB54SNRWO6kP9Vp9C6HsUktCQYpbnOwKPcxdDb6rGqy AxPm7WW0pZMvPIKm0aQzPTGB75jjOjyzqYqYXDOZf6RNDQDsAE NzgrKPKntz6gE6BCg0c/cZsNzFtTnVKPF2/yIU8zT9tnZALN9i i7UPLzgwy3lgLD1A8snU4z+V3khMspGPNg3kxoYfsHQ1HMh3F4 0Vj7MyGOM50zD8y4Zo44A2SIq01ywa0R8hwhMyQdFkmlDZ54QZ qIOaKGcETdklc56bCwtlp/Ke9haFBA+FHvvTSzhDb9dRGxTGHL fAoOI7yzVNmm+KkHEuEOIlxYbpxID2oS8L9Hf36OCOygPWHS6f HSw5JWSY1ybjivXVU2nyWxuAHg3rH23kWH0godWC3 X-Pg-Spam-Score: -1.9 (-) 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 Hello, In 9.3+, when the primary is busy hot_standby_feedback doesn't properly work with symptoms like a) spurious query cancels because no feedback messages have been sent yet, b) bloat on the primary because we don't regularly send feedback leading to stale xmins on the primary. The relevant code is in walreceiver.c's WalReceiverMain(): len = walrcv_receive(NAPTIME_PER_CYCLE, &buf); if (len != 0) { ... /* Let the master know that we received some data. */ XLogWalRcvSendReply(false, false); /* * If we've written some records, flush them to disk and * let the startup process and primary server know about * them. */ XLogWalRcvFlush(false); } else { ... XLogWalRcvSendReply(requestReply, requestReply); XLogWalRcvSendHSFeedback(false); } So, when the connection always has data, we'll not send feedback. That's pretty easy to demonstrate by running pgbench -jc 8 or so against the primary. Looking into this I also noticed that the busy path is odd, because a) why are we sending a reply before flushing things to disk? b) XLogWalRcvFlush() will do it's own XLogWalRcvSendReply(). To a good part that seems to have been introduced in 6f60fdd7015b032bf49273c99f80913d57eac284. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs