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

consumer group shutdown: data race #1355

Closed
sitano opened this issue Apr 11, 2019 · 4 comments
Closed

consumer group shutdown: data race #1355

sitano opened this issue Apr 11, 2019 · 4 comments

Comments

@sitano
Copy link

@sitano sitano commented Apr 11, 2019

Versions

Sarama Version: d84c59b2a2d87f185d91a1cc426a1f4d4e9365109fe0d96cbd2404c3a57c365a / release v1.22.0
Kafka Version: kafka_2.12-2.1.0.jar
Go Version: go version go1.12.1 linux/amd64

Configuration

What configuration values are you using for Sarama and Kafka?

Kafka: a single topic with only 1 partition and 2 consumers in a single consumer group

Logs
==================
WARNING: DATA RACE
Read at 0x00c0004d2050 by goroutine 58:
  github.com/Shopify/sarama.(*client).Coordinator()
      github.com/Shopify/sarama/client.go:245 +0x43
  github.com/Shopify/sarama.(*nopCloserClient).Coordinator()
      <autogenerated>:1 +0x7a
  github.com/Shopify/sarama.(*consumerGroupSession).heartbeatLoop()
      github.com/Shopify/sarama/consumer_group.go:662 +0x283

Previous write at 0x00c0004d2050 by goroutine 60:
  github.com/Shopify/sarama.(*client).Close()
      github.com/Shopify/sarama/client.go:237 +0x2ed
  geinternal/session.(*Service).Stop()
      internal/session/grpc.go:88 +0xea
  geinternal/session.(*Service).Stop-fm()
      internal/session/grpc.go:84 +0x41
  grpc.execUserHooks.func1()
      grpc/server_shutdown.go:121 +0x34

Goroutine 58 (running) created at:
  github.com/Shopify/sarama.newConsumerGroupSession()
      github.com/Shopify/sarama/consumer_group.go:505 +0x41a
  github.com/Shopify/sarama.(*consumerGroup).newSession()
      github.com/Shopify/sarama/consumer_group.go:291 +0x8c8
  github.com/Shopify/sarama.(*consumerGroup).Consume()
      github.com/Shopify/sarama/consumer_group.go:167 +0x2cd
  geinternal/session.(*Service).Start.func1()
      internal/session/grpc.go:66 +0x2c5

Goroutine 60 (running) created at:
  grpc.execUserHooks()
      grpc/server_shutdown.go:120 +0xfc
  grpc.handleSigTerm.func1()
      grpc/server_shutdown.go:86 +0x60
==================
Problem Description

If the client that was used in creating a consumer group will be closed first right before the close of the consumer group itself, this cs close will produce a data race.

@Vesli
Copy link

@Vesli Vesli commented Apr 11, 2019

I experienced the same, I was wondering if this is something missing from the doc.

@varun06
Copy link
Collaborator

@varun06 varun06 commented Apr 11, 2019

@sitano
Copy link
Author

@sitano sitano commented Apr 11, 2019

No. It works fine if to close the client after the consumer group is closed, but if to try to close the client before the consumer group is closed result in a data race. And it could be that just not to do it as the client is reused, but the thing is that the consumer group can hang on close, and a DR is not a nice thing to have trying to enforce shutdown.

Yet, if it is intended feel free to close.

If the word reuse was meant to be read as to not try to close a client if it is in use by the consumer group then it was not very clearly pointed out.

@probot-shopify
Copy link

@probot-shopify probot-shopify bot commented Feb 21, 2020

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur.
Please check if the master branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

@probot-shopify probot-shopify bot added the stale label Feb 21, 2020
@probot-shopify probot-shopify bot closed this Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.