NatsKVContext.CreateStoreAsync (with defaults) fails on a NATS KV store created with defaults from CLI
ckasabula opened this issue · 2 comments
Observed behavior
Create a KV store from the CLI using defaults and then try to create the same store from nats.net/v2 with defaults, it fails (10058, "stream name already in use with a different configuration").
When I compare the config from a CLI created store with defaults vs a store created from code the only difference is Placement
. One observation is the cli created store has "placement": {}
where the c# generated store does not.
There is no way to specify placement when creating a KV store from code.
nats kv add cli
vs. await kvContext.CreateStoreAsync("csharp", cancellationToken);
CLI created store:
"config": {
"name": "KV_cli",
"subjects": [
"$KV.cli.>"
],
"retention": "limits",
"max_consumers": -1,
"max_msgs": -1,
"max_bytes": -1,
"max_age": 0,
"max_msgs_per_subject": 1,
"max_msg_size": -1,
"discard": "new",
"storage": "file",
"num_replicas": 1,
"duplicate_window": 120000000000,
"placement": {},
"compression": "none",
"allow_direct": true,
"mirror_direct": false,
"sealed": false,
"deny_delete": true,
"deny_purge": false,
"allow_rollup_hdrs": true,
"consumer_limits": {}
}
c# created store:
"config": {
"name": "KV_csharp",
"subjects": [
"$KV.csharp.>"
],
"retention": "limits",
"max_consumers": -1,
"max_msgs": -1,
"max_bytes": -1,
"max_age": 0,
"max_msgs_per_subject": 1,
"max_msg_size": -1,
"discard": "new",
"storage": "file",
"num_replicas": 1,
"duplicate_window": 120000000000,
"compression": "none",
"allow_direct": true,
"mirror_direct": false,
"sealed": false,
"deny_delete": true,
"deny_purge": false,
"allow_rollup_hdrs": true,
"consumer_limits": {}
}
Expected behavior
I should be able to create a store with defaults from CLI and then call NatsKVContext.CreateStoreAsync
with defaults. Also, I should be able to specify placement NATS.Client.JetStream.Models.Placement
via NatsKVConfig
when creating a KV store from code.
Server and client version
nats-server: v2.10.18
CLI client: 0.1.5
NATS.NET 2.3.1
Host environment
Windows 11 Pro - 23H2
Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz 2.90 GHz
Installed RAM 64.0 GB (63.8 GB usable)
Steps to reproduce
nats kv add cli
from code:
await kvContext.CreateStoreAsync("cli", cancellationToken);
I was able to avoid an error after modifying the library to include a Default (empty) Placement object. So the conflict does seem to be there. That said, I'm not sure if the CLI should stop including an empty placement or if the client is expected to send one.
I'm including some links for my reference. I'll do some more digging when I have time. Hopefully someone else can chime in with some subject matter expertise.
ADR-8 - includes placement
ADR-20 - includes placement
Jetstream Docs (Placement)