You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.
Any operation that is made at the cluster level requires a consensus,
meaning it will either be accepted by the majority of the cluster nodes (n/2 + 1), or completely fail to register.
This operation is named Raft Command or Raft Log.
Once issued, it is propagated through Rachis to all the nodes.
Only after the cluster's approval (majority of nodes ), it will eventually be executed on all cluster nodes.
In this page:
Operations that require Consensus
Since getting a consensus is an expensive operation, it is limited to the following operations only:
- Creating / Deleting a database
- Adding / Removing node to / from a Database Group
- Changing database settings (e.g. revisions configuraton , conflict resolving)
- Creating / Deleting Indexes (static and auto indexes)
- Configuring the Ongoing Tasks
See Implementation Details below.
Operations that do not require Consensus
It is important to understand that any document related operation does not require a consensus.
Any document CRUD operation or performing a query on an existing index is executed against a specific node,
even in the case of a cluster partition.
Since RavenDB keeps documents synchronized by Replication, any such operation is automatically replicated to all other nodes in the Database Group, so documents are always available for Read, Write and Query even if there is no majority of nodes in the cluster.
Raft Commands Implementation Details
Every Raft command is assigned a Raft Index, which corresponds to the commands sequence execution order.
For example, an operation with the index 7 is executed only after all operations with a smaller index have been executed.
If needed, a client with Valid User privileges can wait for a certain Raft command index to be executed on a specific cluster node.
This is done by issuing the following REST API call:
|Wait for Raft Command||
- The request will return after the corresponding Raft command was successfully applied -or-
timeoutis returned after
Cluster.OperationTimeoutInSechas passed (default: 15 seconds).
Raft Command Events Sequence
When a Raft command is sent, the following sequence of events occurs:
- The client sends the command to a cluster node.
- If the receiving node is not the Leader, it redirects the command to the Leader.
- The Leader appends the command to its log and propagates the command to all other nodes.
- If the Leader receives an acknowledgment from the majority of nodes, the command is actually executed.
- If the command is executed at the Leader node, it is committed to the Leader Log, and notification is sent to other nodes.
Once the other nodes receive the notification, they execute the command as well.
- If a Non-Leader node executes the command, it is added to the node log as well.
- The client receives the Raft Index of the command issued, so it can be waited upon.