Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e23ub-0004Vy-E7 for pgsql-general@arkaria.postgresql.org; Tue, 10 Oct 2017 23:26:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e23ua-0003vG-VS for pgsql-general@arkaria.postgresql.org; Tue, 10 Oct 2017 23:26:09 +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 1e23s9-00081u-Hj for pgsql-general@postgresql.org; Tue, 10 Oct 2017 23:23:37 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1e23s6-0000pD-DJ for pgsql-general@postgresql.org; Tue, 10 Oct 2017 23:23:36 +0000 Received: by mail-wm0-x22c.google.com with SMTP id i124so1187664wmf.3 for ; Tue, 10 Oct 2017 16:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=jeCe8M5rVH2HuoEyya3MKtfmiDkH+ZeTOjYznvh4BxQ=; b=hYWS5+kq1VWUCR4V0sg5rDMEj+3orOc6hB97rYk8CJFmKyeFuUhH7sE4YtRCbV8vjo 7HA8V84+JQ/lUkoTGK7iGxLEMbnq7P6+5suAZBY/aAXvHRhSIN6ZsexNCKz06WcDSIRw qkHApgR+j4nRlAAAHvEfPA74enciaiJqx2TNl98Ek+UI0EAOIhODidr4c9QbGxznW3YO Jk6FSPqvC4I4ckeG+V/FsjhWSOnt8woVNJsPONM0FwzCqfQi/tUXCmGzteic60E4ofJJ rsOiM73M+rQjR/YIJvVD3mvblKpTv0OzjJVwi5eTWvMLMUTp++gggBCS0Xc6efsUGdiW KSYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jeCe8M5rVH2HuoEyya3MKtfmiDkH+ZeTOjYznvh4BxQ=; b=KSUBwl4uXj+11u1L3GLYjU70Cg4/47IbY6zt3HipleX94g9QOrFapb5bYYIuLehfdz IQJTkgrCOfkXcFSAyCnFmG6jOu6Y6GdtYLv4oyEcygCbuzUP0/TwUPfj/L5aQqHQ51nm m+r1ur0PrGJ8RdK4X1DQugHIx9uD8Woqn65owab9iXttFPvwYXda6JPAS2LvTq+2fWN0 /M+pj0t6a91dE0084BmL62wHyeggdyYcrFzcsNrYkRS5+akzKcYoYsTfya5nKD3w9XKb rBMssiwVMkxHrb+9x7AHsJXnsxTgEDYcEjDRXZdQUHXcC+sc30LdT15jv/rtWbS9cPWV gcpQ== X-Gm-Message-State: AMCzsaV4XgB18vTbiT7huzoPfPtlImk3aUvx32D1WwqrEFTt0kASDfYL H6S7vKTqA2w4y7yG9Cuj1fTQGpx3RcF9M/wFs1G+T51+UHsnFKu1y6vbU75JRqG292CMbYxhmI3 7rk2Uh5kox/nFSVvAXT21Se2IPJDU+2R9dxlpQGrjGWuLFW5tOfXwNOEbIFn/qWAjSe+eNUFHsV fmIoFijJtH X-Google-Smtp-Source: AOwi7QADNQfVhhtFqAY0iXgRtnLwHnlTR2uKQiYMBtCEqKEBgBCMnszpPWuBcD0U6GYava+/bdtXDw== X-Received: by 10.223.130.42 with SMTP id 39mr15162483wrb.241.1507677811493; Tue, 10 Oct 2017 16:23:31 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id w79sm7145430wrb.86.2017.10.10.16.23.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 16:23:30 -0700 (PDT) Subject: Re: core system is getting unresponsive because over 300 cpu load To: pinker , pgsql-general@postgresql.org References: <1507668007464-0.post@n3.nabble.com> <4da39f8e-39b9-b4af-d879-72a44dde5fbd@2ndquadrant.com> <1507674532671-0.post@n3.nabble.com> From: Tomas Vondra Message-ID: <85580fec-9d9d-a551-156a-7bb1a66615ed@2ndquadrant.com> Date: Wed, 11 Oct 2017 01:23:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1507674532671-0.post@n3.nabble.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 10/11/2017 12:28 AM, pinker wrote: > Tomas Vondra-4 wrote >> What is "CPU load"? Perhaps you mean "load average"? > > Yes, I wasn't exact: I mean system cpu usage, it can be seen here - it's the > graph from yesterday's failure (after 6p.m.): > > So as one can see connections spikes follow cpu spikes... > I'm probably a bit dumb (after all, it's 1AM over here), but can you explain the CPU chart? I'd understand percentages (say, 75% CPU used) but what do the seconds / fractions mean? E.g. when the system time reaches 5 seconds, what does that mean? > > Tomas Vondra-4 wrote >> Also, what are the basic system parameters (number of cores, RAM), it's >> difficult to help without knowing that. > > I have actually written everything in the first post: > 80 CPU and 4 sockets > over 500GB RAM > Apologies, missed that bit. > > Tomas Vondra-4 wrote >> Well, 3M transactions over ~2h period is just ~450tps, so nothing >> extreme. Not sure how large the transactions are, of course. > > It's quite a lot going on. Most of them are complicated stored procedures. > OK. > > Tomas Vondra-4 wrote >> Something gets executed on the database. We have no idea what it is, but >> it should be in the system logs. And you should see the process in 'top' >> with large amounts of virtual memory ... > > Yes, it would be much easier if it would be just single query from the top, > but the most cpu is eaten by the system itself and I'm not sure why. I > suppose because of page tables size and anon pages is NUMA related. > Have you tried profiling using perf? That usually identifies hot spots pretty quickly - either in PostgreSQL code or in the kernel. > > Tomas Vondra-4 wrote >> Another possibility is a run-away query that consumes a lot of work_mem. > > It was exactly my first guess. work_mem is set to ~ 350MB and I see a lot of > stored procedures with unnecessary WITH clauses (i.e. materialization) and > right after it IN query with results of that (hash). > Depends on how much data is in the CTEs. We don't really allocate all of work_mem at once, but bit by bit. > > Tomas Vondra-4 wrote >> Measure cache hit ratio (see pg_stat_database.blks_hit and blks_read), >> and then you can decide. > > Thank you for the tip. I always do it but haven't here, so the result is > 0.992969610990056 - so increasing it is rather pointless. > Yeah. > > Tomas Vondra-4 wrote >> You may also make the bgwriter more aggressive - that won't really >> improve the hit ratio, it will only make enough room for the backends. > > yes i probably will > On the other hand, the numbers are rather low. I mean, the backends seems to be evicting ~15k buffers over 5-minute period, which is pretty much nothing (~400kB/s). I wouldn't bother by tuning this. > > Tomas Vondra-4 wrote >> But I don't quite see how this could cause the severe problems you have, >> as I assume this is kinda regular behavior on that system. Hard to say >> without more data. > > I can provide you with any data you need :) > What I meant is that if the system evicts this amount of buffers all the time (i.e. there doesn't seem to be any sudden spike), then it's unlikely to be the cause (or related to it). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general