kevin-wu24 commented on code in PR #20707:
URL: https://github.com/apache/kafka/pull/20707#discussion_r2487783869


##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -1022,7 +1021,22 @@ public void 
handleLoadSnapshot(SnapshotReader<ApiMessageAndVersion> reader) {
                         Batch<ApiMessageAndVersion> batch = reader.next();
                         long offset = batch.lastOffset();
                         List<ApiMessageAndVersion> messages = batch.records();
-
+                        if (bootstrapMetadata == null) {
+                            if 
(reader.snapshotId().equals(Snapshots.BOOTSTRAP_SNAPSHOT_ID)) {
+                                // For bootstrap snapshots, extract feature 
levels from all data records
+                                if (batch.controlRecords().isEmpty()) {
+                                    System.out.println("DEBUG: Extracting 
bootstrap metadata from " + messages.size() + " records");
+                                    bootstrapMetadata = 
BootstrapMetadata.fromRecords(messages, "bootstrap");
+                                    System.out.println("DEBUG: Bootstrap 
metadata extracted: " + bootstrapMetadata);
+                                }

Review Comment:
   This is the wrong if condition. We should check `!batch.records.isEmpty`. 
   
   If the 0-0.checkpoint does not have metadata records, AND `bootstrapMetadata 
== null` at this point, we should throw an `IllegalStateException`, because we 
cannot construct `bootstrapMetadata`.



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