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

invalid jetstream publish response #1512

Closed
yeqown opened this issue Jan 6, 2024 · 7 comments
Closed

invalid jetstream publish response #1512

yeqown opened this issue Jan 6, 2024 · 7 comments
Labels
defect Suspected defect such as a bug or regression

Comments

@yeqown
Copy link

yeqown commented Jan 6, 2024

Observed behavior

if _, err = p.js.PublishMsg(msg); err != nil {
return err
}

then it returns the above error, I found this error message from nats.go and found it was defined as ErrInvalidJSAck, and used here:
image

These two code blocks return the error but without the root cause, it's uncertain while locating the error, what's worse the error is not stable enough to reproduce locally.

I'm using the remote nats-server to eliminate differences, the client is using the same code to reproduce, but it's not reproduced yet.

Expected behavior

I wonder dose this error will take any effect. Can I ignore this error directly, if not what could I do to locate the error cause and fix it?

Server and client version

server = 2.10.5
client = 1.28.0 / 1.27.1

Host environment

No response

Steps to reproduce

I could not reproduce it on my local yet

@yeqown yeqown added the defect Suspected defect such as a bug or regression label Jan 6, 2024
@Jarema
Copy link
Member

Jarema commented Jan 8, 2024

Thanks for filling the issue!

While it's always nice to know what caused this error, I don't think its necessary to improve the error handling and wrapping the Unmarshal error.

Are you interested in contribution here?

@yeqown
Copy link
Author

yeqown commented Jan 8, 2024

Thanks for filling the issue!

While it's always nice to know what caused this error, I don't think its necessary to improve the error handling and wrapping the Unmarshal error.

Are you interested in contribution here?

Thanks for replying.

I do not mean to wrap error here, I just wonder what caused this error. Actually, I want to figure out why, and any information to resolve this error. Now, It happens so frequently in my code.

Of course, I'd love to contribute here if it's really necessary.

@yeqown
Copy link
Author

yeqown commented Jan 8, 2024

@Jarema I log the detail of the ackResp and got this, the ErrInvalidJsAck raised here because of the empty resp.Data
image

Can you help me to analyze this deeply?

all changes here, checkout from v1.31: main...yeqown:nats.go:feat/debug

I alse tried to subscribe the _INBOX. directly and then I got:
e37d634e-da7d-4b24-8476-5513381722e3

Does it mean the client received a duplicated ack from the server side?

@piotrpio
Copy link
Collaborator

piotrpio commented Jan 8, 2024

Doubled response from the server definitely looks suspicious. Could you give us some more details so we may try and reproduce? It would be nice to have:

  • debug/trace server logs from when the publish and duplicated ack happen
  • stream config (mainly around policies)
  • are you using plain js.Publish() or do you use any additional options?

@yeqown
Copy link
Author

yeqown commented Jan 9, 2024

Doubled response from the server definitely looks suspicious. Could you give us some more details so we may try and reproduce? It would be nice to have:

  • debug/trace server logs from when the publish and duplicated ack happen
  • stream config (mainly around policies)
  • are you using plain js.Publish() or do you use any additional options?

@piotrpio

  1. logs with inbox filtered
    image

The server dose send 2 messages into inbox to cids(371 and 1423), and the first has 0 size, and the second is actually expected.

  1. Output of nats str info:
Information for Stream local_account created 2023-09-11 18:22:57

              Subjects: local_account.>
              Replicas: 1
               Storage: File

Options:

             Retention: Limits
       Acknowledgments: 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: 84,468
                 Bytes: 28 MiB
        First Sequence: 1 @ 2023-09-12 14:57:25 UTC
         Last Sequence: 84,468 @ 2024-01-09 09:28:46 UTC
      Active Consumers: 37
    Number of Subjects: 8
  1. yes, it's pure
    image
    image

@yeqown
Copy link
Author

yeqown commented Jan 9, 2024

😂😂😂 I thought I have figured out:

The message published was Respond at another subscribing client. It called msg.Respond

// Respond allows a convenient way to respond to requests in service based subscriptions.
func (m *Msg) Respond(data []byte) error {
	if m == nil || m.Sub == nil {
		return ErrMsgNotBound
	}
	if m.Reply == "" {
		return ErrMsgNoReply
	}
	m.Sub.mu.Lock()
	nc := m.Sub.conn
	m.Sub.mu.Unlock()
	// No need to check the connection here since the call to publish will do all the checking.
	return nc.Publish(m.Reply, data)
}

@yeqown
Copy link
Author

yeqown commented Jan 9, 2024

@Jarema I have make a PR to wrapping JS publish error, would you mind to push it going on 👏?

@yeqown yeqown closed this as completed Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

3 participants