Subject Re: [Firebird-Java] Concurrent updates - Retry not allowed without commit or rollback
Author Nickolay Samofatov
Hello Nitin,

> This is a repeat post because my first post did not
> get any replies. Any help is much appreciated.

> Environment -

> Firebird 1.5 rc3 running on Win 2K professional
> JayBird 1.0.1 driver
> Transaction Isolation setting -
> TRANSACTION_READ_COMMITTED=isc_tpb_write,isc_tpb_read_committed,isc_tpb_rec_version,isc_tpb_wait

> I have also tried permutations and combinations of
> record version/no record version, wait/no wait.

> The scenario is as follows:
> User A : 'Update temptable set idd=11 where name
> ='bar'

> Executes and waits for a while before committing.

> User B : 'Update temptable set idd=12 where name
> ='bar'

> Executes and blocks (or immediately gets an exception
> in no wait) for user a to commit.

> User B has a try catch block in a while loop (for
> GDSException 335544336) that retries the update.

> I keep getting the same exception unless I commit or
> rollback. I tried the same logic on Oracle and MySql
> and the update goes through without any issues.

> Any thoughts on what I may be doing wrong?

This behaviour is AS DESIGNED. Firebird doesn't take implicit
pessimistic locks for the period of physical record update for various
reasons (mainly performance-related in clustered environment, AFAIU).

Use explicit pessimistic locks and
isc_tpb_read_committed+isc_tpb_wait+<whatever> isolation mode to avoid
the error or handle this error yourself via retring statement
(isc_tpb_read_committed modes) or transation (isc_tpb_concurrency).

But retry should handle the error in isc_tpb_read_committed modes so
you possibly setting Jaybird TPB modes incorrectly. My TPB management
code looks like this:

Properties conProp = new Properties ();
conProp.put ("user", user);
conProp.put ("password", password);
/* Firebird JCA-JDBC driver (Jaybird) parameters */
conProp.put ("lc_ctype", "WIN1251");
conProp.put ("TRANSACTION_SERIALIZABLE", "concurrency,nowait");
conProp.put ("TRANSACTION_REPEATABLE_READ", "consistency,wait");
conProp.put ("TRANSACTION_READ_COMMITTED", "read_committed,rec_version,wait");
con = DriverManager.getConnection(URL, conProp);



> Nitin


--
Nickolay Samofatov