Fix lock_many race condition