After implementing max_attempts I noticed some rather old messages that had negative attempt counts. After investigating I noticed that the nsqd message format defines attempts as an unsigned 16-bit integer. The current unpack implementation is unpacking it as a signed integer which means you end up with negative attempts in ruby-land.
After implementing
max_attempts
I noticed some rather old messages that had negative attempt counts. After investigating I noticed that the nsqd message format definesattempts
as an unsigned 16-bit integer. The currentunpack
implementation is unpacking it as a signed integer which means you end up with negative attempts in ruby-land.NSQ message format: https://github.com/nsqio/nsq/blob/cc29d7202e35b6d94d361fa9890077048a1d0763/nsqd/message.go#L68-L77
Ruby unpack reference: https://ruby-doc.org/core-2.4.0/String.html#method-i-unpack
example: