Search code examples
couchbasespring-data-couchbasecouchbase-java-api

Does couchbase persist data?


I am planning to store data into the couch-base cluster.

I would like to know what will happen if my couch base goes down for the following scenarios: [Consider that there were no active transactions happening]

  1. A node goes down from the cluster.(My assumption is after the node is fixed and is up, it will sync up with other nodes, and the data would be there). Also, let me know after it is synced up will there still be any data loss?
  2. The cluster went down and is fixed and restarted.

Please let me know data persistence analogy for the above scenarios.


Solution

  • Yes, Couchbase persists data to disk. It writes change operations to append-only files on the Data Service nodes.

    Data loss is unlikely for your two scenarios because there are no active transactions.

    Data loss can occur if a node fails

    • while persisting a change to disk or

    • before completing replication to another node if the bucket supports replicas.

    Example: Three Node Cluster with Replication

    Consider the case of a three node Couchbase cluster and a bucket with one replica for each document. That means that a single document will have a copy stored on two separate nodes, call those the active and the replica copies. Couchbase will shard the documents equitably across the nodes.

    1. When a node goes down, about a third of the active and replica copies become unavailable.

      A. If a brand new node is added and the cluster rebalanced, the new node will have the same active and replica copies as the old one did. Data loss will occur if replication was incomplete when the node failed.

      B. If the node is failed over, then replicas for the active documents on the failed node will become active. Data loss will occur if replication was incomplete when the node failed.

      C. If the failed node rejoins the cluster it can reuse its existing data so the only data loss would be due to a failure to write changes to disk.

    2. When the cluster goes down, data loss may occur if there is a disk failure.