gaurav-narula commented on code in PR #23258:
URL: https://github.com/apache/kafka/pull/23258#discussion_r3846941398
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/AbstractIndex.java:
##########
@@ -216,6 +225,9 @@ public boolean resize(int newSize) throws IOException {
mmap =
raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, roundedNewSize);
this.maxEntries = mmap.limit() / entrySize();
mmap.position(position);
+ if (sync) {
+ raf.getChannel().force(true);
Review Comment:
Looking at the javadoc for FileChannel#force
> This method is only guaranteed to force changes that were made to this
channel's file via the methods defined in this class, or the methods defined by
java.io.FileOutputStream or java.io.RandomAccessFile when the channel was
obtained with the getChannel method. It may or may not force changes that were
made by modifying the content of a mapped byte buffer obtained by invoking the
map method. Invoking the force method of the mapped byte buffer will force
changes made to the buffer's content to be written.
I think if the intention is to sync both the existing data and the file
metadata we should invoke `mmap.force()` just before `safeForceUnmap()` in
addition to this
--
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]