jsancio commented on code in PR #16862:
URL: https://github.com/apache/kafka/pull/16862#discussion_r1715970892


##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -817,27 +817,25 @@ public void run() throws Exception {
                         // succeed; if it does not, that's a fatal error. It 
is important to do this before
                         // scheduling the record for Raft replication.
                         int recordIndex = 0;
-                        long nextWriteOffset = offsetControl.nextWriteOffset();
+                        long lastOffset = 
raftClient.scheduleAppend(controllerEpoch, records);
+                        long baseOffset = lastOffset - records.size() + 1;
                         for (ApiMessageAndVersion message : records) {
-                            long recordOffset = nextWriteOffset + recordIndex;
+                            long recordOffset = baseOffset + recordIndex;
                             try {
                                 replay(message.message(), Optional.empty(), 
recordOffset);
                             } catch (Throwable e) {
                                 String failureMessage = String.format("Unable 
to apply %s " +
                                     "record at offset %d on active controller, 
from the " +
                                     "batch with baseOffset %d",
                                     
message.message().getClass().getSimpleName(),
-                                    recordOffset, nextWriteOffset);
+                                    recordOffset, baseOffset);
                                 throw 
fatalFaultHandler.handleFault(failureMessage, e);
                             }
                             recordIndex++;
                         }
-                        long nextEndOffset = nextWriteOffset - 1 + recordIndex;
-                        raftClient.scheduleAtomicAppend(controllerEpoch,
-                            OptionalLong.of(nextWriteOffset),
-                            records);
-                        
offsetControl.handleScheduleAtomicAppend(nextEndOffset);
-                        return nextEndOffset;
+                        raftClient.scheduleFlush();

Review Comment:
   Not possible. Flush it no accurate. I changed the name from `scheduleFlush` 
to `schedulePreparedAppend`.
   
   `prepareAppend` accumulates batches in-memory and will never send them to 
the log layer until `schedulePreparedAppend` is called.



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