Alex Bligh
unread,Jan 6, 2016, 8:45:50 AM1/6/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Diego Ongaro, Alex Bligh, raft...@googlegroups.com, Archie Cobbs
On 6 Jan 2016, at 02:05, Diego Ongaro <
onga...@gmail.com> wrote:
>> However, I can see no way for S2 to determine whether or not this is the case as the list of IDs that have been processed is kept per server and not in the FSM.
>
> Agreed! The list of IDs that have been process should be part of the replicated state machine. As in, each server's state machine independently processes the requests to arrive at the same client session state.
OK thanks. I think perhaps the language might benefit from a little tidying.
> Archie is almost right, except for:
>
>> The overall transaction (client activity plus new table row) is then committed as a new Raft log entry
>
> The simplest way, I think, is to include the client table as part of the state machine and only consult it within the state machine. And the entire client request goes right into the Raft log as one entry, not two. A typical request in the Raft log then looks like:
> (client ID, serial number, command to modify primary data structure)
> Once an entry is committed, it's applied to the state machine. Assuming the request hasn't already been executed and has an effect, applying it updates both the state machine's primary data structure (key-value store or whatever) and also its client session table. The client session table is just part of the state machine state. That's it, no second entry needed, no consulting the client table until after the request was committed in the log.
Suppose the client's request/response also includes some state to return. Let us assume that the client's call is an RPC call to set the value of a given key in a key/value store AND return the previous value. This would be the sort of call that we would want to ensure runs exactly once, as if it runs twice the returned value would be wrong.
In the situation where the leader's response is lost, there are two possibilities: either the leader has applied the transaction or it has not. The client resends the request. The above method allows the leader to determine whether the original transaction was applied. If not it applies it now. If it has been applied, how does it return the old value, now it has been removed from the K/V store?
What I was doing was simply caching queries and replies (on a per server basis) and discarding those appropriately. Do I need to effectively put the entire cache into the FSM? I have a nasty suspicion the session cache might then become the largest part of the FSM!
--
Alex Bligh