Skip to content

Setting a custom RdKafka::PartitionerCb doesn't work in certain circumstances #5245

@wmorgan6796

Description

@wmorgan6796

Librdkafka Version: 2.11.1
GCC Version: 15.2
OS: Ubuntu 20.04

Bug:

When I set a RdKafka::PartitionerCb* on the default topic configuration that correct gets set on the C++ class, but never gets set on the underlying rkt conf struct. This means when the Default Topic Configuration is added to the Global Conf via

Conf::ConfResult set(const std::string &name,
                       const Conf *topic_conf,
                       std::string &errstr)

the internal call to rd_kafka_topic_conf_dup loses the pointer to the RdKafka::PartitionerCb* that was set in the default Topic Conf prior.

This means when we're calling a produce call that doesn't instantiate a RdKafka::Topic from the given Topic Conf, we will see the partitioner_cb_ ignored and we will find that it will instead use the default consistent_random partitioner (since it sees the underlying partitioner in the default rkt as NULL

Potential Fix:

When duplicating the default topic conf in the C++ function, you need to set the trampoline partitioner_cb_trampoline to the partitioner so that the C++ child class correctly gets called. The issue I can't seem to solve is how to get a pointer to the partitioner_cb_ into the *rkt_opaque

I think at a minimum there needs to be a note that unless you're using a produce call that takes a RdKafka::Topic*, you need to utilize the C API to set a custom partitioner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions