pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Blasby <dblasby@openplans.org>
To: pgsql-jdbc@postgresql.org
Subject: OutOfMemory causing connection leaks
Date: Fri, 24 Mar 2006 10:47:43 -0800
Message-ID: <44243ECF.9020301@openplans.org> (raw)

I have a DB where each row is *giagantic* (up to 60mb in size).  I have 
my fetch size set to 200. I realize that this isnt so smart, but the 
problem it causes is more generic than my specific situation.

While reading, an OutOfMemoryError gets thrown and I start closing 
things down.  So far, so good.

I close the statement and close the result set - freeing up a bunch of 
memory.  Unfortunately, I get problems when I try to close the 
connection and release it to the connection pool.  This fails - most 
likely because it was in the middle of reading a tuple when it was 
rudely interupted by running out of memory.

It actually runs out of memory in PGStream.ReceiveTupleV3(), called from 
QueryExecutorImpl.processResults().

Later, the connection is closed and the
PooledConnectionImpl$ConnectionHandler.invoke() is called, which 
(because we're not AutoCommit) attempt to rollback the transaction with 
a con.rollback().  This is where the problem occurs.

Inside QueryExecutorImpl.processResults(), it gets a "\" from the server 
(highly likely from the bytea returned from the original query).  It, of 
course, doesnt understand this and throws an "An I/O error occured while 
sending to the backend." error.

The end result is that the connection doesnt appear to be closed and 
released back to the connection pool.  This means that connections to 
the database are being leaked, and probably a fair amount of memory.  
This, of course, causes the OutOfMemory error to happen more often.

dave




view thread (5+ messages)  latest in thread

Message-ID: <44243ECF.9020301@openplans.org>
Permalink:  ../44243ECF.9020301@openplans.org/
Also on:    postgresql.org/message-id/44243ECF.9020301@openplans.org

 · 

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: dblasby@openplans.org
  Subject: Re: OutOfMemory causing connection leaks
  In-Reply-To: <44243ECF.9020301@openplans.org>
  References: <44243ECF.9020301@openplans.org>

* 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