Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operations on KV store doesn't work #165

Open
munjalpatel opened this issue Jul 20, 2024 · 1 comment
Open

Operations on KV store doesn't work #165

munjalpatel opened this issue Jul 20, 2024 · 1 comment

Comments

@munjalpatel
Copy link

munjalpatel commented Jul 20, 2024

I have the coordinates KV bucket in NGS Cloud. I mirrored that bucket to my leaf node dev
When I try to put and get KV keys using nats cli, it works fine.

However, I keep getting no message found for get and :timeout for put operations on KV using this library.


nats context info

NATS Configuration Context "gtg-local"

  Server URLs: nats://127.0.0.1:4222
         Path: /Users/munjalapatel/.config/nats/context/gtg-local.json

nats kv ls

╭────────────────────────────────────────────────────────────────────────────────╮
│                                Key-Value Buckets                               │
├─────────────┬─────────────┬─────────────────────┬───────┬────────┬─────────────┤
│ Bucket      │ Description │ Created             │ Size  │ Values │ Last Update │
├─────────────┼─────────────┼─────────────────────┼───────┼────────┼─────────────┤
│ coordinates │             │ 2024-07-20 09:52:59 │ 100 B │ 1      │ 7m15s       │
╰─────────────┴─────────────┴─────────────────────┴───────┴────────┴─────────────╯

nats s ls -a

╭──────────────────────────────────────────────────────────────────────────────────────╮
│                                        Streams                                       │
├────────────────┬─────────────┬─────────────────────┬──────────┬───────┬──────────────┤
│ Name           │ Description │ Created             │ Messages │ Size  │ Last Message │
├────────────────┼─────────────┼─────────────────────┼──────────┼───────┼──────────────┤
│ KV_coordinates │             │ 2024-07-20 09:52:59 │ 1        │ 100 B │ 8m5s         │
╰────────────────┴─────────────┴─────────────────────┴──────────┴───────┴──────────────╯

PUT Operation

Trace using nats cli

nats kv put coordinates "33d00533601518134-m117d06731438930926.id" "na.us.ca.san-diego.san-diego" --trace

10:11:49 >>> $JS.API.STREAM.INFO.KV_coordinates


10:11:49 <<< $JS.API.STREAM.INFO.KV_coordinates: {"type":"io.nats.jetstream.api.v1.stream_info_response","total":0,"offset":0,"limit":0,"config":{"name":"KV_coordinates","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":"memory","num_replicas":1,"duplicate_window":120000000000,"placement":{},"mirror":{"name":"KV_coordinates","external":{"api":"$JS.ngs.API","deliver":""}},"compression":"none","allow_direct":true,"mirror_direct":true,"sealed":false,"deny_delete":true,"deny_purge":false,"allow_rollup_hdrs":true,"consumer_limits":{}},"created":"2024-07-20T16:52:59.765798Z","state":{"messages":1,"bytes":100,"first_seq":1,"first_ts":"2024-07-20T17:00:21.261461449Z","last_seq":1,"last_ts":"2024-07-20T17:00:21.261461449Z","num_subjects":1,"consumer_count":0},"cluster":{"name":"dev","leader":"dev"},"mirror":{"name":"KV_coordinates","external":{"api":"$JS.ngs.API","deliver":""},"lag":0,"active":841691000},"ts":"2024-07-20T17:11:49.390147Z"}
na.us.ca.san-diego.san-diego

Trace using this library

:ok = KV.put_value(:gnat, "coordinates", "#{key}.id", id)

│ !!! REQ
│ %{
│   body: "na.us.ca.san-diego.san-diego",
│   topic: "$KV.coordinates.33d005376074881035-m117d0675056841886.id",
│   recipient: #PID<0.854.0>
│ }
│ ---
│ !!! SUB
│ "_INBOX.PpTLlRUldV4e6CTK.0IYlNCdIOtX1JaQd"
│ ---
│ !!! RES
│ {:error, :timeout}

GET Operation
Trace using nats cli

nats kv get coordinates "33d00533601518134-m117d06731438930926.id" --trace

10:17:19 >>> $JS.API.STREAM.INFO.KV_coordinates


10:17:19 <<< $JS.API.STREAM.INFO.KV_coordinates: {"type":"io.nats.jetstream.api.v1.stream_info_response","total":0,"offset":0,"limit":0,"config":{"name":"KV_coordinates","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":"memory","num_replicas":1,"duplicate_window":120000000000,"placement":{},"mirror":{"name":"KV_coordinates","external":{"api":"$JS.ngs.API","deliver":""}},"compression":"none","allow_direct":true,"mirror_direct":true,"sealed":false,"deny_delete":true,"deny_purge":false,"allow_rollup_hdrs":true,"consumer_limits":{}},"created":"2024-07-20T16:52:59.765798Z","state":{"messages":1,"bytes":100,"first_seq":2,"first_ts":"2024-07-20T17:11:49.470524286Z","last_seq":2,"last_ts":"2024-07-20T17:11:49.470524286Z","num_subjects":1,"consumer_count":0},"cluster":{"name":"dev","leader":"dev"},"mirror":{"name":"KV_coordinates","external":{"api":"$JS.ngs.API","deliver":""},"lag":0,"active":303980000},"ts":"2024-07-20T17:17:19.958569Z"}
10:17:19 >>> $JS.API.DIRECT.GET.KV_coordinates.$KV.coordinates.33d00533601518134-m117d06731438930926.id


10:17:19 <<< $JS.API.DIRECT.GET.KV_coordinates.$KV.coordinates.33d00533601518134-m117d06731438930926.id: na.us.ca.san-diego.san-diego
coordinates > 33d00533601518134-m117d06731438930926.id revision: 2 created @ 20 Jul 24 17:11 UTC

na.us.ca.san-diego.san-diego

Trace using this library

KV.get_value(:gnat, "coordinates", "#{key}.id")

│ !!! REQ
│ %{
│   body: "{\"last_by_subj\":\"$KV.coordinates.33d005376074881035-m117d0675056841886.id\"}",
│   topic: "$JS.API.STREAM.MSG.GET.KV_coordinates",
│   recipient: #PID<0.854.0>
│ }
│ ---
│ !!! SUB
│ "_INBOX.PpTLlRUldV4e6CTK.xYhioQgY+h76NT1E"
│ ---
│ !!! RES
│ {:ok,
│  %{
│    body: "{\"type\":\"io.nats.jetstream.api.v1.stream_msg_get_response\",\"error\":{\"code\":404,\"err_code\":10037,\"description\":\"no message
│ found\"}}",
│    gnat: #PID<0.807.0>,
│    topic: "_INBOX.PpTLlRUldV4e6CTK.xYhioQgY+h76NT1E",
│    reply_to: nil
│  }}
@jcreager
Copy link
Contributor

@munjalpatel can you provide a more complete example with steps to reproduce? KV.get_value(:gnat, "coordinates", "#{key}.id") is not readily reproducible because "#{key}.id" is derived from a variable in your application. Without knowing the value no-one can say if the error lies within this library or your application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants