Open GO-DIE opened 2 years ago
If it is in parallel, every instance can acquire a lock which is another race condtion again. e.g. A,B,C,D acquire the same lock at the same time. If it is not executed sequetially, can we say all of them get the lock ? We need to treat it as first come first serve bias. It can ensure that critical session is accessed only one user instead of multiple users at the same time.
if it's done in parallel, the system will probably never be able to step into the its critical section. The processes will probably acquire some of the locks but never all of them. And retrying won't help, it will just create backpressure on your system.
But if done sequentially, it will fail early and never block another process from acquiring the remaining locks. Let me know if that makes sence 👍
In Distributed locks with Redis – Redis - The Redlock algorithm, it says:
I don't understand why it needs to try to acquire the lock in all the N instances sequentially. What can go wrong if we try to acquire the lock in all the N instances in parallel?