← Lessons

quiz vs the machine

Gold1460

Concurrency

Conflict Resolution Strategies

When concurrent writes collide, choose last write wins, merge, or surface to the user.

5 min read · core · beat Gold to climb

Why conflicts happen

In a replicated system two clients can update the same item at the same time on different replicas. When the replicas sync, they hold divergent values and must reconcile. The chosen conflict resolution strategy decides the outcome.

Common strategies

  • Last write wins picks the value with the highest timestamp and discards the others. It is simple but silently loses data and depends on clock accuracy.
  • Merge functions combine both values, suitable when the data has a natural join, such as adding two sets or taking a maximum.
  • Application resolution keeps all conflicting versions, called siblings, and asks the application or user to decide, as a shopping cart might union its items.

Choosing well

The right strategy depends on the data. Counters and sets merge cleanly. A single scalar like a profile name often defaults to last write wins. Critical data may need siblings so nothing is dropped. Detecting the conflict in the first place usually relies on vector clocks.

Key idea

Conflict resolution chooses between last write wins, automatic merge, and surfacing siblings, and the safest choice depends on the data and the cost of losing an update.

Check yourself

Answer to earn rating on the learn ladder.

1. What is a drawback of last write wins?

2. When is keeping siblings appropriate?