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

Issue with Topic Creation Using ReplicaAssignments in xk6-kafka #310

Open
vereshchagin-d opened this issue Nov 22, 2024 · 3 comments
Open
Assignees
Labels
🐛 Bug Something isn't working

Comments

@vereshchagin-d
Copy link

Hi!

Environment:

  • Kafka 3.7.0 running in Kubernetes
  • Docker image: mostafamoradian/xk6-kafka:0.28.0

Description:
I'm encountering an issue when trying to create a topic with replicaAssignments. Below is the code snippet used:

connection.createTopic({
  topic: "my-topic", 
  numPartitions: -1, // Also tried declaring only `topic` and `replicaAssignments`
  replicationFactor: -1, //
  replicaAssignments: [{partition: 0, replicas: [0,1,2]}]
});

The error message I receive is:

time="2024-11-22T11:23:47Z" level=error msg="Failed to create topic., OriginalError: [42] Invalid Request: this most likely occurs because of a request being malformed by the client library or the message was sent to an incompatible broker, se the broker logs for more details" error="Failed to create topic., OriginalError: [42] Invalid Request: this most likely occurs because of a request being malformed by the client library or the message was sent to an incompatible broker, se the broker logs for more details"

Observations:
Upon checking the code, I noticed that in this section of the source code, default values for NumPartitions and ReplicationFactor are set to 1 if they are <= 0.

        if topicConfig.NumPartitions <= 0 {
		topicConfig.NumPartitions = 1
	}

	if topicConfig.ReplicationFactor <= 0 {
		topicConfig.ReplicationFactor = 1
	}

This behavior seems incorrect when using replicaAssignments since NumPartitions and ReplicationFactor should be inferred from the replicaAssignments field according to the Kafka protocol.

References:

Suggested Fix:
The library should allow NumPartitions and ReplicationFactor to remain unset or explicitly -1 when replicaAssignments is provided. This would align the behavior with Kafka’s protocol and similar libraries.

@vereshchagin-d
Copy link
Author

Hi @mostafa,

Thank you for your work on the xk6-kafka project—it’s been incredibly useful for our Kafka-related testing needs.

I’ve encountered an issue when trying to create a topic with replicaAssignments and have provided a detailed report [above/in this issue]. It seems like the library sets default values for NumPartitions and ReplicationFactor even when replicaAssignments is provided, which contradicts Kafka’s protocol.

Would you be able to take a look when you have time? I’ve included links to relevant Kafka documentation and test cases from kafka-go library to help clarify the context.

Let me know if there’s any additional information I can provide or steps I can take to assist. Thanks again for maintaining this project!

Best regards,
Dmitriy

@mostafa
Copy link
Owner

mostafa commented Nov 22, 2024

Hey @vereshchagin-d,

Looks like a bug. Would you please create a PR to fix this?

@mostafa mostafa added the 🐛 Bug Something isn't working label Nov 22, 2024
@vereshchagin-d
Copy link
Author

Hey @mostafa,

I'm currently swamped with work and won't be able to address this issue in the next few weeks. I'll circle back to it as soon as I have some bandwidth.

Thanks for understanding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants