Skip to content

Commit

Permalink
[Fix][producer] Ensure all data in dataChan will be processed when in…
Browse files Browse the repository at this point in the history
…ternalClose() was called
  • Loading branch information
graysonzeng committed Jul 20, 2023
1 parent 9867c29 commit eda691e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pulsar/producer_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,16 @@ func (p *partitionProducer) internalClose(req *closeProducer) {
return
}

defer close(p.dataChan)
defer close(p.cmdChan)
p.log.Info("Closing producer")
flushReq := &flushRequest{
doneCh: make(chan struct{}),
err: nil,
}
p.internalFlush(flushReq)
// wait for the flush request to complete
<-flushReq.doneCh

id := p.client.rpcClient.NewRequestID()
_, err := p.client.rpcClient.RequestOnCnx(p._getConn(), id, pb.BaseCommand_CLOSE_PRODUCER, &pb.CommandCloseProducer{
Expand Down

0 comments on commit eda691e

Please sign in to comment.