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

Thanks for your reply.

> 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).

I do not have any issue with the optimistic locking
mechanism. I am questioning why I have to commit or
rollback the transaction after Firebird reports an
update conflict? Should a client application not be
allowed to execute the same sql on the existing
transaction without having to commit/rollback?

> 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).

Even if I specify tpb_wait, If I understand correctly,
Firebird will report an update failure once the first
update commits. So wait/nowait only differ in when
Firebird reports a conflict, right?

> But retry should handle the error in
> isc_tpb_read_committed modes so
> you possibly setting Jaybird TPB modes incorrectly.

"jdbc:firebirdsql:localhost/3050:TGDB?TRANSACTION_READ_COMMITTED=isc_tpb_write,isc_tpb_read_committed,isc_tpb_no_rec_version,isc_tpb_nowait";

I have tried wait and nowait in this loop. I have also
tried setting connection properties like you
indicated....except I used "isc_" prefix. Maybe, thats
what I am doing wrong.

> 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);

I will try without the "isc_" prefix and report back
in this list.

Thanks for the help.

Nitin

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com