From 55e651c1181291f786528800e6294e1b840d0061 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Tue, 1 Nov 2022 12:58:45 -0600 Subject: [PATCH] [FIXED] JetStream: processing of snapshot with expired messages The issue that a "first sequence mismatch" during processing of a snapshot was causing the state to be reset and caused a lot of catchup from the follower. An attempt to fix that in PR #3567 caused an issue that was addressed in PR #3589. However, this was then causing the follower to sometime never able to catchup or took a very long time. This PR - we believe - addresses the original and subsequent issues. Signed-off-by: Ivan Kozlovic --- server/jetstream_cluster.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/server/jetstream_cluster.go b/server/jetstream_cluster.go index 59626f6e..cfd8b25e 100644 --- a/server/jetstream_cluster.go +++ b/server/jetstream_cluster.go @@ -6683,7 +6683,7 @@ func (mset *stream) processSnapshotDeletes(snap *streamSnapshot) { // Always adjust if FirstSeq has moved beyond our state. if snap.FirstSeq > state.FirstSeq { mset.store.Compact(snap.FirstSeq) - state = mset.store.State() + mset.store.FastState(&state) mset.setLastSeq(state.LastSeq) } // Range the deleted and delete if applicable. @@ -6811,12 +6811,6 @@ func (mset *stream) processSnapshot(snap *streamSnapshot) (e error) { return nil } - // See if our state's first sequence is >= the leader's snapshot. - // This signifies messages have been expired, purged, deleted and the leader no longer has them. - if snap.FirstSeq < state.FirstSeq { - sreq.FirstSeq = state.FirstSeq + 1 - } - // Pause the apply channel for our raft group while we catch up. if err := n.PauseApply(); err != nil { return err @@ -6941,11 +6935,6 @@ RETRY: if sreq == nil { return nil } - // See if our state's first sequence is >= the leader's snapshot. - // This signifies messages have been expired, purged, deleted and the leader no longer has them. - if snap.FirstSeq < state.FirstSeq { - sreq.FirstSeq = state.FirstSeq + 1 - } // Reset notion of lastRequested lastRequested = sreq.LastSeq }