educative.io

Educative

Fencing - what if node A reaches the protected system before node B?

In the fencing mechanism explanation, the example shows that when Node A’s request finally reaches the protected system after Node B has completed its transaction, it is blocked. I understand this part.

What if Node A acquires a lease, and then it expires. After that, Node B acquires a lease, but before Node B is able to make the request, Node A’s request reaches the protected system? In that case, Node A’s request will be executed because it’s still valid from the protected system’s point of view. Then Node B’s request will be executed and may cause consistency issue for B because the system has been updated by Node A which should not happen and B is not aware of it.

Hello @Chun_Du,
This is a very good question, but it does not have a clear answer. So, this is a fundamental limitation of the fencing algorithm because it has a race condition between two clients. Now a way to resolve this is that the storage system or the protected system in this case checks what the latest lease is but that adds latency. Other than that there is no workaround for this unless the protected system has more information. This is the main problem in a distributed system you have to compromise on speed for safety.
Hope this helps

Thank you Omer for clarifying this. It helps a lot.