see on GitHub

Replication

Replication in RavenDB is the process of transferring data from one database to another.

The transferred entities are:

  • Documents
  • Revisions
  • Attachments
  • Conflicts

How does Replication works

  • The replication process sends data over a TCP connection by the modification order, from the oldest to the newest.
  • Every database has an ETag, which is incremented on every modification in the database's storage.
  • Each replication process has a source , destination and a last confirmed ETag which is the cursor to where the replication process is.
  • The data is sent in batches. When the destination confirms getting the data, the last accepted ETag is then advanced and the next batch of data is sent.

Replication Failure

In case of failure it will re-start with the Initial Handshake Procedure, which will make sure we will start replicating from the last accepted ETag.

Replication Transaction Boundary

The boundary of a transaction is extended across multiple nodes.
If there are several documents in the same transaction they will be sent in the same replication batch to keep the data consistent.

However this not always ensure the data consistency, since the same document can be modified in a different transactions and therefor be sent in a different batch.

Ensuring the replication consistency can be achieved by one of the following:

  1. Write Assurance.
  2. Enable Revisions and thus will replicate the revisions along side the documents.