diff --git a/server/filestore.go b/server/filestore.go index a9a215e0e10..5e5ed7e040a 100644 --- a/server/filestore.go +++ b/server/filestore.go @@ -10669,8 +10669,14 @@ func (fs *fileStore) deleteBlocks() DeleteBlocks { // deleteMap returns all interior deletes for each block based on the mb.dmap. // Specifically, this will not contain any deletes for blocks that have been removed. // This is useful to know whether a tombstone is still relevant and marked as deleted by an active block. -// All blocks should be at least read locked. +// No locks should be held. func (fs *fileStore) deleteMap() (dmap avl.SequenceSet) { + fs.mu.RLock() + defer fs.mu.RUnlock() + + fs.readLockAllMsgBlocks() + defer fs.readUnlockAllMsgBlocks() + for _, mb := range fs.blks { if mb.dmap.Size() > 0 { mb.dmap.Range(func(seq uint64) bool {