dragosvictor commented on code in PR #1208: URL: https://github.com/apache/pulsar-client-go/pull/1208#discussion_r1576507047
########## pulsar/producer_partition.go: ########## @@ -429,12 +453,22 @@ func (p *partitionProducer) reconnectToBroker() { return } - if p.options.BackoffPolicy == nil { + var assignedBrokerURL string + + if connectionClosed != nil && connectionClosed.HasURL() { + delayReconnectTime = 0 + assignedBrokerURL = connectionClosed.assignedBrokerURL + connectionClosed = nil // Only attempt once Review Comment: There is a for loop wrapping around the reconnection attempts: ```go for maxRetry != 0 { if p.getProducerState() != producerReady { // Producer is already closing p.log.Info("producer state not ready, exit reconnect") return } var assignedBrokerURL string if connectionClosed != nil && connectionClosed.HasURL() { delayReconnectTime = 0 assignedBrokerURL = connectionClosed.assignedBrokerURL connectionClosed = nil // Only attempt once } else if p.options.BackoffPolicy == nil { delayReconnectTime = defaultBackoff.Next() } else { delayReconnectTime = p.options.BackoffPolicy.Next() } ... ``` Setting the variable to nil guarantees we will only attempt connection to the assigned broker once. If that fails, for whatever reason, we revert back to performing topic lookups in order to locate the broker serving the topic. -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org