Hi!
Changes:
1. Check for other waiters is moved from LockResolveConflict to LockAquire.
2. Don't take other waiters into account if either lock aquired by MyProc don't conflict with locks aquired by
waitersor MyProc already holds conflicting lock.
3. ProcSleep uses conflict table to order waiters. Priority not used.
4. ProcLockWakeup stops attempts to wakeup waiters if lock conflict found _and_ someone was already wakeuped.
5. DeadLockCheck is able to wakeup MyProc or other proc to prevent deadlock.
Below are tests I run. Hope that lmgr issues are closed.
---
Blocked by "higher priority" lock waiting:
1:
begin;
lock t1 in row exclusive mode;
2:
begin;
lock table t1 in share row exclusive mode; -- blocked by 1
3:
begin;
lock table t2 in share row exclusive mode;
lock table t1 in row exclusive mode; -- blocked by 2
1:
lock t2 in row exclusive mode; -- blocked by 3
-- was: DeadLock: 3 waits for 2 waiting for 1
-- now: 3 granted lock on t1 and wakeuped
Blocked by other:
1:
begin;
lock t1 in row share mode;
2:
begin;
lock table t1 in row exclusive mode;
3:
begin;
lock table t2 in share row exclusive mode;
lock table t1 in share row exclusive mode; -- blocked by 2
1:
lock t2 in row exclusive mode; -- blocked by 3
-- was: DeadLock: 3 waits for lock on t1 and 1 hold lock on t1
-- now: no DeadLock: 3 blocked not by 1
Blocked by other II:
1:
begin;
lock table t1 in row share mode;
2:
begin;
lock table t1 in row exclusive mode;
3:
begin;
lock table t2 in exclusive mode;
1:
lock t2 in row share mode; -- blocked by 3
3:
lock table t1 in share row exclusive mode; -- blocked by 2
-- was: DeadLock: 3 waits for lock on t1 and 1 hold lock on t1
-- now: no DeadLock: 3 blocked not by 1
4:
begin;
lock table t3 in exclusive mode;
2:
lock table t3 in row share mode; -- blocked by 4
4:
lock table t1 in row exclusive mode; -- blocked by 3
-- was: not possible
-- now: self wakeing up
Vadim