-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
khepri_machine: Introduce a fence mechanism
[Why] with the previous commits, we ensured that: 1. when a synchronous update returns, the local machine state is up-to-date; 2. Khepri would default to local queries, to eliminate the risks linked to remote executions and possible incompatible code. Therefore, a query ais local to make sure its execution is local and that it works on an up-to-date state. There is still the following scenario where this isn't enough: 1. The caller makes several asynchronous updates without a correlation ID, or overrides the default of `reply_from => local`. 2. The caller then performs a query. In this case, the query is unlikely to be executed after the asynchronous commands were applied. This is not a bug, the caller explicitly asked for asynchronous updates. The caller could use correlation IDs and wait for the replies. But without correlation IDs, it's not possible. [How] To help the caller in this case, this patch introduces `khepri:fence/{0,1,2}`. It is a blocking call that queries the Ra leader to learn its last index (the number of the last command it received), then performs an arbitrary local query, passing that index so that the query execution waits for that index to be committed locally. This way, by putting a call to `khepri:fence()` between asynchronous updates and a query, the caller ensures that the query will see the result of those asynchronous updates.
- Loading branch information
Showing
4 changed files
with
381 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.