You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if errors.Is(err, ErrStreamNameAlreadyInUse) {
if si, _ = js.StreamInfo(scfg.Name); si != nil {
// To compare, make the server's stream info discard
// policy same than ours.
si.Config.Discard = scfg.Discard
// Also need to set allow direct for v2.9.x+
si.Config.AllowDirect = scfg.AllowDirect
if reflect.DeepEqual(&si.Config, scfg) {
si, err = js.UpdateStream(scfg)
}
}
}
In my opinion it must be like this:
if errors.Is(err, ErrStreamNameAlreadyInUse) {
if si, _ = js.StreamInfo(scfg.Name); si != nil {
// To compare, make the server's stream info discard
// policy same than ours.
si.Config.Discard = scfg.Discard
// Also need to set allow direct for v2.9.x+
si.Config.AllowDirect = scfg.AllowDirect
if reflect.DeepEqual(&si.Config, scfg) {
err = nil
} else {
si, err = js.UpdateStream(scfg)
}
}
}
If configs are equals - do nothing, else - update stream. Now updating only if there are no changes - this is wrong.
The text was updated successfully, but these errors were encountered:
We do need a KV Update function - but maybe make it a specific function rather than overuse this code path. This code path mainly is there to upgrade configuration of old buckets to current internal needs afaik
Hello @MashinaMashina, thanks for creating the issue. As @ripienaar said, we'll be adding an UpdateKeyValue() method for that, rather than modifying create. Possibly we'll also add CreateOrUpdate to match what we have for streams and consumers.
Observed behavior
When I use nats.jetstream.CreateKeyValue after changing TTL, I got error "nats: stream name already in use"
Expected behavior
I use nats.jetstream.CreateKeyValue and the TTL will update.
Server and client version
nats-io/nats.go version 1.31.0
nats in docker: nats:2.9-alpine3.18
Host environment
No response
Steps to reproduce
... connect to nats
==================
this behavior because we have this code (https://github.com/nats-io/nats.go/blob/main/kv.go#L489):
In my opinion it must be like this:
If configs are equals - do nothing, else - update stream. Now updating only if there are no changes - this is wrong.
The text was updated successfully, but these errors were encountered: