billowqiu commented on a change in pull request #712:
URL: https://github.com/apache/pulsar-client-go/pull/712#discussion_r787331302
##########
File path: pulsar/producer_partition.go
##########
@@ -709,35 +709,40 @@ func (p *partitionProducer) internalFlush(fr
*flushRequest) {
// The last item in the queue has been completed while we were
// looking at it. It's safe at this point to assume that every
// message enqueued before Flush() was called are now persisted
- fr.waitGroup.Done()
+ close(fr.doneCh)
return
}
sendReq := &sendRequest{
msg: nil,
callback: func(id MessageID, message *ProducerMessage, e error)
{
fr.err = e
- fr.waitGroup.Done()
+ close(fr.doneCh)
},
}
pi.sendRequests = append(pi.sendRequests, sendReq)
}
func (p *partitionProducer) Send(ctx context.Context, msg *ProducerMessage)
(MessageID, error) {
- wg := sync.WaitGroup{}
- wg.Add(1)
-
var err error
var msgID MessageID
+ // use atomic bool to avoid race
+ isDone := uAtomic.NewBool(false)
Review comment:
this callback is still callback more than once, isDone is only check
callback is called.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]