Subject Re: Help locate a connection leak...
Author Roman Rokytskyy
Hi,

> I have an application that just recently after a deployment of a new
> version started to open more connections to the database server than
> before, so we suspected a connection leak where a connection
> obtained from the pool (via FBWrappingDataSource) was not being
> returned or could not be reused for some reason.

What version of the JayBird do you use? 1.0.1 or 1.5 RC2?

> But I need to understand the type of error that would really cause a
> leak so I have the following questions, note:- I'm using a
> FBWrapping datasource(max=100,min=0,idle=1,pooled=true).
>
> 1) If Statements, PrepareStatements, or CallableStatements were not
> closed but the connection they were obtained using were would this
> cause an issue?

At least this would not lead to a new connection being allocated. Most
likely at some point you would run out of handles.

> 2) Is the order of closing resources important.
> For example I have found code that closed Statements, before Closing
> the ResultSets obtained via the Statements, would this cause any
> issues?

In 1.5 closing ResultSet after Statement would cause SQLException.

> 3) Again if a ResultSet wasn't closed but the connection was, is
> this a problem?

No, when you close the statement, result set is closed.

> Also if I stop access to the site and then wait says 10 mins (ldle
> time=1 min, min connections=0) I would expect under normal
> circumstances for all the database connections to close, is this
> right?

Depends on the version. In 1.0.1 it could happen that not all idle
connections were closed.

> What I have observed is that for 130 connections open, only 18 are
> closed after waiting 10 mins with no site activity, does this mean
> 112 (130-18) connections have leaked?

Not necessarily. They might happily live in pool. Ask the pool for the
current number of connections. If it reports 0, then 112 have leaked.

Roman