Subject Strange problems
Author Nickolay Samofatov
Hello !

I'm still getting strange errors during multi-threaded operation
when working with Jaybird from CVS. Problem is that I still don't
have a reproducable test case. Errors show themselves from time to
time on client sites.

--
java.lang.IllegalStateException: registerStatement called with no transaction
at org.firebirdsql.jca.FBManagedConnection.registerStatement(FBManagedConnection.java:840)
at org.firebirdsql.jdbc.FBConnection.registerStatement(FBConnection.java:1106)
at org.firebirdsql.jdbc.FBStatementFetcher.<init>(FBStatementFetcher.java:41)
at org.firebirdsql.jdbc.FBResultSet.<init>(FBResultSet.java:103)
at org.firebirdsql.jdbc.FBStatement.getResultSet(FBStatement.java:550)
at org.firebirdsql.jdbc.FBPreparedStatement.executeQuery(FBPreparedStatement.java:111)
...
--
org.firebirdsql.jdbc.FBSQLException: GDS Exception. Dynamic SQL Error
SQL error code = -501
Attempt to reclose a closed cursor
at org.firebirdsql.jdbc.FBStatement.closeResultSet(FBStatement.java:887)
at org.firebirdsql.jdbc.FBPreparedStatement.internalExecute(FBPreparedStatement.java:419)
at org.firebirdsql.jdbc.FBPreparedStatement.executeQuery(FBPreparedStatement.java:101)
...
--
Stack traces are from Jaybird ~15 Feb 2003, but they they seem to happen
with current Jaybird too.

Environment:
Firebird 1.5 RC1 Linux CS
Current CVS Jaybird
JDBC back-end is used by multi-threaded application server.

Errors appear when several threads work with server in parallel on SMP
machine with classic Firebird for several hours. I'm pretty sure I
access each connection from only one thread at a time, but connections
migrate between threads very often. Errors appear randomly on
executeQuery calls in different places of my code.

Worst part of this process is that transaction is getting committed
when my application gets this error. I get inconsistent database then.
Oracle (9.0.1) and MSSQL (JSQLConnect) drivers do not show any signs
of problems in the same conditions.

I'll try to pinpoint the bug, but I still have no idea about
reason of the problem. I added some debug logging to Firebird 1.5
engine and my application server. Problem seems to be in Jaybird.

I will add debug logging to it regarding threading, transactions
and connections, but maybe authors can point my attention to
specific areas of code (XID->handle mapping is probaby one of them) ?

--
Best regards,
Nickolay Samofatov mailto:skidder@...