copycat
copycat copied to clipboard
Duplicate commands don't have to be committed to the Raft log
The current implementation of linearizable semantics for clients via sessions follows the Raft dissertation precisely. All commands are logged with a sequence number. When a command is applied to the state machine, if a command with that sequence number has already been evaluated, the command's cached output is returned. But this process does not have to occur through the log. Leaders have enough information to determine whether a command has already been written to the Raft log based on the command's sequence number. If a leader receives a command request for a sequence number that it already wrote to the Raft log, it can simply immediately return the cached output or if the cached output is not yet available (the original command has not been committed) store the request object until the original command is completed.