adjust / rmq

Message queue system written in Go and backed by Redis
MIT License
1.57k stars 206 forks source link

Data race #48

Closed xeoncross closed 6 years ago

xeoncross commented 6 years ago

I am trying to figure out what I'm doing wrong in causing a data race with redisQueue.StopConsuming()

WARNING: DATA RACE
Write at 0x00c4201960a8 by goroutine 104:
  github.com/adjust/rmq.(*redisQueue).StopConsuming()
      /Users/owner/go/src/github.com/adjust/rmq/queue.go:222 +0x9b
  main.main.func2()

Previous read at 0x00c4201960a8 by goroutine 19:
  github.com/adjust/rmq.(*redisQueue).consume()
      /Users/owner/go/src/github.com/adjust/rmq/queue.go:290 +0x68

Goroutine 104 (running) created at:
  main.main()

Goroutine 19 (running) created at:
  github.com/adjust/rmq.(*redisQueue).StartConsuming()
      /Users/owner/go/src/github.com/adjust/rmq/queue.go:213 +0x18b
  main.main()

Code:

    connection := rmq.OpenConnection("email queue", "tcp", Address, 1)
    emailQueue := connection.OpenQueue("emails")
    emailQueue.StartConsuming(100, time.Microsecond)

    consumer := &queue.EmailConsumer{}
    emailQueue.AddConsumer("consumer", consumer)

    emailQueue.StopConsuming()
wellle commented 6 years ago

As mentioned in https://github.com/adjust/rmq/issues/47 this function is currently not meant to be used. Lets keep the discussion there, closing this one.