Hi, again :sweat_smile: Do I have to set the key i...
# troubleshooting
f
Hi, again 😅 Do I have to set the key in Kafka in a specific format or a simple concatenation of the values I use as primary key in my upsert configuration would be enough? Ex. CustomerId_Category (these would be the values of my primary key) Or just setting a key to guarantee that the messages always go to the same partition is enough? The docs are not clear about this: https://docs.pinot.apache.org/basics/data-import/upsert#define-the-primary-key-in-the-schema Thanks!
m
You can define a composite key in Pinot that is a combination of multiple columns
f
Yes, I got that, and I'm using it like that. I'm just not clear if in Kafka I should set a key in a specific manner using the same values as the composite key, or simply adding a key like "pk1" + "pk2" all together would be enough
f
@Felipe Are you asking the question because you rely on Pinot's upsert to keep the latest state?
f
Yes, exactly
f
@Felipe The key will ensure the topic partition in Kafka where the message lands. As long as the messages land in the same partition, they'll be consumed in the order they were written in. For Pinot's upsert to work, you'll have to extract fields out of the Kafka payload that pertain to your table's primary key.
f
Thanks, I just wanted to be sure that I just needed to guarantee that the messages would go to the same partition. The docs made me a bit confused suggesting I should use the same values of my primary key as my Kafka Keys.
f
That'd be advisable since it keeps messages in the same partition.
f
Sure, I just want to avoid any hidden caveat like, "the keys should follow the pattern key1_key2" and so on. Thank you all for the support
Ok, the situation looks better, but it's not 100% yet. There are less duplicates now, and the duplicates are always falling in the same segments 🤔
for my other tables, there are no duplicates
c
What do you mean by you are seeing duplicates?Are you using skipUpsert=true, then you will see all the rows for a primary key. What is the hash function that you are using for this upsert table? Although the chance is very low there might be collisions for a primary key with hash function. And one more question to ask are you sending duplicates into pinot through different partitions? There is a chance of duplication in such case.
f
I didn't set any hash function. And I'm not using skipUpsert. But you might be right in the duplications sent by my side though 🤔 I will check the source of the data, I need to set the record keys there as well and some dedup logic. Ok, I believe that my configuration on Pinot is not the problem for now. Thanks again!
c
Also check how the ttl is set for primary keys, sometimes if it’s set too low but > 0, duplicates could also be visible in such cases if the primary key is removed from metadata map and a removed pk is ingested again. If it’s set to 0, or ttl is not specified, you are fine.
f
Interesting, I'll check that as well.