nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
15.49k stars 1.38k forks source link

Invalid Nats server response when requesting stream information #3483

Closed cgapu closed 1 year ago

cgapu commented 1 year ago

Versions of nats-server and affected client libraries used:

nats server info:

     Version: 2.9.0
  Git Commit: 517d9b3
  Go Version: go1.19.1

nats --version

0.0.34

OS/Container environment:

nats server installed via helm, os info:

20.04.1-Ubuntu, x86_64

Steps or code to reproduce the issue:

  1. nats stream add test
? Subjects >
? Storage file
? Replication 1
? Retention Policy Limits
? Discard Policy Old
? Stream Messages Limit -1
? Per Subject Messages Limit -1
? Total Stream Size -1
? Message TTL -1
? Max Message Size -1
? Duplicate tracking time window 2m0s
? Allow message Roll-ups No
? Allow message deletion Yes
? Allow purging subjects or the entire stream Yes
Stream test was created
  1. nats stream info test

    
    Information for Stream test created 2022-09-21 18:05:31
    
             Subjects: >
             Replicas: 1
              Storage: File

Options:

        Retention: Limits
 Acknowledgements: true
   Discard Policy: Old
 Duplicate Window: 2m0s
Allows Msg Delete: true
     Allows Purge: true
   Allows Rollups: false

Limits:

 Maximum Messages: unlimited

Maximum Per Subject: unlimited Maximum Bytes: unlimited Maximum Age: unlimited Maximum Message Size: unlimited Maximum Consumers: unlimited

State:

         Messages: 12
            Bytes: 5.1 KiB
         FirstSeq: 1 @ 2022-09-21T10:05:31 UTC
          LastSeq: 12 @ 2022-09-21T10:11:00 UTC
 Active Consumers: 0

Number of Subjects: 7

3. nats stream info test

nats: error: could not pick a Stream to operate on: server response is not a valid "io.nats.jetstream.api.v1.stream_names_response" message: /type: value must be "io.nats.jetstream.api.v1.stream_names_response"


#### Expected result:
It  always prints correct stream information.
#### Actual result:
This error seems to appear randomly, I tried it a few times, sometimes it works, and sometimes this error occurs.
ripienaar commented 1 year ago

Can you show with the nats cli output with --trace.

In general you cant have stream subject > and I think that's what the problem is, you need to set specific subject spaces for streams and your subjects shouldnt overlap with your API subjects like $JS.>

cgapu commented 1 year ago

If I create a stream with a subject other than ">", this error doesn't reappear.

cgapu commented 1 year ago

18:35:05 >>> $JS.API.STREAM.INFO.test null

18:35:05 <<< $JS.API.STREAM.INFO.test {"stream":"test", "seq":48}

18:35:05 >>> $JS.API.STREAM.NAMES {"offset":0}

18:35:05 <<< $JS.API.STREAM.NAMES {"stream":"test", "seq":52}

nats: error: could not pick a Stream to operate on: server response is not a valid "io.nats.jetstream.api.v1.stream_names_response" message: /type: value must be "io.nats.jetstream.api.v1.stream_names_response"

ripienaar commented 1 year ago

yes, you cant have a stream with subject >, thats the cause.