Subject Problem with multi-threaded update/query causing JDBC driver errors
Author phil_hhn
(This call being raised as suggested by Roman in the main FB support
NG...)

We had some multi-threaded code running where both threads were using
the same JDBC connection; if they ran SQL code at the same time,
errors could occur. (The threads have since been changed to have their
own JDBC connections.)
Sometimes the error was a NullPointerException, or in some cases "GDS
Exception. 335544332. invalid transaction handle (expecting explicit
transaction start)".

I created a test case to mimic the situation but could not reproduce
the error (so no sample code, sorry). However I have captured some of
the stack traces (from our main application), as below. (Sometimes I'd
have to run the code several times before the timing of the threads
clashed and an error would occur.)
We are using Firebird 1.5.3 (4870), JDBC driver 2.1.1.

Most common error:
=================================
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544332. invalid
transaction handle (expecting explicit transaction start)
at
org.firebirdsql.jdbc.AbstractStatement.executeQuery(AbstractStatement.java:228)
<< Our code, running a query >>


More worrying is this one:
=================================
java.lang.NullPointerException
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlExecute2(AbstractJavaGDSImpl.java:1119)
at
org.firebirdsql.gds.impl.GDSHelper.executeStatement(GDSHelper.java:224)
at
org.firebirdsql.jdbc.AbstractStatement.internalExecute(AbstractStatement.java:1109)
at
org.firebirdsql.jdbc.AbstractStatement.executeQuery(AbstractStatement.java:219)
<< Our code, running a query >>

Followed immediately by:
=================================
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544726. Error
reading data from the connection.
null
Reason: Error reading data from the connection.
null
at
org.firebirdsql.jdbc.InternalTransactionCoordinator$LocalTransactionCoordinator.ensureTransaction(InternalTransactionCoordinator.java:313)
at
org.firebirdsql.jdbc.InternalTransactionCoordinator$LocalTransactionCoordinator.executionStarted(InternalTransactionCoordinator.java:342)
at
org.firebirdsql.jdbc.InternalTransactionCoordinator.executionStarted(InternalTransactionCoordinator.java:38)
at
org.firebirdsql.jdbc.AbstractStatement.notifyStatementStarted(AbstractStatement.java:243)
at
org.firebirdsql.jdbc.AbstractStatement.notifyStatementStarted(AbstractStatement.java:234)
at
org.firebirdsql.jdbc.AbstractStatement.executeQuery(AbstractStatement.java:216)

... all subsequent queries resulted in the following (obviously
Firebird had crashed, and I verified this by checking the windows
event log which had an entry for "fbserver.exe: terminated abnormally"):
=================================
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544721. Unable
to complete network request to host "".
Reason: Unable to complete network request to host "".
at
org.firebirdsql.jdbc.InternalTransactionCoordinator$LocalTransactionCoordinator.ensureTransaction(InternalTransactionCoordinator.java:313)
at
org.firebirdsql.jdbc.InternalTransactionCoordinator$LocalTransactionCoordinator.executionStarted(InternalTransactionCoordinator.java:342)
at
org.firebirdsql.jdbc.InternalTransactionCoordinator.executionStarted(InternalTransactionCoordinator.java:38)
at
org.firebirdsql.jdbc.AbstractStatement.notifyStatementStarted(AbstractStatement.java:243)
at
org.firebirdsql.jdbc.AbstractStatement.notifyStatementStarted(AbstractStatement.java:234)
at
org.firebirdsql.jdbc.AbstractStatement.executeQuery(AbstractStatement.java:216)
<< Our code, running a query >>


Hope this helps. Let me know if you want any other details.
Thanks, Phil