streamnative/pulsar-rs

BUG,consumer.rs:872:29 attempt to subtract with overflow,

zhengxingjian opened this issue · 3 comments

`

      self.remaining_messages -= message
                            .payload
                            .as_ref()
                            .and_then(|payload| {
                                println!("len {} {:?}",self.remaining_messages,payload.metadata.num_messages_in_batch);
                                payload.metadata.num_messages_in_batch
                            })
                            .unwrap_or(1i32)
                            as u32;

`
When a large number of messages are consumed, they can be reproduced by sending tens of thousands of messages in a few seconds, and the log outputs data:len 610 Some(1000),610-1000 as u32 overflow

@zhengxingjian Could you explain in detail how to reproduce this issue?

If the batch_size used by producer is not smaller than the batch_size in consumer, the lib might panic in above position.

For example:

  • send in 10, receive in 1000 => it works.
  • send in 1000, receive in 100 => boom!