Subject Re: [Firebird-Java] Re: 335544329 invalid BLOB ID
Author Roman Rokytskyy
> Would that cause an intermittent failure or would that fail every
> time?

Should fail every time.

> Looking at our source, it is difficult to see how this could ever happen.
> The code looks something like this:

> final Blob blob = con.createBlob();
> final OutputStream out = blob.setBinaryStream(0);
> try
> {
> out.write( buffer, offset, len );
> }
> finally
> {
> out.close();
> }

> statement.setBlob( pos, blob );
> .
> .
> .
> statement.execute();

> The statement is then closed in a finally block and the connection is
> committed.

Looks ok.

> However, this sequence is happening across multiple threads.

You mean that same sequences are executed by different threads? Or that
parts of this sequence is executed by different threads - e.g. create blob
using one connection/transaction, execute statement in another one?

> Normally the code is even simpler like:
>
> statement.setBinaryStream( pos, baos, baos.size() );
>
> Which I suppose is just a short-cut for the previous example.

Correct - the code above is more or less what drivers does within this
method (only that few objects are not created, since the Firebird API is
called directly)

> Is there any tracing code I could add to the driver that would add
> more context to this exception?

Not that I know. :) Sure, you can enable the DEBUG level and then go through
each call to check the BLOB IDs, but that will be tons of code. And on the
other hand it won't help you anyway, since the log will contain temp IDs,
and your query will read permanent IDs...

Did you try using LOCAL or EMBEDDED types?

Roman