Also, unlock before calling Act.

This was suggested in a comment for #3588 and seems to work fine without stalls.
This commit is contained in:
Vivianne Langdon 2025-08-12 20:28:36 -04:00
parent 0e10d89791
commit 5f56cf78bc

View file

@ -289,10 +289,10 @@ func (w *worker) _next() {
// down the subscriber to free up resources. It'll get started // down the subscriber to free up resources. It'll get started
// again if new activity happens. // again if new activity happens.
w.Lock() w.Lock()
defer w.Unlock()
// inside the lock, let's check if the ephemeral consumer saw something new! // inside the lock, let's check if the ephemeral consumer saw something new!
// If so, we do have new messages after all, they just came at a bad time. // If so, we do have new messages after all, they just came at a bad time.
if w.ephemeralSeq > w.durableSeq { if w.ephemeralSeq > w.durableSeq {
w.Unlock();
w.Act(nil, w._next) w.Act(nil, w._next)
return return
} }
@ -301,6 +301,7 @@ func (w *worker) _next() {
logrus.WithError(err).Errorf("Failed to unsubscribe to stream for room %q", w.roomID) logrus.WithError(err).Errorf("Failed to unsubscribe to stream for room %q", w.roomID)
} }
w.subscription = nil w.subscription = nil
w.Unlock()
return return
case nats.ErrConsumerDeleted, nats.ErrConsumerNotFound: case nats.ErrConsumerDeleted, nats.ErrConsumerNotFound:
w.Lock() w.Lock()