Skip to content

Commit

Permalink
fix: double check before producer reconnect (#1131)
Browse files Browse the repository at this point in the history
Co-authored-by: gunli <[email protected]>
  • Loading branch information
gunli and gunli authored Nov 15, 2023
1 parent c91a800 commit ef0ba67
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pulsar/producer_partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,14 @@ func (p *partitionProducer) reconnectToBroker() {
}
p.log.Info("Reconnecting to broker in ", delayReconnectTime)
time.Sleep(delayReconnectTime)

// double check
if p.getProducerState() != producerReady {
// Producer is already closing
p.log.Info("producer state not ready, exit reconnect")
return
}

atomic.AddUint64(&p.epoch, 1)
err := p.grabCnx()
if err == nil {
Expand Down

0 comments on commit ef0ba67

Please sign in to comment.