X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 10E443A3D47 for ; Tue, 23 Nov 2004 10:36:25 +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 92542-07 for ; Tue, 23 Nov 2004 10:36:21 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id DDA6A3A3D4F for ; Tue, 23 Nov 2004 10:36:22 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1CWY1y-0006Co-00; Tue, 23 Nov 2004 23:36:18 +1300 Message-ID: <41A313B0.7080103@opencloud.com> Date: Tue, 23 Nov 2004 23:40:48 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 0.9 (X11/20041115) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Temp02 Cc: pgsql-jdbc@postgresql.org Subject: Re: Can't throw the dreaded 'idle in transaction' - need help! References: <02fe01c4d054$b60a5fe0$2201010a@bluereef.local> <41A1870F.4030506@opencloud.com> <002d01c4d122$2abdc6b0$2201010a@bluereef.local> In-Reply-To: <002d01c4d122$2abdc6b0$2201010a@bluereef.local> X-Enigmail-Version: 0.86.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime 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.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/182 X-Sequence-Number: 11604 Temp02 wrote: > 1. Turning on statement logging for every query shows that the last > transaction that was responsible for the 'idle in transaction' did in fact > complete successfully. The code did not error during this processing and > appeared to complete the transaction normally. What do you mean by "complete the transaction normally" -- is the last logged statement on that connection a COMMIT or ROLLBACK? Can you provide statement logging for one of the connections that gets stuck in idle-in-transaction up to the point it gets stuck? > 2. The lock being held is a row lock that pertains to only one user, so we > don't know why this event would cause the entire servlet to block and hold, > as other threads from the pool should be available for other users which are > not reliant on this row. The locks you need to obtain depends on the query you are executing, so it's hard to say. > This to me seems like a jdbc driver issue, because > Jetty is happy to service other servlets that require no database connection > (indicating that Jetty is okay), and when we tried this without the use of > any DB connection pool, the same situation occured. Can anyone validate if > this seems logical? The locks are all on the server side, and the JDBC driver knows nothing about them. So I can't really see it being a JDBC driver bug, unless the JDBC driver is getting transaction demarcation wrong. > 3. Doing periodic 'ps' on the server frequently shows threads that remain > 'idle in transaction' for up to about 3-5 secs before being normally > cleared. Is this what we should expect even if we issue explicit con.commit > statements after the statement closes? I would have not expected to see idle > in transaction at all. For a particular connection the lifecycle looks something like: connection made from client mark connection as idle receive BEGIN from client mark connection as busy start transaction send BEGIN result to client mark connection as idle in transaction receive query from client mark connection as busy execute query send results to client mark connection as idle in transaction [... more queries ...] receive COMMIT or ROLLBACK from client mark connection as busy commit or rollback transaction send COMMIT or ROLLBACK result to client mark connection as idle So it is normal to see connections that are "idle in transaction" for short periods; these are connections that are waiting for the next query from the client. -O