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-consumer] Use wait group to ensure goroutine is finished before returning from Close #4582

Merged
merged 5 commits into from
Jul 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/ingester/app/consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ func New(params Params) (*Consumer, error) {
// Start begins consuming messages in a go routine
func (c *Consumer) Start() {
c.deadlockDetector.start()
c.doneWg.Add(1)
go func() {
c.logger.Info("Starting main loop")
c.doneWg.Done()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
c.logger.Info("Starting main loop")
c.doneWg.Done()
defer c.doneWg.Done()
c.logger.Info("Starting main loop")

Copy link
Contributor Author

@kennyaz kennyaz Jul 14, 2023

Choose a reason for hiding this comment

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

Doing, that cause test to timeout because this channel is not closed at all for some reason. I investigate it further and it seems like this method is not closing the partition channel properly at least. The test that causes the code to timeout is https://github.com/jaegertracing/jaeger/blob/main/cmd/ingester/app/consumer/consumer_test.go#L122. It seems like the bug is happening on the "github.com/Shopify/sarama/mocks" side.

Copy link
Contributor Author

@kennyaz kennyaz Jul 14, 2023

Choose a reason for hiding this comment

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

I take it back. It is happening on the Jaeger Side. I will submit a correct push shortly.

for pc := range c.internalConsumer.Partitions() {
c.partitionMapLock.Lock()
c.partitionIDToState[pc.Partition()] = &consumerState{partitionConsumer: pc}
Expand Down