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

Fix examples initialization after auto creation of topics is disabled #384

Merged

Conversation

norbertklawikowski
Copy link
Contributor

@norbertklawikowski norbertklawikowski commented Jun 8, 2022

Because of the changes in commit 2ff0aea topics will not get automatically created, which breaks examples 2, 3, 5, 6, 7 and 8.

This is fixed in this PR by:

  • creating topics explicitly before execution for application topics
  • synchronize Goroutines so goka-internal topics will be created before they are referred to

Also applied a small fix in README.md of example 3: e31d04d

* ensure topic 'user-click' exists
* view goroutine must wait for the processor to be initialized
* ensure topics exist
* synchronize goroutines to be initialized before running
* still has race conditions in initialization, but after a restart the example works
* added file topic.go
* ensure topic exists
* ensure topic exists
* in runProcessor we use joinGroup, which depends on its initialization in runJoinProcessor
…vent race conditions

TopicManager.EnsureStreamExists is not atomic and therefore can fail if between checking if a topic exists and
creating a new one the topic gets created by another Goroutine.
… in the code but was incorrect in the README
@norbertklawikowski norbertklawikowski marked this pull request as ready for review June 8, 2022 15:43
* Ensuring the existence of topics in the Run functions was not correctly preventing race conditions - only
  making them more unlikely to happen. Introduced a PrepareTopics function in every processor package, where
  topics are created if they do not exist before starting any Goroutine.
* Removed synchronization with WaitGroup, this made the example too complex. With the PrepareTopics functions
  there is no need for this synchronization.
@norbertklawikowski
Copy link
Contributor Author

Fixed and simplified example 3

  • Ensuring the existence of topics in the Run functions was not correctly preventing race conditions - only
    making them more unlikely to happen. Introduced a PrepareTopics function in every processor package, where
    topics are created if they do not exist before starting any Goroutine.
  • Removed synchronization with WaitGroup, this made the example too complex. With the PrepareTopics functions
    there is no need for this synchronization.

@norbertklawikowski norbertklawikowski merged commit 443f482 into lovoo:master Jun 13, 2022
@norbertklawikowski norbertklawikowski deleted the fix-examples-initialization branch June 13, 2022 15:26
frairon added a commit that referenced this pull request Jun 15, 2022
* inherit debug logging to custom loggers, fixes issue #384
* fixed comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants