PavelZeger commented on code in PR #1490:
URL: https://github.com/apache/pulsar-client-go/pull/1490#discussion_r3212833335


##########
pulsar/consumer_partition.go:
##########
@@ -2100,6 +2102,12 @@ func (pc *partitionConsumer) 
reconnectToBroker(connectionClosed *connectionClose
                pc.metrics.ConsumersReconnectFailure.Inc()
                if maxRetry == 0 || bo.IsMaxBackoffReached() {
                        pc.metrics.ConsumersReconnectMaxRetry.Inc()
+                       if pc.options.maxReconnectToBrokerListener != nil {
+                               
pc.options.maxReconnectToBrokerListener(pc.parentConsumer, err)
+                       }

Review Comment:
   I confirmed the bug. With `MaxReconnectToBroker` unset, 
`bo.IsMaxBackoffReached()` stays true and the branch returns err, so the retry 
loop  re-enters indefinitely — listener fires every iteration, close goroutines 
pile up.                                                  
                                                                                
                                                         
   Didn't take the "make it terminal" option: it would silently change the 
default contract of retrying forever at the backoff ceiling.
   
   Fix: closure-local `maxRetryNotified bool` gating only the listener and 
close goroutine; retry flow and metric untouched. Plain bool  is fine since 
`opFn` runs sequentially.                                                       
                                      
                                                                                
                                                         
   Added `TestConsumerMaxReconnectToBrokerListenerFiresOnceWhenBackoffMaxed: 
MaxReconnectToBroker` unset + always-maxed backoff, kills  broker, waits 3 s 
past first invocation, asserts counter == 1. Passes.
                                                                   



-- 
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]

Reply via email to