nats.go: Jetstream KV watcher does not watch after NATS server restart
KV watcher does not do its job after Nats server is restarted.
nats.go version v1.17.0 nats server v2.9.1
Steps or code to reproduce the issue:
- Implement simple watch-all logic.
- Run nats server and client. Make updates with keys in a bucket. See, updates are coming.
- Restart nats server
watcher, err := flowsKV.WatchAll(nats.Context(ctx))
if err != nil {
return err
}
defer watcher.Stop()
for {
select {
case update := <-watcher.Updates():
if update == nil {
break
}
case <-ctx.Done():
return nil
}
}
Expected result:
After nats restart watcher backs to printing latest KV updates
Actual result:
Watcher gives no updates Error happens time to time nats: consumer not active on connection [101] for subscription on “$KV.bucket.>”
js.Subscribe() without nats.OrderedConsumer()
option behaves correctly, but this option is built-in into kv.Watch…
Thanks.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (17 by maintainers)
Seems to me that during a single invocation of ordered consumer it would know it’s state - what msg it received last.
So if the consumer is lost it can recreate it to continue from last known position.
It would have to do this anyway regardless of storage type since many things can happen to consumers.
If it did that it would be reliable even with memory storage.
Here I restarted the server mid-watch, the watcher never worked again and consumer was not recreated. Something not happy with ordered consumers recovery logic.