Suppose the following:
- There is a user session which holds exclusive locks on several rows in the table.
- Two (or more) other sessions are started, each with the request to acquire some of the currently held locks
- To make the case easier, let's assume that the new sessions want to acquire just one row lock, and they both want the same one. In reality it's unlikely to happen exactly that way, because each session will try to lock an "island" of connected rows, but I doubt this impacts the answer to this question.
- Documentation on concurrency says, that:
If the lock is active, then the session asks to be notified when the lock is released.`
- The original session which held the locks commits and releases its locks.
Which one of the two waiting sessions will get notified that it is now able to acquire locks? Is there a DB setting that controls this?
If the waiters are notified in random order, does that mean that there is a possibility of lock-starving one of the sessions when a lot of them compete for the same lock, or is there a mechanism to address this case?