From f8de05269efee8e8324a2dde1676ba41a41e78df Mon Sep 17 00:00:00 2001 From: Andrew Werner Date: Tue, 23 Apr 2019 17:31:35 -0400 Subject: [PATCH] storage: drop raftentry.Cache data in applySnapshot Add logic to clear cached raft log entries when applying a snapshot. Release note: None --- pkg/storage/replica_raftstorage.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/storage/replica_raftstorage.go b/pkg/storage/replica_raftstorage.go index 65bd758c584a..b16e2398ddaf 100644 --- a/pkg/storage/replica_raftstorage.go +++ b/pkg/storage/replica_raftstorage.go @@ -856,6 +856,9 @@ func (r *Replica) applySnapshot( if err := clearRangeData(ctx, s.Desc, r.store.Engine(), batch, true /* destroyData */); err != nil { return err } + // Clear the cached raft log entries to ensure that old or uncommitted + // entries don't impact the in-memory state. + r.store.raftEntryCache.Drop(r.RangeID) stats.clear = timeutil.Now() // Write the snapshot into the range.