-
Notifications
You must be signed in to change notification settings - Fork 14.5k
(WIP)KAFKA-9965/KAFKA-13303: RoundRobinPartitioner broken by KIP-480 #20170
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
base: trunk
Are you sure you want to change the base?
(WIP)KAFKA-9965/KAFKA-13303: RoundRobinPartitioner broken by KIP-480 #20170
Conversation
partitioner.onNewBatch(topicB, testCluster, 1); | ||
assertEquals(7, partitioner.partition(topicA, null, null, null, null, testCluster)); | ||
assertEquals(8, partitioner.partition(topicA, null, null, null, null, testCluster)); | ||
assertEquals(1, partitioner.partition(topicB, null, null, null, null, testCluster)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great that this test verifies the next partition selected matches the enqueued value for each topic. Consider adding test cases for some edge cases, like empty queue and error handling
@@ -45,4 +45,7 @@ public interface Partitioner extends Configurable, Closeable { | |||
* This is called when partitioner is closed. | |||
*/ | |||
void close(); | |||
|
|||
default void onNewBatch(String topic, Cluster cluster, int prevPartition) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please consider using "casting" to invoke RoundRobinPartitioner#onNewBatch
if needs
RoundRobinPartitioner behaviour was broken by sticky partitioning (KIP-480).
This patch addresses the behavioural issue caused by the second call to
partition()
afteronNewBatch()
, in a predicatable and thread-safe manner.Unit tested by simulation of multiple threads producing to two topics with race conditions.
Changes:
Reasons: