Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-14546 - Support Partitioner fallback to default #14531

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

jimbogithub
Copy link

Allow custom Partitioners to fallback to default partitioning.

@jimbogithub
Copy link
Author

See https://issues.apache.org/jira/browse/KAFKA-14546 for rationale.

Copy link

This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has merge conflicts, please update it with the latest from trunk (or appropriate release branch)

If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.

@github-actions github-actions bot added the stale Stale PRs label Jan 10, 2024
@jimbogithub
Copy link
Author

This PR is still valid and desired, has no merge conflicts and does build despite Jenkins protestations. I do not have the ability to add Reviewers.

@@ -1368,7 +1368,7 @@ private int partition(ProducerRecord<K, V> record, byte[] serializedKey, byte[]
if (record.partition() != null)
return record.partition();

if (partitioner != null) {
if (partitioner != null && partitioner.partitionsTopic(record.topic())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a slight change to the behavior of the current API, could you modify the documentation?

@philipnee
Copy link
Collaborator

@jimbogithub - thanks for the PR, i've got a few questions to clarify:

  • KafkaProducer.partition(...) not throw IllegalArgumentException if the Partitioner returns RecordMetadata.UNKNOWN_PARTITION : I'm not sure if any partitioner actually return this UNKNOWN_PARTITION. it should be returned by the producer.partition no?
  • to the question above, I think different partitions has different implementations of handling missing topics. but since they all return some partition, are the default behaviors insufficient? bottom line is I'm not 100% convincing that the fallback to default is actually needed.
  • there's no test for the change you made. i think it would be good to add some to demonstrate some of the use cases.
  • I would also update the PR description. you can just use whatever described in the PR.

@jolshan - if you get time maybe you can review this? it seems like you implemented a few partitioner so you are probably the better person to speak about this... thanks!

* @param topic The topic name
*/
default boolean partitionsTopic(String topic) {
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it true by default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea is that this would be implemented differently by different custom partitioners. As default though there is no change from current behavior.

@jolshan
Copy link
Contributor

jolshan commented Jan 10, 2024

I think this change would require a KIP since it modifies the public API.

@github-actions github-actions bot removed the stale Stale PRs label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants