diff --git a/server/consumer.go b/server/consumer.go index 8a046819d5..28951dec53 100644 --- a/server/consumer.go +++ b/server/consumer.go @@ -5787,12 +5787,14 @@ func (o *consumer) cleanupNoInterestMessages(mset *stream, ignoreInterest bool) return } + mset.mu.RUnlock() + mset.mu.Lock() for seq := start; seq <= stop; seq++ { if mset.noInterest(seq, co) { rmseqs = append(rmseqs, seq) } } - mset.mu.RUnlock() + mset.mu.Unlock() // These can be removed. for _, seq := range rmseqs {