Re: Couple of preparedstatement bug suspects

From: Kris Jurka <books(at)ejurka(dot)com>
To: Roy Smith <roy(dot)smith(at)primetext(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Couple of preparedstatement bug suspects
Date: 2008-05-09 04:14:22
Message-ID: Pine.BSO.4.64.0805090011170.3632@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Fri, 9 May 2008, Roy Smith wrote:

> I have an app which inserts rows to a table called messages. During load
> testing, I'm looping to insert 10,000 rows. Intermittentently (around 5%
> and only after the first 6,000 or so) I'm getting the following
> Exception...
>
> org.postgresql.util.PSQLException: This statement has been closed.
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.checkClosed(AbstractJdbc2Statement.java:2442)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.getUpdateCount(AbstractJdbc2Statement.java:495)
> at
> org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:309)
> at com.primetext.tl2000.dataobjects.Messages.insert(Messages.java:566)
>
> This smells like a bug. There are other updates within my loop, and I
> can't promise that I'm closing all statements. Therefore if this bug is
> being triggered by me abusing the driver, please confirm and I'll go
> through all of my code ensuring that all preparedstatements are being
> closed.
>

Is your app multi-threaded? The only way I see for this to happen is that
one thread is executing the statement and another is closing it.

> However, there is a another aspect of this which smells like an even
> bigger bug... Even though the PreparedStatement.executeUpdate is
> throwing an exception, the row *is* being written to the database!! This
> can't possibly be valid.
>

The exception is from the driver, not the server and it happens after the
query has been executed by the server. Once the server has committed the
data, there's not much the driver can do about that.

Kris Jurka

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Roy Smith 2008-05-09 04:41:29 Re: Couple of preparedstatement bug suspects
Previous Message Roy Smith 2008-05-09 03:54:54 Couple of preparedstatement bug suspects