Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id C621FB5DC09 for ; Wed, 21 Sep 2011 10:40:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 64148-05 for ; Wed, 21 Sep 2011 13:40:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.ip-pool.com [217.118.26.141]) by mail.postgresql.org (Postfix) with ESMTP id 1C06AB5DC13 for ; Wed, 21 Sep 2011 10:40:23 -0300 (ADT) Received: from mail.softperience.eu (loft2296 [217.118.26.141]) by mail.softperience.eu (Postfix) with ESMTPA id 92017C0007D; Wed, 21 Sep 2011 15:40:16 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 21 Sep 2011 15:40:16 +0200 From: =?UTF-8?Q?Rados=C5=82aw_Smogura?= To: Jean-Max Reymond Cc: Subject: Re: behavior at the end of a transaction In-Reply-To: References: <4E7760FB02000025000413A1@gw.wicourts.gov> Message-ID: X-Sender: rsmogura@softperience.eu User-Agent: Roundcube Webmail/0.5.4 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/80 X-Sequence-Number: 22198 On Wed, 21 Sep 2011 13:05:44 +0200, Jean-Max Reymond wrote: > Le 20/09/2011 11:36, Radosław Smogura a écrit : >> On Mon, 19 Sep 2011 15:34:19 -0500, Kevin Grittner wrote: >>> Jean-Max Reymond wrote: >>> >>>> On commit or rollback statement, I expect that all the cursors >>>> are closed (all my Resultset not closed) in the postgres database. >>>> is it correct ? >>> >>> No. >>> >>> http://www.postgresql.org/docs/9.1/interactive/sql-declare.html >>> >>> In particular, see the WITH/WITHOUT HOLD section. >>> >>> -Kevin >> >> Don't worry, If you "forget" result sets, when those will be GCed >> then >> cursors will be closed soon, too. > > no sure that GC will free the resources in the postgres database I think yes (I don't give head, because it's software), but driver monitors statements and portals (cursor), if those are unreachable then it sends close, so there are following requirements to auto-clean up (in case of cursor) 1) cursor must be unreachable, 2) cursor must be garbage collected (so it may take some time), 3) processing of deads must be invoked 4) connection must be valid Ad 3. processing of dead cursors must be invoked - this means you need to send other query to server after 1) and 2). It doesn't means what you will send, just You need to "wake up" some portions of code. Ad 4. driver must be able to send data - there is possibility of half-open connection, when server will have no knowledge that connection died And all of this in some way depends of environment, of pool you use. Cursors will be closed but not immediatly. If for example you have pool, you forgot about connection and connection is returned to pool, then in fact this may not be closed even for months (similarly if you have connection opened) (against 3). Result sets should be enqueued, but there no info will be posted to server. Should because this depends on pool implementation, actually server may wrap all driver objects, and delay freeing how long it wants - and it does it for connection and statements, and this is good stuff. You may try to check this, by self. By the way thanks for post, I will add background cleaning functionality. Regards, Radosław Smogura http://softperience.eu