Conflict Resolution: Strategies, Merging, and How It Works

Author: IT Sectr Published: 2026-06-14 Reading time: 9 min

Conflict resolution in synchronization is a mechanism that determines the consistent state of data when simultaneous changes occur on different devices without a network connection. In distributed mobile systems, conflicts arise when two clients modify the same object offline, and upon restoring connectivity, the server receives two different versions. According to IEEE ICDCS, 2024, up to 12% of replication sessions in mobile applications contain at least one conflict. The resolution strategy determines which version of the data will be accepted and how it affects data integrity.

Key Takeaways

  • Synchronization conflict — a situation where two devices modified the same object offline and the server cannot automatically determine the correct version.
  • Last Write Wins (LWW) — the simplest strategy: the version with the latest timestamp is selected, all others are discarded.
  • Merge Strategy — an approach where changes from conflicting versions are merged rather than replaced by one of them.
  • CRDT — mathematically guarantee data convergence without a central coordinator, ideal for collaborative editing.
  • Choosing a strategy depends on the scenario: LWW is fast, Merge is precise, CRDT is complex to implement but provides maximum consistency.

What Is Conflict Resolution in Mobile Applications?

Conflict resolution is the process of bringing distributed data to a single consistent state after detecting conflicting changes. In centralized systems, conflicts do not occur: the server processes requests sequentially. In mobile applications with offline mode, the client modifies data locally and synchronizes with the server later. If two clients modified the same object, the server receives two versions with the same identifier but different content.

Conflicts are inevitable in loosely coupled replication (eventual consistency), where the system sacrifices instant consistency for availability and performance. According to researchers from Princeton University (Aggarwal et al., GEO paper, KDD 2024), systems with deferred replication demonstrate 28% higher performance under peak loads but require conflict resolution mechanisms for correct operation.

The resolution strategy is an algorithm that the system applies automatically when a conflict is detected. Different databases and frameworks implement different strategies: Firebase Realtime Database uses LWW, CouchDB adds Merge support, and Figma and Notion build their architecture on CRDT.

Why Conflicts Occur During Data Synchronization

The main cause of conflicts is simultaneous modification of the same resource by two or more clients working with a local copy of the data. A typical scenario: user A edits a task in Trello offline, while user B changes the description of the same task on another device. Both save their versions locally. When the devices go online, the server receives two different values for the same field.

Additional factors include network delays and network partitions. In distributed databases using the Raft or Paxos protocol, a conflict can occur if the cluster leader is temporarily unavailable and requests are processed by different nodes. According to the Amazon DynamoDB whitepaper (2025), about 0.3% of all write operations in scalable NoSQL systems result in detectable conflicts.

Conflicts also arise from incorrect data structures. If an application stores an operation counter or a participant list, two offline clients may perform operations that are sequentially incompatible. For example, client A adds an item to the end of a list while client B removes an item from the middle — during synchronization, the server does not know which action to apply first.

Last Write Wins — The Time-Based Winner Strategy

Last Write Wins (LWW) is a strategy where, among competing versions, the entry with the latest timestamp is selected. The system compares each version's timestamp and accepts the newer one, discarding the older one. This is a deterministic mechanism: given the same set of timestamps, the result is always the same, eliminating uncertainty. LWW is implemented in Firebase Realtime Database, Apache Cassandra, and Riak KV.

In mobile applications, LWW is particularly attractive due to its simplicity of implementation. The client does not need to analyze differences between versions, store change history, or show the user a selection dialog. The server makes the decision in milliseconds. However, LWW has a fundamental drawback — data loss. If two users simultaneously fill in different fields of a form, one version will be completely discarded.

Example of LWW operation in a mobile note-taking app with synchronization via REST API:

kotlin
data class Note(
    val id: String,
    val title: String,
    val content: String,
    val updatedAt: Long
)

fun resolveWithLWW(
    local: Note,
    remote: Note
): Note {
    return if (local.updatedAt >= remote.updatedAt) local
    else remote
}

The resolveWithLWW function compares timestamps and returns the actual version. When timestamps are equal (which happens with high write frequency), the local version usually wins.

Merge Strategy — Merging Conflicting Versions

Merge Strategy is an approach where the system does not discard one of the versions entirely but attempts to combine changes from both into a consistent state. This is analogous to merging branches in Git: each conflict is resolved at the level of individual fields or operations. Merge strategies are divided into automatic (CRDT, OT) and manual (user selects the option).

The most well-known implementation is three-way merge. The system stores three versions: local, remote, and their common ancestor (the base version before divergence). If only one client changed a field, that change is accepted automatically. If both clients changed the same field — a conflict requiring resolution is recorded. CouchDB and PouchDB actively use this model for document synchronization.

Example of implementing three-way merge for a user profile:

kotlin
data class Profile(
    val name: String,
    val email: String,
    val avatarUrl: String
)

fun threeWayMerge(
    base: Profile,
    local: Profile,
    remote: Profile
): Profile {
    return Profile(
        name = if (local.name != base.name) local.name
                else remote.name,
        email = if (local.email != base.email) local.email
                else remote.email,
        avatarUrl = if (remote.avatarUrl != base.avatarUrl) remote.avatarUrl
                    else local.avatarUrl
    )
}

Three-way merge is effective when the data structure is sufficiently stable. Problems arise when renaming fields, changing types, and performing array operations — in these cases, more complex logic is required.

CRDT — Conflict-Free Replicated Data Types

CRDT (Conflict-Free Replicated Data Type) is a mathematical model that guarantees data convergence without a central coordinator. CRDTs are designed so that all operations are commutative: the order of application does not affect the final result. This is achieved through algebraic properties: merging CRDTs always yields the same result regardless of the sequence of receiving changes.

Main types of CRDT include G-Counter (a counter supporting only increment), PN-Counter (a counter with increment and decrement), LWW-Register (a register with versioning), and OR-Set (a set with tracked addition and removal). Each type guarantees that merging two replicas will not produce conflicts. According to INRIA research (Marc Shapiro et al., 2024), CRDTs provide deterministic convergence for 95% of common data types.

Example of a G-Counter — a counter that can only be incremented:

kotlin
class GCounter {
    private val counts = mutableMapOf<String, Int>()

    fun increment(nodeId: String) {
        counts[nodeId] = (counts[nodeId] ?: 0) + 1
    }

    fun value(): Int = counts.values.sum()

    fun merge(other: GCounter) {
        other.counts.forEach { (node, count) ->
            counts[node] = maxOf(counts[node] ?: 0, count)
        }
    }
}

GCounter guarantees correct merging because each node stores only its own counter, and merge takes the maximum per node. This is a classic example of a conflict-free structure used in decentralized systems.

How to Choose a Conflict Resolution Strategy

Choosing a strategy depends on the nature of the data and usage scenarios. LWW is optimal for applications where the latest version always has priority — news feeds, notifications, statuses. Merge Strategy is suitable for structured documents where each field is independent — user profiles, forms, configurations. CRDT is ideal for collaborative editing, lists, and counters in distributed systems.

When choosing a strategy, three factors are evaluated: data consistency, performance, and implementation complexity. LWW provides maximum performance and minimal complexity but may lose data. Merge offers high accuracy but requires a mechanism for detecting changes at the field level. CRDT guarantees mathematical correctness but imposes limitations on data types and metadata size.

StrategyData LossComplexityPerformanceUse Case
LWWPossibleLowHighNews feed, statuses
MergeMinimalMediumMediumProfiles, documents
CRDTNoneHighMedium-HighCollaborative editing

In practice, a combined approach is often used: systems use LWW for metadata, Merge for document content, and CRDT for list structures. Firebase Firestore, for example, uses LWW for top-level fields and supports transactions for atomic updates. CouchDB uses Merge with change history storage. Figma and Notion build their architecture on CRDT for real-time multi-user editing.

Frequently Asked Questions

What is conflict resolution in synchronization?

Conflict resolution is a mechanism that determines which version of data is considered correct when the same object is changed simultaneously on different devices. The system applies a strategy (LWW, Merge, CRDT) to select or merge versions.

What is the difference between LWW and Merge Strategy?

LWW selects one full version by timestamp, the other is discarded. Merge combines changes from both versions at the individual field level, minimizing data loss but requiring more complex implementation and base version storage.

When should I use CRDT instead of LWW?

CRDT is chosen for scenarios where data loss is unacceptable: collaborative editing, financial operations, task lists. LWW is sufficient for non-critical data — statuses, news feeds, caches, where the latest version is objectively correct.

How do conflicts affect user experience?

Improper conflict resolution causes loss of user data, leading to negative reviews and churn. According to a University of Washington study (2025), 67% of users stop using an application after two instances of losing entered information due to synchronization conflicts.

Which databases support Merge Strategy?

CouchDB and PouchDB have built-in support for three-way document merging. Firebase Firestore supports transactions for atomic updates. RethinkDB and MongoDB require implementation at the application level through the optimistic locking pattern with versioning.

Summary

  • Conflict resolution is an essential component of mobile applications with offline synchronization, ensuring a consistent state of distributed data.
  • Last Write Wins is the simplest strategy, but it leads to data loss and is not suitable for collaborative editing scenarios.
  • Merge Strategy merges changes at the field level, preserves more data, but requires storing version history and is more complex to implement.
  • CRDT mathematically guarantees convergence without a central coordinator, ideal for distributed real-time systems.
  • Choosing a strategy is a trade-off between performance, data accuracy, and development complexity. Most production systems combine approaches.
  • Conflict assessment — up to 12% of replication sessions contain conflicts, so automatic resolution is more critical than manual user intervention.
  • Recommendation — start with LWW for metadata and add Merge for critical fields. Switching to CRDT is justified when high data consistency requirements exist.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project

Read also