CalvinConfluent commented on code in PR #18277:
URL: https://github.com/apache/kafka/pull/18277#discussion_r1936517489


##########
metadata/src/main/java/org/apache/kafka/controller/ClusterControlManager.java:
##########
@@ -432,23 +443,29 @@ public ControllerResult<BrokerRegistrationReply> 
registerBroker(
                         "epoch is {}.", brokerId, request.incarnationId(), 
numRecordsAdded, newBrokerEpoch);
             } else {
                 log.info("Registering a new incarnation of broker {}. Previous 
incarnation ID " +
-                        "was {}; new incarnation ID is {}. Generated {} 
record(s) to clean up " +
+                        "was {}; new incarnation ID is {}. {}Generated {} 
record(s) to clean up " +
                         "previous incarnations. Broker epoch will become {}.", 
brokerId,
-                        existing.incarnationId(), request.incarnationId(), 
numRecordsAdded,
+                        existing.incarnationId(), request.incarnationId(),
+                        uncleanShutdownDetectionEnabled ?
+                            "Using unclean shutdown detection. Stored broker 
epoch=" + storedBrokerEpoch +
+                                " vs request broker epoch=" + 
request.previousBrokerEpoch() + ". "
+                            : "",
+                        numRecordsAdded,
                         newBrokerEpoch);
             }
             record.setBrokerEpoch(newBrokerEpoch);
         } else {
             log.info("Amending registration of broker {}, incarnation ID {}. 
Broker epoch remains {}.",
                     request.brokerId(), request.incarnationId(), 
existing.epoch());
             record.setFenced(existing.fenced());
-            record.setInControlledShutdown(existing.inControlledShutdown());
+            record.setInControlledShutdown(isBrokerStartUp ? false : 
existing.inControlledShutdown());
             record.setBrokerEpoch(existing.epoch());
+            record.setIncarnationId(request.incarnationId());
         }
         records.add(new ApiMessageAndVersion(record, 
featureControl.metadataVersion().
             registerBrokerRecordVersion()));
 
-        if (!request.incarnationId().equals(prevIncarnationId)) {
+        if (isUncleanShutdownRegistration) {

Review Comment:
   Refactored the code.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to