apache / apache/rocketmq-client-go
Close the channel before sending data if the consumer has been shutdown.
Open
bug
- Dominant language
- Go
- Stars
- 1.4k
- Forks
- 445
- PR merge metrics
- No merged PRs in 30d
Description
### # The Question
For the consumer, the closing and writing of msgCh are in two coroutines. Even though the chan of `closeChan` is added, since `case` clauses will be randomly executed for the `select` statement, it is still possible Write data to a closed channel
```go
if !pq.order {
select {
case <-pq.closeChan:
return
case pq.msgCh <- messages:
}
}
```
https://github.com/apache/rocketmq-client-go/blob/master/consumer/process_queue.go#LL124C1-L130C3
### # How fo fix?
We'd better close the channel in the goroutine that pullMessage to avoid closing and writing at the same time.
Contributor guide
Assessment
This issue has not been assessed yet.