X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 811F352838 for ; Wed, 6 Jul 2005 09:04:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 68134-03 for ; Wed, 6 Jul 2005 12:04:48 +0000 (GMT) Received: from jupiter.egsgroup.com (jupiter.egsgroup.com [217.199.182.198]) by svr1.postgresql.org (Postfix) with ESMTP id 1975F52808 for ; Wed, 6 Jul 2005 09:04:47 -0300 (ADT) Received: by jupiter.egsgroup.com (Postfix, from userid 65) id AC90F1784D; Wed, 6 Jul 2005 13:04:49 +0100 (BST) X-Scanned-By: AMaViS-ng at egsgroup.com Received: from [10.20.0.81] (unknown [217.150.127.117]) by jupiter.egsgroup.com (Postfix) with ESMTP id 8E2ED643B; Wed, 6 Jul 2005 13:04:47 +0100 (BST) Message-ID: <42CBC8A0.4070901@egsgroup.com> Date: Wed, 06 Jul 2005 13:03:44 +0100 From: Alexander Stanier User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Heavy virtual memory usage on production system References: <42CAB1B6.50201@egsgroup.com> <23889.1120582516@sss.pgh.pa.us> In-Reply-To: <23889.1120582516@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200507/43 X-Sequence-Number: 13284 The problem happened again this morning and I took the chance to check out the locking situation. The number of locks increased dramatically up to over 1000, but they were all "AccessShareLocks" and all were granted. The odd "RowExclusiveLock" appeared but none persisted. On the basis that nothing seems to be waiting for a lock, I don't think it is a locking problem. I think the vast number of locks is symptom of the fact that the server is trying to service a vast number of requests. Eventually, the server seemed to catch up with itself - the CPU went up, the VM went down and the number of queries in pg_stat_activity reduced. The problem then occurred a second time and there seemed to be a lot of pageouts and pageins going on, but I was only looking at top so it was difficult to tell. I have now restarted with a statement_timeout of 2 mins to protect the server from poorly performing queries (fairly brutal - but it does at least stop the downward spiral). I have also reduced the sort_mem to 1024. I guess it could be that we simply need more memory in the server. I have got vmstat (vm_stat on Mac) running and I will watch the behaviour...... Regards, Alex Stanier. Tom Lane wrote: >Alexander Stanier writes: > > >>The database seems to fine to start with, but then as the load increases >>it seems to reach a threshold where the number of non-idle queries in >>pg_stat_activity grows heavily and we appear to get something similar to >>a motorway tail back with up to perhaps 140 queries awaiting processing. >>At the same time the virtual memory usage (reported by the OS) appears >>to grow heavily too (sometimes up to 50GB). The CPUs do not seems to be >>working overly hard nor do the disks and the memory monitor reports >>about 600MB of inactive memory. >> >> > >You shouldn't be putting a lot of credence in the virtual memory usage >then, methinks. Some versions of top count the Postgres shared memory >against *each* backend process, leading to a wildly inflated figure for >total memory used. I'd suggest watching the output of "vmstat 1" (or >local equivalent) to observe whether there's any significant amount of >swapping going on; if not, excessive memory usage isn't the problem. > >Are you sure that the problem isn't at the level of some query taking an >exclusive lock and then sitting on it? I would expect either CPU or >disk bandwidth or both to be saturated if you were having a conventional >resource limitation problem. Again, comparing vmstat readings during >normal and slow response conditions would be instructive. > > regards, tom lane > > >