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

data race #97

Open
gerdstolpmann opened this issue Sep 25, 2020 · 3 comments
Open

data race #97

gerdstolpmann opened this issue Sep 25, 2020 · 3 comments

Comments

@gerdstolpmann
Copy link
Contributor

We are seeing this:

WARNING: DATA RACE
Write at 0x00c0008ca0b0 by goroutine 271:
  github.com/fhmq/hmq/broker.(*client).Close()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:611 +0xb2
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:194 +0x411
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:55 +0x31

Previous read at 0x00c0008ca0b0 by goroutine 160:
  github.com/fhmq/hmq/broker.(*client).WriterPacket()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:662 +0x45
  github.com/fhmq/hmq/broker.publish()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/comm.go:151 +0x84
  github.com/fhmq/hmq/broker.(*client).ProcessPublishMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:326 +0x791
  github.com/fhmq/hmq/broker.(*client).processClientPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:271 +0xbfd
  github.com/fhmq/hmq/broker.(*client).ProcessPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:203 +0xa4
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:177 +0x444
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:55 +0x31

Goroutine 271 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:46 +0x4c

Goroutine 160 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:46 +0x4c

Data race means that some locking is missing. I briefly scanned the code, and I'm wondering whether the Client should be locked for the duration of ProcessMessage (there is a mutex mu but it seems to be unused).

@lucasvmx
Copy link
Contributor

We are seeing this:

WARNING: DATA RACE
Write at 0x00c0008ca0b0 by goroutine 271:
  github.com/fhmq/hmq/broker.(*client).Close()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:611 +0xb2
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:194 +0x411
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:55 +0x31

Previous read at 0x00c0008ca0b0 by goroutine 160:
  github.com/fhmq/hmq/broker.(*client).WriterPacket()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:662 +0x45
  github.com/fhmq/hmq/broker.publish()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/comm.go:151 +0x84
  github.com/fhmq/hmq/broker.(*client).ProcessPublishMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:326 +0x791
  github.com/fhmq/hmq/broker.(*client).processClientPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:271 +0xbfd
  github.com/fhmq/hmq/broker.(*client).ProcessPublish()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:203 +0xa4
  github.com/fhmq/hmq/broker.ProcessMessage()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/client.go:177 +0x444
  github.com/fhmq/hmq/broker.(*Broker).SubmitWork.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/broker/broker.go:110 +0x44
  github.com/fhmq/hmq/pool.startWorker.func1()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:55 +0x31

Goroutine 271 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:46 +0x4c

Goroutine 160 (running) created at:
  github.com/fhmq/hmq/pool.startWorker()
      /home/circleci/project/pkg/mod/github.com/fhmq/hmq@v0.0.0-20200416060851-3cf90d5231d2/pool/fixpool.go:46 +0x4c

Data race means that some locking is missing. I briefly scanned the code, and I'm wondering whether the Client should be locked for the duration of ProcessMessage (there is a mutex mu but it seems to be unused).

can you explain how to reproduce this issue?

@lucasvmx
Copy link
Contributor

Reported with more details on #153

@lucasvmx
Copy link
Contributor

this issue can be closed. It's fixed

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

No branches or pull requests

2 participants