Couchbase Interview Questions Interview Questions

How conflicts resolution is handled in Couchbase when there is a bi-directional replication scheduled?

Conflicts and Their Resolution

conflict happens when the source and target copies of an XDCR-replicated document are updated independently of and dissimilarly to one another, each by a local application. The conflict must be resolved, by finding which of the variants should prevail; and then correspondingly saving both documents in identical form. XDCR provides an automated conflict resolution process.

Two, alternative conflict resolution policies are supported: revision-based (default), and timestamp-based. Note that timestamp-based conflict resolution is only available in the Enterprise Edition of Couchbase Server.

Revision-Based Conflict Resolution

Revision-based conflict resolution uses the document’s revision ID to resolve conflicts.

If both document-versions have the same revision ID, the conflict is resolved by comparing the following metadata-elements, in the order shown:

  1. CAS value
  2. Expiration (TTL) value
  3. Document flags

Timestamp-Based Conflict Resolution

Timestamp-based conflict resolution uses the document timestamp (stored in the CAS) to resolve conflicts.

If both document-versions have the same timestamp-value, the conflict is resolved by comparing the following metadata-elements, in the order shown:

  1. Revision ID
  2. Expiration (TTL) value
  3. Document flags

The Conflict Resolution Process

When a source document is modified, XDCR determines whether this revision of the document should be applied to the target. For documents above 256 bytes in size, XDCR fetches metadata from the target cluster before replicating. 

As a performance optimization, XDCR makes no metadata comparison on the source for documents of 256 bytes or less, thus making unnecessary a metadata fetch from the target cluster: instead, the document is replicated immediately to the target, and metadata comparison is performed there.

Once a replicated document reaches the target, the target cluster also performs a metadata comparison as described, in order to confirm that the document from the source cluster should indeed prevail. If this is confirmed, the document from the source cluster is applied to the target cluster, and the target cluster’s previous version of the document is discarded.

If a document is deleted on the source, XDCR makes no metadata comparison on the source before replication.


To know more about XDCR Conflict Resolution, click here

See,
Cross Data Center Replication (XDCR), XDCR Advanced Settings


Categories

Categories