X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 17F8F8B9B58 for ; Mon, 7 Feb 2005 11:04:56 +0000 (GMT) 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 37744-10 for ; Mon, 7 Feb 2005 11:04:45 +0000 (GMT) Received: from mail.jobflash.com (oncallweb2.jobflash.com [64.62.211.41]) by svr1.postgresql.org (Postfix) with ESMTP id 078248B9C8A for ; Mon, 7 Feb 2005 11:04:47 +0000 (GMT) Received: from [192.168.2.22] (user-38lc06i.dialup.mindspring.com [209.86.0.210]) by mail.jobflash.com (Postfix) with ESMTP id 8CCA2420E4; Mon, 7 Feb 2005 03:04:44 -0800 (PST) Message-ID: <42074B30.1050400@jobflash.com> Date: Mon, 07 Feb 2005 03:04:16 -0800 From: Tom Arthurs User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Rubio Cc: pgsql-admin@postgresql.org Subject: Re: Problem with permanent connections from Tomcat References: <42074420.80502@tinet.org> In-Reply-To: <42074420.80502@tinet.org> Content-Type: text/plain; charset=us-ascii; 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: 200502/52 X-Sequence-Number: 16220 Hi, Daniel I run a similar environment and I've seen this problem a lot. It's a java code problem -- your developers need to run a profiler to see where the resource leaks are -- they need to make sure that everytime they open a connection, they also close it as well -- and don't forget to to close the statements. We use borland's optimizeit which is not free (by a long shot) but it's probably worth the investment -- you can't promote code to production that is leaking resources like this. (Are you using connection pooling on tomcat?) If they all shutdown their tomcat instances, it should release the connection, don't know how popular that suggestion would be though. If you have the berkely version of ps (on solaris I use /usr/ucb/ps -auxww | grep post) you can see where each of these connections is coming from and some indication of what it's doing, and you can do a kill -15 on each one of them -- which is a more graceful recovery. For a quick and dirty fix -- do pg_ctl stop -m i That's an immediate shutdown -- though it's still a "dirty" shutdown and the db must recover on startup, so make sure your backups and txlogs are good -- *don't* run out of room for the txlogs. Daniel Rubio wrote: > Hi all > > Our developers are making some kind of DoS on my postgres installation. > They use Tomcat to develop in java and they have an instance on every > computer (only 3). > > It seems that tomcat makes permanent connections to the configured > database, but they have this number limited to 5, and max_connections in > postgresql.conf is 40, and no more connections are made to the database > because is a development environment. > > The number of connections starts increasing and when arrives to 40 ( ps > -ef | grep postm | wc -l ) the server doesn't accept more connections > but it seems that neither finish these that are open, and no one can > acces to the database (here is the DoS I say). > > Here is what the log says > > 2005-02-07 10:13:26 LOG: connection received: host=127.0.0.1 port=55834 > 2005-02-07 10:13:26 LOG: connection authorized: user=test database=test > 2005-02-07 10:13:26 FATAL: connection limit exceeded for non-superusers > > I try to stop the postmaster with pg_ctl but it says that postmaster > doesn't stops and I have to make kill -9 for the processes to stop :( > > What could I make to solve this? > > I've tried with: > > statement_timeout = 100000 > > but nothing happens ... :( >