Announcement Announcement Module
Collapse
No announcement yet.
Order of lock acquisition - pessimistick locking - deadlock Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Order of lock acquisition - pessimistick locking - deadlock

    Hi,

    I have a question about the hibernate locking mechanism.
    I am using:
    - Spring 2.5.6
    - Hibernate 3.2.6
    - Atomikos XA transaction manager
    - Oracle 9g

    My DAO is based on plain Hibernate API

    I have 3 threads of type A which performs lock operation 4 times per second:
    Code:
    session.lock(object, LockMode.UPGRADE_NO_WAIT);
    This threads analyzes and modifies records in the database if the acquire the lock - otherwise they skip the execution.

    I have another 5 threads of type B which performs operation in an asynchronous onMessage method (JMS message receiver)
    Code:
    session.lock(object, LockMode.UPGRADE); .
    They wait for the lock - then performs update, and then commits the transaction.

    Is it possible that threads of type A will cause a deadlocks in threads of type B?
    I am asking whether the locks are granted in the order of session.lock method invocation?
    Or maybe it is not deterministic.
    I sometimes get transaction timeout (300 seconds) in threads of type B - so my assumption is that the lock ordering is not deterministic? Is that right?

    Regards,
    Tom
Working...
X