Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X1kpY-0004qo-UI for pgsql-performance@arkaria.postgresql.org; Mon, 30 Jun 2014 23:17:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X1kpX-0001We-Ts for pgsql-performance@arkaria.postgresql.org; Mon, 30 Jun 2014 23:17:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X1kpW-0001WV-Lw for pgsql-performance@postgresql.org; Mon, 30 Jun 2014 23:17:46 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X1kpS-0003lB-JC for pgsql-performance@postgresql.org; Mon, 30 Jun 2014 23:17:44 +0000 Received: from intern.anarazel.de (p54AF441C.dip0.t-ipconnect.de [84.175.68.28]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id DA9084F0001; Tue, 1 Jul 2014 01:17:41 +0200 (CEST) Date: Tue, 1 Jul 2014 01:17:41 +0200 From: Andres Freund To: Tom Lane Cc: Jeff Frost , Matheus de Oliveira , Soni M , Heikki Linnakangas , pgsql-performance Subject: Re: Postgres Replaying WAL slowly Message-ID: <20140630231741.GA30918@alap3.anarazel.de> References: <20300.1404156750@sss.pgh.pa.us> <20140630201523.GV26930@awork2.anarazel.de> <943ECC8E-8899-422E-937C-50DE20E1F7AC@pgexperts.com> <21474.1404160784@sss.pgh.pa.us> <2E438E7D-E3C1-47A1-A1AF-9FE50A14A302@pgexperts.com> <571D044B-260A-4E06-ACBC-8869B8F73C0F@pgexperts.com> <24455.1404169460@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24455.1404169460@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 2014-06-30 19:04:20 -0400, Tom Lane wrote: > Jeff Frost writes: > >>> So it seems like we have a candidate explanation. I'm a bit surprised > >>> that StandbyReleaseLocks would get this slow if there are only a dozen > >>> AccessExclusiveLocks in place at any one time, though. Perhaps that > >>> was a low point and there are often many more? > > > Since we turned on the monitoring for that, we had a peak of 13,550 > > AccessExclusiveLocks. Any chance the workload also uses lots of subtransactions? > Ah ... that's more like a number I can believe something would have > trouble coping with. Did you see a noticeable slowdown with this? > Now that we've seen that number, of course it's possible there was an > even higher peak occurring when you saw the trouble. > > Perhaps there's an O(N^2) behavior in StandbyReleaseLocks, or maybe > it just takes awhile to handle that many locks. I don't think there's a O(n^2) in StandbyReleaseLocks() itself, but in combination with StandbyReleaseLockTree() it looks possibly bad. The latter will call StandbyReleaseLocks() for every xid/subxid, and each of the StandbyReleaseLocks() will then trawl the entire RecoveryLockList... It'd probably be better to implement ReleaseLocksTree() by sorting the subxid list and bsearch that while iterating RecoveryLockList. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance