1
0
Fork 0

Make a init case cleare for IsStaleRead

master
Philip O'Toole 7 months ago
parent 54d925ef46
commit 091c078b02

@ -39,6 +39,11 @@ func IsStaleRead(
// Strict mode is not enabled, so no further checks are needed. // Strict mode is not enabled, so no further checks are needed.
return false return false
} }
if lastAppendedAtTime.IsZero() {
// We've yet to be told about any appended log entries, so we
// assume we're caught up.
return false
}
if fsmIndex == commitIndex { if fsmIndex == commitIndex {
// FSM index is the same as the commit index, so we're caught up. // FSM index is the same as the commit index, so we're caught up.
return false return false

@ -44,6 +44,13 @@ func Test_IsStaleRead(t *testing.T) {
Freshness: time.Second, Freshness: time.Second,
Exp: true, Exp: true,
}, },
{
Name: "freshness set and ok, strict is set, but no appended time",
LeaderLastContact: time.Now(),
Freshness: 10 * time.Second,
Strict: true,
Exp: false,
},
{ {
Name: "freshness set, is ok, strict is set, appended time exceeds, but applied index is up-to-date", Name: "freshness set, is ok, strict is set, appended time exceeds, but applied index is up-to-date",
LeaderLastContact: time.Now(), LeaderLastContact: time.Now(),

Loading…
Cancel
Save