streamnative / pulsar-rs

Rust Client library for Apache Pulsar
Other
369 stars 121 forks source link

If the producer message generated by pulsar client is encapsulated as a function, only one message can be sent in a topic #314

Open Mr-lq7 opened 5 months ago

Mr-lq7 commented 5 months ago

Environmental Info: rust pulsar client sdk Version: v6.3.0

Node(s) CPU architecture, OS, and Version:

host machine: Linux SMP Sat Oct 7 17:52:50 CST 2023 x86_64 x86_64 x86_64 GNU/Linux

Pulsar Cluster Configuration:

I Install the pulsar cluster version, the link: https://github.com/apache/pulsar-helm-chart/tree/pulsar-2.9.4 ,the docker image version of pulsar is 2.10.3

Describe the bug:

When I call the function send_msg twice,only one message sent successfully on the same topic,the other messages cannot sent successfully.

Steps To Reproduce:

  1. this is the send_msg function, it uses producer to send bytes array and the msg id will be printed if the message is sent;

    image
  2. the load function calls the send_msg function

    image
  3. when the send_msg is called twice by load function(step 2), the second message cannot sent successfully. The log is as follows:

[2024-06-19T06:21:07Z WARN pulsar::retry_op] Retry #0 -> connecting producer 0 :topic persistent://default/public/test, Message sent successfully: CommandSendReceipt { producer_id: 0, sequence_id: 0, message_id: Some(MessageIdData { ledger_id: 5508, entry_id: 0, partition: None, batch_index: None, ack_set: [], batch_size: None, first_chunk_message_id: None }), highest_sequence_id: Some(18446744073709551615) }

[2024-06-19T06:21:08Z WARN pulsar::retry_op] Retry #0 -> connecting producer 1:topic persistent://default/public/test, Message sent successfully: CommandSendReceipt { producer_id: 1, sequence_id: 0, message_id: Some(MessageIdData { ledger_id: 18446744073709551615, entry_id: 18446744073709551615, partition: None, batch_index: None, ack_set: [], batch_size: None, first_chunk_message_id: None }), highest_sequence_id: Some(18446744073709551615) }

We can find the second message's ledger_id is very strange, and the highest_sequence_id value ​​of both messages are weird ,too

  1. I use the pulsar-admin,command: pulsar-admin topics stats-internal persistent://default/public/test, finds that only the first message is sent successfully.

  2. But when the message is sent twice in send_msg, it works well, the code is as follows:

    image
  3. When I use pulsar's command-line tools(pulsar-client) for production and consumption, I don't have a problem,so I think the pulsar server is OK. Thus, maybe some problems happen in rust pulsar sdk,or maybe because of the asynchronous problem, the message cannot be wrapped with send_msg.

This problem puzzles me very long time, how can I do? Thanks a lot!