• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

concurrency and transaction isolation level

 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the database concurrency strategy section this article http://dev2dev.bea.com/lpt/a/458 mentions

At least one problem exists with both the exclusive and the database concurrency strategies: the possibility of lost updates. Imagine if two clients almost simultaneously try to update the same record in a table that is mapped to an entity bean. If no locks are held in the database, the result of the update operation that finished first will be overwritten by the second update.



I am not sure why is it mentioned that no locks are held.
Won't using the right transaction isolation level help prevent the problem. Is he talking about the case where the transaction isolation level is READ_COMMITED.

If it were REPETABLE_READ

TX1 reads a ROW A
TX2 cannot update the ROW A until TX1 completes so that TX1 is able to read the same data later in transaction?

What I dont understand is the relation betwen concurrency and ISOLATION LEVEL?

In the next para

This is achieved by setting the use-select-for-update element in weblogic-cmp-jar.xml to true (the default setting is false). As you can guess from the name, this action will instruct WebLogic Server to use "select for update" when loading entity bean data. The resulting database lock will be held until the transaction is completed, and therefore it's impossible for any other transaction to read or change data while the first transaction is running.



I am again confused. Wouldn't using the right isolation level help rather than using SELECT FOR UPDATE lock.

Thanks,
Pradeep
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pradeep,

You're very right, setting a higher level of isolation will prevent that from happening. The problem though is that all beans accessed by that transaction will run within the same isolation level and therefore more database locks will be held. Using the use-select-for-update deployment descriptor will set the "isolation level" only for the bean and not for the entire transaction. Other beans can have a lower isolation level set.
Regards.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Valentin.

Using the use-select-for-update deployment descriptor will set the "isolation level" only for the bean and not for the entire transaction. Other beans can have a lower isolation level set.



I haven't understood the above. What do you mean by not for the entire transaction. Thanks,Pradeep
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pradeep,

What I mean is that use-select-for-update deployment descriptor is not actually setting the transaction isolation level in any way. This is a very restrictive operation and setting a higher isolation level will degrade the performances considerable. In order to avoid this the use-select-for-update deployment descriptor will instruct the container to exclusively lock the mapping table independent of the isolation level used. It has the advantage that you can still assure data integrity even though the isolation level for the current transaction is set to a lower value.
Regards.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Valentin.Great explanation.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're very welcome Pradip
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic