Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED] Possible panic in consumer, needed to recheck if consumer was closed #4541

Merged
merged 2 commits into from Sep 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions server/consumer.go
Expand Up @@ -3794,7 +3794,9 @@ func (o *consumer) loopAndGatherMsgs(qch chan struct{}) {
sz int
wrn, wrb int
)

o.mu.Lock()

// consumer is closed when mset is set to nil.
if o.mset == nil {
o.mu.Unlock()
Expand All @@ -3817,6 +3819,13 @@ func (o *consumer) loopAndGatherMsgs(qch chan struct{}) {
// Grab our next msg.
pmsg, dc, err = o.getNextMsg()

// We can release the lock now under getNextMsg so need to check this condition again here.
// consumer is closed when mset is set to nil.
if o.mset == nil {
o.mu.Unlock()
return
}

// On error either wait or return.
if err != nil || pmsg == nil {
// On EOF we can optionally fast sync num pending state.
Expand Down