Skip to content

Instantly share code, notes, and snippets.

@kjnilsson
Last active April 9, 2019 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjnilsson/ff0d79afc88bb583c95a9b2a64a31705 to your computer and use it in GitHub Desktop.
Save kjnilsson/ff0d79afc88bb583c95a9b2a64a31705 to your computer and use it in GitHub Desktop.
add two fields to append_entries_rpc:
read_index :: non_neg_integer()
echo :: boolean()
and one field to append_entries_reply:
read_index :: non_neg_integer()
All consistent queries are assigned a monotonic read index / token that is reset to 0 every time there is a leader change.
every append_entries_rpc includes the largest assigned read index and every append_entries_reply includes the highest read index seen
by each follower. The read index seen by each follower is stored in the "peer map" and can be used to work out the highest read index for which the leader has had a follower confirmation. Just like match_index tracks which log index each follower has confirmed they have seen.
Every time the read index "result" (the consensus calculation) is incremented by the follower all waiting readers can be served that
have been assigned a lower or equal read index.
If the `echo` flag is set the follower knows to echo back an append_entries_reply immediately and not wait for the next disk write to complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment