1

I am using Spring-Data-Jpa and using @Lock annotation(PESSIMISTIC_WRITE) for taking database(Oracle) locks. I need help in understanding that whether the following scenario can lead to a database dead lock.

  1. Transaction 1(PROPAGATION_REQUIRES_NEW, ISOLATION_DEFAULT) one takes a database lock over say Teacher table(say lock is taken over row with id=1). It tries to insert a new record in the child table say Meeting. No update is done on the Teacher table
  2. While Transaction 1 is in progress. Transaction 2(PROPAGATION_REQUIRED, ISOLATION_DEFAULT) tries to update the Teacher table(row with id=1). It does not take a database lock.
  3. Since the lock is taken over row with id 1. Transaction 2 has to wait for transaction 1 to get over.

Can this condition lead to a database dead lock?

JDev
  • 1,662
  • 4
  • 25
  • 55

1 Answers1

0

I think your case will lead to a database lock, yes, but no deadlock will be triggered. And database lock is something we expect to happen to achieve ACID transaction.

Er.M
  • 26
  • 2