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 4D1373ABE89 for ; Wed, 22 Dec 2004 20:27:44 +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 25626-03 for ; Wed, 22 Dec 2004 20:27:39 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id CDD0E3ABC1C for ; Wed, 22 Dec 2004 20:27:37 +0000 (GMT) Received: from p25-max3.pmr.ihug.co.nz ([203.173.223.153] helo=[192.168.0.4]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1ChD52-0008G9-00; Thu, 23 Dec 2004 09:27:33 +1300 Message-ID: <41C9D8B4.7090605@opencloud.com> Date: Thu, 23 Dec 2004 09:27:32 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kris Jurka Cc: Bahadur Singh , "pgsql-jdbc@postgresql.org" Subject: Re: [BUGS] BUG #1347: Bulk Import stopps after a while ( References: <20041214122627.22135.qmail@web50802.mail.yahoo.com> <41BEED57.2090904@opencloud.com> In-Reply-To: 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: 200412/169 X-Sequence-Number: 11835 Kris Jurka wrote: > On Wed, 15 Dec 2004, Oliver Jowett wrote: > >>OK, it looks like it is the connection deadlock issue, but triggered by >>a case I hadn't considered. For some reason every query in the batch is >>creating a new named statement on the backend .. and the statement >>cleanup process that happens before query execution is flooding >>statement Close commands down the connection on the second batch >>execution, which appears to deadlock the connection. The exact behaviour >>will be fairly unpredicatable as it depends on when the JVM does garbage >>collection. > > Any news on this? I didn't get a chance to look at it before going on leave. I won't be able to look at it before early January. > In general it seems like the whole statement/portal > cleanup is too lazy. These things can take up significant backend > resources and I would have expected calling ResultSet.close() and/or > Statement.close() to actually close something (perhaps not immediately, > but at least on the next network trip). I don't have the code to hand, but from memory an explicit close of the Query does exactly this -- it clears the reference which causes it to be immeditately enqueued, and the next query will do cleanup when it polls the reference queue. The GC-driven enqueue only kicks in if the object holding the statement info becomes garbage without being closed. The reference queue stuff seems to be working as designed. The problem is that we should be taking the Close messages we send into account when trying to avoid protocol deadlocks, but currently we don't, so a big batch of Close messages at once break things. I was more worried about why a batch update was generating so many individual named statements.. it should either use zero (Statement.addBatch) or one (PreparedStatement.addBatch) named statement, not N statements. -O