RAFT based Changes to commit logs

For Dgraph, RocksDB is our state machine. When we commit our dirty posting lists to RocksDB, and once we have confirmed sync to disk, we can discard the logs.

This mechanism is great because we can avoid storing our commit logs. Each mutation would get written to RAFT logs, from where they’d get applied to RocksDB (state machine). As we merge our dirty posting lists, we can discard the older RAFT logs.

In the case of server crash and restart, it would proactively go through all pending logs and apply them to the posting lists (state machine), if they haven’t already been applied. So, when we bring a posting list in memory during query execution, we wouldn’t have to go through our commit logs to ensure it has the latest entries. This would make our query execution faster.

In fact, we can probably just use memory-based RAFT logs. Because, even if a server crashes, the other servers in the cluster can bring it back up to the latest update log. Though, it might be safer to store them on disk in case multiple servers crash at the same time. So, we don’t lose history.

@minions: Read through this and see if you have any suggestions.

That does sound right to me with whatever limit knowledge I have.

What I am trying to understand is his how our posting list would work with RAFT. I am guessing all mutations would be stored in RAFT logs on all machines, but only the machine/machines corresponding to a predicate would apply those logs.

So, each posting list would be part of a RAFT group, composed of 3 servers. One of these servers would be the leader and the other two followers (replicas). Mutations would only be stored in the RAFT group the posting list belongs to. They won’t be stored on each server in the entire cluster. So, in other words, mutations applicable to PLs would only be stored in max three servers.

There would be a cluster-wide RAFT group, but that’d store the PL to server mapping – so each server knows which server to query for a given PL.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.