concurrencydistributed-system

is last write wins redundant for immutable keys?


In the book Designing Data-Intensive Applications > chapter-5 > Leaderless replication > Detecting Concurrent Writes, below is what Author says while talking about Last write wins (LWW)

The only safe way of using a database with LWW is to ensure that a key is only written once and thereafter treated as immutable, thus avoiding any concurrent updates to the same key. For example, a recommended way of using Cassandra is to use a UUID as the key, thus giving each write operation a unique key

If keys are immutable, why do I even need LWW? Am I missing something here?


Solution

  • I believe you are understanding this in a wrong sense.

    You do not

    Need LWW if keys are immutable.

    You should

    Use keys that are immutable if DB is of type LWW.

    The pre-condition here is not that "keys are immutable". Precondition is "DB is LWW"; and conclusion is not "Need LWW". Conclusion is "given pre-condition DB is LWW, you need to make keys immutable"