Fix deadlocks in lock manager.