I was asked in an interview, "In a MySQL database, what happens if a Transaction(2) tries to acquire a Shared/Exclusive lock, but another Transaction{1) already has an Exclusive lock on the same Resource?"
My answer was simple, The Transaction(2) waits until the commit or rollback of Transaction(1). Then comes the followup questions. If so,
- Where will the second transaction be waiting. (like Blocking queue kind of implementations?)
- How the 2nd Transaction will be notified upon the commit or Rollback of Transaction(1)?
- If there are more than one transactions waiting for the same resource which was locked by Transaction(1), how the lock resolution be done?