diff --git a/store/state.go b/store/state.go index 5e43fa8c..74191a9f 100644 --- a/store/state.go +++ b/store/state.go @@ -27,17 +27,24 @@ func IsStaleRead( strict bool, ) bool { if freshness == 0 { + // Freshness not set, so no read can be stale. return false } if time.Since(leaderlastContact).Nanoseconds() > freshness { + // The Leader has not been in contact witin the freshness window, so + // the read is stale. return true } if !strict { + // Strict mode is not enabled, so no further checks are needed. return false } if fsmIndex == commitIndex { + // FSM index is the same as the commit index, so we're caught up. return false } + // OK, we're not caught up. So was the log that last updated our local FSM + // appended by the Leader to its log within the freshness window? return lastFSMUpdateTime.Sub(lastAppendedAtTime).Nanoseconds() > freshness }