Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 484532E0039 for ; Mon, 18 Feb 2008 19:08:09 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 55138-01 for ; Mon, 18 Feb 2008 19:07:59 -0400 (AST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.185]) by postgresql.org (Postfix) with ESMTP id 59B0C2E0035 for ; Mon, 18 Feb 2008 19:08:02 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so2188987fka.3 for ; Mon, 18 Feb 2008 15:08:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=Uo/WWxm0xLKAvFxxPL3HqNZm8rFaoqUsA0/tHSGQrZs=; b=BfDOlk9Bb6p9jZfv5MBv7RD/2B4c4DXupTEeRDUR/MdLa5/Rq+LPnlu3A+kxV21wD2zCOb2hOTYjNwiATOqPIOV4PBxj9XY+x1abxCwc2uW5uaLqaI1in+8e9HDgXhfTTkdiu75wlTUvG8/kwF5c/3wN3CmXpjtGwUKK7KHUjGw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ja79dha2LGbbqu/9JSkhL/4gqYAelNLnScnTuXs4ktM2vyS3bbzfdPgWYAszQWxy99VMi3E89DHDvemNXwHedm6XqVpyQ//66tgyvK0I5x1ycApKxVrEDG8VDFfn6OgCIBe5QVHIhOVrQeOWxArTH2gVw5YdkKIwe7pgMIgwN1Q= Received: by 10.82.172.10 with SMTP id u10mr12853925bue.14.1203376079915; Mon, 18 Feb 2008 15:07:59 -0800 (PST) Received: by 10.82.180.9 with HTTP; Mon, 18 Feb 2008 15:07:59 -0800 (PST) Message-ID: <8efd35820802181507i3dace145t9b67bda4f07cd0fa@mail.gmail.com> Date: Mon, 18 Feb 2008 18:07:59 -0500 From: "Paul Tomblin" To: pgsql-jdbc@postgresql.org Subject: Re: Getting "This ResultSet is closed" exceptions In-Reply-To: <200802181708.07111.jdevisser@digitalfairway.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8efd35820802180619l352d9b0eta35788642a5fc4eb@mail.gmail.com> <3fccaa690802181110j4b5d1429ta8ea641f4ebb160@mail.gmail.com> <8efd35820802181148o3325551fj2f4f7de7baab39a1@mail.gmail.com> <200802181708.07111.jdevisser@digitalfairway.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200802/127 X-Sequence-Number: 18334 On Feb 18, 2008 5:08 PM, Jan de Visser wrote: > On Monday 18 February 2008 14:48:24 Paul Tomblin wrote: > > Forgive a possibly stupid question, but how would a class know whether > > there is a Connection for this thread already? I use a simple static > > to hold the Connection, and so I get one for the whole program. > > That sounds like a bad plan to me. You're going to interleave transactions > etc. (You are using transactions, aren't you? :) Look into connection pools Unfortunately the existing code ran with autocommit on, and there was no concern for transations. I've turned off autocommit, and am running around the code trying to figure out where is the best place to put "conn.commit();" calls. Right now, I'm hunting down a lot of cases where one program or another is stuck because of transaction locks held by another, so I'm being overzealous and sprinkling them around liberally, but I think we definitely need them before we send an event or an RMI call, or before finishing a thread or sleeping, but otherwise we probably don't need any others. I also run a "vacuumdb -analyze" every night, and that's causing problems in the field with lock contention[1]. That's one reason why I want to make sure we use transactions and commit when we need to. [1] I know it's off topic for this mailing list, but can anybody point me to a site that shows how to figure out what Java program is causing the thread locks? Right now I'm doing it like: ps auwwx | grep 'idle in transaction' that gives me the socket number, and then I use lsof -i :[socketnumber] and that gives me the two PIDs that have it open, one of which is postgresql and the other is java, and then I go back to "ps auwwx" to find that the arguments to "java" for that pid to find out what program it is. -- For my assured failures and derelictions I ask pardon beforehand of my betters and my equals in my Calling here assembled, praying that in the hour of my temptations, weakness and weariness, the memory of this my Obligation and of the company before whom it was entered into, may return to me to aid, comfort and restrain.