junrao commented on code in PR #23316:
URL: https://github.com/apache/kafka/pull/23316#discussion_r3919846746
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/AbstractIndex.java:
##########
@@ -252,12 +243,18 @@ public void renameTo(File f) throws IOException {
}
/**
- * Flush the data in the index to disk
+ * Flush the data in the index and its metadata to disk
*/
- public void flush() {
+ public void flush() throws IOException {
inLock(() -> {
if (mmap != null) {
mmap.force();
+ if (dirtyMetadata) {
+ try (FileChannel channel = FileChannel.open(file.toPath(),
StandardOpenOption.WRITE)) {
+ channel.force(true);
+ }
+ dirtyMetadata = false;
Review Comment:
This seems problematic. During a control shutdown, LogManager first calls
flush() on each log segment and then calls close() on each. The flush() call
will clear dirtyMetadata. But close() could add an entry to index and needs to
call flush() again. Since dirtyMetadata is cleared, the second flush() won't
flush the metadata.
--
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]