This "lease" idea from the dissertation is a way to provide fully consistency reads efficiently.
First of all, we must be able to assume (a) clock slew is bounded by some value X%, and (b) all nodes are configured with the same election timeout minimum M. If so, then we can build into our protocol a simple mechanism to allow a leader to ask the question "Am I still the leader at this moment?" and with high likelihood be able to give an immediate answer of "yes" without any network communication.
Do this by having each message from Leader to Follower include the leader's current timestamp. Follower replies include a copy of this timestamp. Now the leader knows how "up-to-date" each follower is. In particular, for some easily calculated timestamp value X, the leader knows a majority of the cluster (including itself) is up-to-date as of leader time X.
The leader can then calculate its "lease timeout" LT, which is a lower bound on the earliest time at which it is possible for another leader to be elected: LT = X + M * (1.0 - X%).
During normal operation with regular heartbeats, the lease timeout will always be greater than the current time. So fully consistent reads are possible immediately on the leader, or via a single round trip communication from follower to leader asking the question "Is my latest entry also your latest entry?". In either case, if that last entry is not committed (in the Raft sense), the transaction simply waits for that to occur.
RaftKVDatabase has three other weaker consistency levels for read-only transactions besides
LINEARIZABLE: these are
UNCOMMITTED,
EVENTUAL, and
EVENTUAL_COMMITTED. These weaken various requirements in exchange for less network communication. In particular, the
EVENTUAL_COMMITTED is useful in situations where the network cannot be relied upon at all (e.g., a read-only transaction when you are in a minority network partition).
See
Consistency Javadoc for details.
-Archie