bugfix: don't try to process messages if we timeout

Due to a bad merge, timeouts were not early-returning and so could cause a stall
in the roomserver. Fix the bad merge and early-out.

Signed-off-by: Vivianne Langdon <puttabutta@gmail.com>
This commit is contained in:
Vivianne Langdon 2025-08-12 19:36:57 -04:00
parent 5e05f3090b
commit 0e10d89791

View file

@ -289,14 +289,19 @@ 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.Act(nil, w._next) w.Act(nil, w._next)
w.Unlock()
return return
} }
w.Unlock()
if err = w.subscription.Unsubscribe(); err != nil {
logrus.WithError(err).Errorf("Failed to unsubscribe to stream for room %q", w.roomID)
}
w.subscription = nil
return
case nats.ErrConsumerDeleted, nats.ErrConsumerNotFound: case nats.ErrConsumerDeleted, nats.ErrConsumerNotFound:
w.Lock() w.Lock()
defer w.Unlock() defer w.Unlock()