Writable replication topology

Multi-primary replication: multiple writers require explicit conflict rules.

Multi-primary replication allows writes on more than one database member. It can reduce dependence on one primary and support regional or local writes, but concurrent changes, uniqueness, ordering and partition behavior become part of every production decision.

Key point: “all nodes can write” does not mean “all writes are safe.” The workload must be designed around the replication system’s certification, locking, ordering or conflict-resolution model.

Multi-primary replication with several writable database nodes
The replication topology must preserve row identity and business invariants under concurrent writes.

What multi-primary replication means

Multi-primary replication, also called multi-master replication in older terminology, is a topology in which multiple database members can accept write transactions and distribute those changes to peers.

Some systems certify transactions before commit. Some serialize changes through group communication or consensus. Others replicate asynchronously and resolve conflicts afterward. These approaches have very different guarantees, so product documentation and workload testing are essential.

Typical write workflow

Application writes to Node A
        ↓
Node A validates and executes transaction
        ↓
Change set is ordered, certified or logged
        ↓
Peer nodes apply the transaction
        ↓
Commit is acknowledged according to the durability model

The critical questions are when the transaction is considered committed, whether peer confirmation is required, what happens when another transaction touches the same data, and how a disconnected node rejoins.

Conflict types

Update-update conflicts

Two nodes update the same row or logical entity concurrently. Certification may abort one transaction, while asynchronous systems may apply a resolution rule later.

Insert and uniqueness conflicts

Different nodes insert the same primary key, unique key, email, order number or other business identifier. Local validation can succeed on both nodes before replication exposes the collision.

Delete-update conflicts

One node deletes a row while another updates it. The final state depends on ordering and conflict policy.

Business invariant conflicts

Transactions may touch different rows but violate a global rule, such as overselling inventory, exceeding an account limit or assigning the same scarce resource twice. Row-level conflict detection may not protect these invariants.

Conflict prevention strategies

  • Single-writer ownership: route each tenant, key range or entity to one designated writer.
  • Partitioned writes: use different nodes for non-overlapping data sets.
  • Certification: detect overlapping write sets and abort conflicting transactions.
  • Global ordering: serialize transactions through consensus or deterministic ordering.
  • Commutative operations: design updates that can merge safely when the business model allows it.
  • Idempotency keys: prevent duplicate effects during retries.
  • Global identity generation: avoid primary key and sequence collisions.

Conflict resolution after the event should be a last, well-specified mechanism. Silent last-write-wins policies may be unacceptable for financial, inventory or compliance data.

Synchronous versus asynchronous behavior

ModelBenefitTradeoff
Synchronous or certification-basedStronger coordination before acknowledgement.Commit latency and availability can depend on peer communication or quorum.
AsynchronousFast local writes and tolerance of disconnected operation.Lag, divergence and post-write conflict resolution.
Ownership-based asynchronousLocal writes without overlapping ownership.Requires accurate routing and controlled ownership changes.

Multi-primary versus active-active

Multi-primary is a replication capability. Active-active is the broader service model. An active-active design may use multi-primary replication, but it may instead use sharded ownership, one writer per region, active reads with centralized writes, or a native distributed SQL database. Review the active-active database guide for the broader context.

Operational checklist

  • document supported isolation levels and conflict behavior;
  • test concurrent insert, update and delete patterns;
  • protect primary keys, unique keys and sequences;
  • monitor certification failures, replication lag and node membership;
  • define network-partition and quorum behavior;
  • control schema changes across members;
  • test node rejoin, state transfer and full rebuild;
  • verify backup restoration does not reintroduce conflicting state.

ShardronDB perspective

ShardronDB does not describe itself as generic multi-primary replication. Its public model uses a gateway to control requests before they reach relational nodes, assigns node-local ownership and separates primary and backup placement. This can reduce overlapping write domains compared with unrestricted multi-writer replication.

The PK Guard rule also rejects client-supplied primary key values for normal inserts. Identity generation occurs after validation, while trusted migration, backup and recovery paths are explicitly separated. Read the primary key collision guide and the coordination-layer guide.

Frequently asked questions

What is multi-primary replication?

Multi-primary replication allows more than one database member to accept writes and replicate those changes to other members.

Is multi-primary always synchronous?

No. Multi-primary systems can be synchronous, virtually synchronous or asynchronous. The consistency, latency and conflict behavior depend on the implementation.

What causes conflicts in multi-primary replication?

Conflicts occur when separate nodes modify the same row, unique key, sequence or dependent business state before the changes are mutually visible or serialized.

Is multi-primary the same as sharding?

No. Multi-primary usually creates writable copies of overlapping data. Sharding assigns different subsets of data to different owners. They can be combined.