pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Guillaume Smet <guillaume.smet@gmail.com>
Cc: PostgreSQL JDBC <pgsql-jdbc@postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: Memory leaks using refcursors
Date: Thu, 18 Jan 2007 19:03:16 -0500
Message-ID: <212AA1E7-770A-4F24-B8DF-B11438F748F7@fastcrypt.com> (raw)
In-Reply-To: <1d4e0c10701180942i60edff8bt914258ab0e1761ac@mail.gmail.com>
References: <1d4e0c10701171053t55e60a2epf3e395b5b97101b5@mail.gmail.com>
	<1d4e0c10701171422u2e9d8758ia663dd1f826f8258@mail.gmail.com>
	<6135.1169073075@sss.pgh.pa.us>
	<1d4e0c10701171527u744fd81eh6de7908599349af3@mail.gmail.com>
	<C8C31B9B-ABE7-41D6-AB6C-F03B2C11D038@postgresintl.com>
	<1d4e0c10701180057s2c2e4c85g50998c883bb470df@mail.gmail.com>
	<1E6DB692-8D5A-493F-9E1F-82130917EE77@postgresintl.com>
	<1d4e0c10701180646p56c18dcal2cb3526bd1050e63@mail.gmail.com>
	<1d4e0c10701180942i60edff8bt914258ab0e1761ac@mail.gmail.com>


On 18-Jan-07, at 12:42 PM, Guillaume Smet wrote:

> Hi again,
>
> In fact, there is still a remaining problem. People who developed this
> application sometimes commit the transaction before closing the result
> set in their code.
> With the current driver, it's not a problem as it didn't close the
> cursor at all so the cursor is closed at the end of the transaction
> and that's all.
>
> But with this patch, we have the following case:
> - begin
> - open result set -> open the cursor
> - commit -> close the cursor
> - close the result set -> try to close the cursor -> exception and
> backend in an error state if autocommit is false
>
> They fixed the order of commit/close in their application but IMHO,
> it's a bad idea to introduce this sort of regression.
>
> A try/catch is probably not a good idea because it leaves the backend
> in an error state if the CLOSE query is executed in a transaction (if
> autocommit is false for example).
>
> Any ideas on how we can solve this problem? I can't find any way to
> check if a cursor is still alive without throwing an error.

There's one important piece of information I believe might be  
relevant here.

The application is using XA. I'm not convinced that there isn't a  
subtle bug in the server's XA implementation that may be keeping  
track of the open cursor.

Under the covers this is using the unnamed cursor, and there is no  
close cursor being issued, The cursor is implicitly closed by opening  
another unnamed cursor.

I've asked Guillaume to test this hypothesis with his test case that  
does not use XA to see if the memory "leak" still exists without XA

Dave
>
> --
> Guillaume
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that  
> your
>       message can get through to the mailing list cleanly
>




view thread (16+ messages)  latest in thread

Message-ID: <212AA1E7-770A-4F24-B8DF-B11438F748F7@fastcrypt.com>
Permalink:  ../212AA1E7-770A-4F24-B8DF-B11438F748F7@fastcrypt.com/
Also on:    postgresql.org/message-id/212AA1E7-770A-4F24-B8DF-B11438F748F7@fastcrypt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, guillaume.smet@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Memory leaks using refcursors
  In-Reply-To: <212AA1E7-770A-4F24-B8DF-B11438F748F7@fastcrypt.com>
  References: <1d4e0c10701171053t55e60a2epf3e395b5b97101b5@mail.gmail.com> <1d4e0c10701171422u2e9d8758ia663dd1f826f8258@mail.gmail.com> <6135.1169073075@sss.pgh.pa.us> <1d4e0c10701171527u744fd81eh6de7908599349af3@mail.gmail.com> <C8C31B9B-ABE7-41D6-AB6C-F03B2C11D038@postgresintl.com> <1d4e0c10701180057s2c2e4c85g50998c883bb470df@mail.gmail.com> <1E6DB692-8D5A-493F-9E1F-82130917EE77@postgresintl.com> <1d4e0c10701180646p56c18dcal2cb3526bd1050e63@mail.gmail.com> <1d4e0c10701180942i60edff8bt914258ab0e1761ac@mail.gmail.com> <212AA1E7-770A-4F24-B8DF-B11438F748F7@fastcrypt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox