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

Deduplicate topic declaration before trying to create them #383

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

Conversation

kYann
Copy link
Contributor

@kYann kYann commented Mar 16, 2023

Description

Deduplicate topic list before sending it to AdminClient. Handle case where client call multiple CreateTopicIfNotExists with same topic name.

Fixes #382

How Has This Been Tested?

Tested on our solution

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have made corresponding changes to the documentation

Disclaimer

By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our Contributor Ownership Statement

public bool Equals(TopicConfiguration x, TopicConfiguration y) => x?.Name == y?.Name;

public int GetHashCode(TopicConfiguration obj) => obj.Name.GetHashCode();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe throwing an exception should be better. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's whats happening now. The issue with the exception is that it means that we must only call createtopics one time per topic.
In our case for a topic we have many handler and by default we call create topic. The registration happen in the bounded context of the handler and is then use in the app. Each bounded context are not aware of how the registration has been made for other bounded context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since KafkaFlow doesn't throw an exception if it already exists, I think it makes sense not to throw it in case of duplicated configuration. I believe that as a consumer, I would expect the first attempt to succeed and the second to be ignored.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @kYann
We discussed this issue and @filipeesch raised a scenario that we are concerned with.
If eventually, we have a duplicate topic declaration with different parameters (number of partitions and replicas), a silent deduplication process may induce confusion.
So, we believe that at least we should log a warning mentioning the duplication and that we are deduplicating and using the settings X and Y to try to create the topic.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I think the warning is a good idea. There is no other way to resolve this.
If the warning could happen only when the parameters are different would be a nice touch.

@gsferreira gsferreira self-requested a review May 17, 2023 13:14
public bool Equals(TopicConfiguration x, TopicConfiguration y) => x?.Name == y?.Name;

public int GetHashCode(TopicConfiguration obj) => obj.Name.GetHashCode();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @kYann
We discussed this issue and @filipeesch raised a scenario that we are concerned with.
If eventually, we have a duplicate topic declaration with different parameters (number of partitions and replicas), a silent deduplication process may induce confusion.
So, we believe that at least we should log a warning mentioning the duplication and that we are deduplicating and using the settings X and Y to try to create the topic.

What do you think?

@kYann
Copy link
Contributor Author

kYann commented Jul 9, 2023

Sorry I thought I answered but did not. Yes I agree with your solution.

@gsferreira
Copy link
Contributor

Sorry I thought I answered but did not. Yes I agree with your solution.

@kYann are you available to review the PR applying that?

@kYann
Copy link
Contributor Author

kYann commented Jul 24, 2023

Yes !

@Fram90
Copy link

Fram90 commented Oct 21, 2024

Hello, any updates on this? Seems like everything is ready, only conflicting megre is left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report]: When declaring many producer with same topic name, creation fail
4 participants