Skip to content

Commit

Permalink
[FIXED] mset.noInterest requires write lock (#6122)
Browse files Browse the repository at this point in the history
`mset.noInterest(..)` mentions it requires a write lock to be held:
```go
// Check if there is no interest in this sequence number across our consumers.
// The consumer passed is optional if we are processing the ack for that consumer.
// Write lock should be held.
func (mset *stream) noInterest(seq uint64, obs *consumer) bool {
	return !mset.checkForInterest(seq, obs)
}
```

This wasn't done in `cleanupNoInterestMessages`.

Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
  • Loading branch information
derekcollison authored Nov 13, 2024
2 parents 230745a + 8898d64 commit ffdef99
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ffdef99

Please sign in to comment.