educative.io

Question on Vector Clock reads when in a conflicted state

In the section discussion version clocks and resolving conflicts within the key/value store, I believe I understand how future write operations are resolved, but what happens when you try to do a read in a conflicted state? For example, after the network partition is resolved in the section’s example, we are left with ([A,2],[B,1],[C,1]) as the values for the provided key. If we try to do a read, is this context returned to the client making the read request, and they decide how to reconcile and repair the conflict with a write?


Course: Grokking Modern System Design Interview for Engineers & Managers - Learn Interactively
Lesson: Versioning Data and Achieving Configurability

Hi @James_Gatenby !!
In the scenario where a network partition is resolved, and the system is left with conflicting values for a key like ([A,2],[B,1],[C,1]), here’s how a read operation would typically be managed:

  1. Read Operation in a Conflicted State:

    • When a client initiates a read operation for the key, the system detects that there are conflicting values associated with that key.
  2. Context Returned to the Client:

    • The system returns the conflicting values ([A,2],[B,1],[C,1]) along with their respective vector clocks to the client.
    • The context includes metadata about each version, such as the node information (e.g., A, B, C) and the counters ([A,2], [B,1], [C,1]).
  3. Client-Side Reconciliation:

    • The client, armed with the conflicting values and their vector clocks, now has the context needed to understand the divergent histories.
    • The client can decide how to reconcile and repair the conflict based on its application logic or a conflict resolution strategy.
  4. Potential Repair with a Write Operation:

    • Depending on the client’s decision, it may initiate a write operation to resolve the conflict. The write operation would include the reconciled value and an updated vector clock to maintain causality.
  5. Manual or Automatic Conflict Resolution:

    • Similar to the Git analogy mentioned in the lesson, the system may attempt automatic conflict resolution. If automatic resolution is not possible or if the client prefers manual resolution, the client can provide a final resolved value.

In essence, the system returns the conflicting values and their context to the client, empowering the client to make decisions on how to reconcile the conflict. This approach provides flexibility, allowing applications to implement conflict resolution strategies that align with their specific requirements and business logic.
I hope it helps. Happy Learning :blush:

2 Likes