Part 4 of 5 · 2 min read
Conflict resolution strategies
Different concrete rules exist for deciding which of two conflicting writes should win, or whether to merge them.
Conflict resolution strategies
Think of a company policy for exactly this situation. Either the change with the later timestamp automatically wins, or a specific regional office is always given priority over the other. For some kinds of data, both changes are instead kept and manually reconciled by a person later.
In plain words: last-write-wins is a simple conflict resolution strategy that picks whichever conflicting write has the later timestamp, discarding the other, though it requires trusting that each leader's clock is reasonably accurate and synchronized. A fixed-priority strategy instead always prefers one specific leader's write over another's regardless of timing, useful when one source is known to be more authoritative. For data where discarding either change outright is unacceptable, some systems instead merge both values, such as combining two concurrently added items into a shopping cart rather than keeping only one.
A worked example. A system resolving the conflicting shipping-address update with last-write-wins keeps whichever update's timestamp is later, discarding the other entirely, even if the discarded update was also a legitimate, intentional change by the customer.
The key lines. No new SQL; which conflict resolution strategy applies is a configuration choice of the replication system, and can also depend on the specific kind of data being written.
Last-write-wins, fixed-priority, merge
Last-write-wins keeps whichever conflicting write has the later timestamp; a fixed-priority strategy always prefers one specific leader's write; a merge strategy combines both conflicting values instead of discarding either.
Example: a company policy letting the later timestamp win, always favoring one office, or manually reconciling both changes later, mirrors these three conflict resolution strategies respectively.
Remember this
Multi-leader replication trades away single-leader's one unambiguous ordering point in exchange for fast, local writes everywhere, and that trade is exactly what makes write conflicts possible at all. Choosing a conflict resolution strategy is an unavoidable part of adopting multi-leader replication, not an optional extra step.
Quick notes
- Multi-leader replication allows more than one leader, each accepting writes locally, trading away single-leader's one ordering point.
- A write conflict happens when two leaders each accept a change to the same data before hearing from each other.
- Last-write-wins resolves a conflict using timestamps, discarding the earlier write.
- A fixed-priority strategy always prefers one specific leader's write regardless of timing.
- A merge strategy combines both conflicting values instead of discarding either one.