Hi, we are using a Pulsar cluster of 3 nodes v3.1....
# general
j
Hi, we are using a Pulsar cluster of 3 nodes v3.1.1. We're using partitioned topics. There are 3 hosts that run 25 instances of consumers configured in Key_Shared mode. While I'm executing :
Copy code
sudo -u pulsar /opt/pulsar/apache-pulsar/bin/pulsar-admin topics stats <persistent://public/default/postprocess.request-partition-0>  | grep keyHashRanges | grep -o "................$" | sort
Highest range value is
214719819
(0x7FFBA4F3) Why it's not
2147483647
(0x7FFFFFFF) ?
We're thinking this is linked to an issue we've got. We noticed that the key "D-25887" was very slow to consume. We try to calculate murmur hash in python through this simple code (it needs the dependency mmh3==4.0.1 )
Copy code
import mmh3
print(mmh3.hash("D-25887".encode(), signed=False) & 0x7FFFFFFF)
Execution gives
2147395553
that's higher than the highest range associated to our consumer (ie
214719819
)
ConsistentHashing is enabled
l
Highest range value is
214719819
(0x7FFBA4F3)
Why it's not
2147483647
(0x7FFFFFFF) ?
The implementation explains this. https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apach[…]/broker/service/ConsistentHashingStickyKeyConsumerSelector.java Key ranges concept doesn't really map well to ConsistentHashingStickyKeyConsumerSelector. I don't think that there's a problem. In the implementation, each consumer gets mapped to the hash range 100 times. With this information it will select a consumer with this logic: https://github.com/apache/pulsar/blob/48c85ab1707004dc27022c494dbc557f7c3e888c/pul[…]/broker/service/ConsistentHashingStickyKeyConsumerSelector.java Therefore I think that the "keyHashRanges" is a misleading concept for this algorithm.
We're thinking this is linked to an issue we've got. We noticed that the key "D-25887" was very slow to consume.
It's possible that it's a coincidence that the hash of the key is close to integer maximum value. What client & version are you using ?
I spotted one bug here: https://github.com/apache/pulsar/blob/48c85ab1707004dc27022c494dbc557f7c3e888c/pul[…]/broker/service/ConsistentHashingStickyKeyConsumerSelector.java . The modulus operation isn't "sign safe". That matters when there's a hash key collision and the hash value is negative.
👍 1
However, I don't know if that applies in your case
I'd assume that there would be an index out of bounds exception in the logs
The "sign safe modulus" fix: https://github.com/apache/pulsar/pull/22100
🙌 1
the problem exists for other Key_Shared implementations too. In other implementation it seems to have a real impact.
j
Thanks a lot for the detail, I'll spend some time understand the
select
method of
ConsistentHashingStickyKeyConsumerSelector
. Mainly, understand
NavigateMap
a Java Collection object I didn't know.
What client & version are you using ?
We are using broker & client version 3.1.1
👍 1