These are chat archives for atomix/atomix

4th
Jul 2017
terrytan
@txm119161336_twitter
Jul 04 2017 08:37
Hi ,Jordan ,i found you have indexQuery check , like entry.index()>session.lastApplied, but as what i have seen ,the entry.index is from lastAppliedIndex, which means the entry.index will never be greater than session.lastapplied,right?
terrytan
@txm119161336_twitter
Jul 04 2017 09:14
This check is only for follower?
Jordan Halterman
@kuujo
Jul 04 2017 22:30

@txm119161336_twitter Keep in mind that is not an index from the local log. Query indexes are provided by the client. That index is used to ensure the client doesn't see state go back in time when it switches servers. For example, if a client submits a command to a leader and it's committed at index 10, then the same client submits a query to a follower whose state machine is at index 8, we have to make sure that follower catches up at least to index 10 before applying the query, otherwise sequential consistency is broken. The same goes for queries submitted to different servers. So any server that handles a command or query will respond with the lastApplied index when the operation was applied, and that's used by other servers to ensure they only apply operations after that point.

Similarly, sequence numbers are provided by clients to ensure operations are applied in the order in which they occur on the client. If a server receives a query with sequence number 10 from a client, but the last sequence number applied for that session was 8, it will wait for sequence number 9 for a command or 10 for a query from that same session to ensure operations are applied in the order in which the client submits them. This allows clients to retry operations and for different operations from the same client to take different paths to the leader without reordering them.