Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/src/main/scala/kafka/log/AbstractIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ abstract class AbstractIndex[K, V](@volatile var file: File, val baseOffset: Lon
try {
val position = mmap.position()

/* Windows won't let us modify the file length while the file is mmapped :-( */
if (OperatingSystem.IS_WINDOWS)
safeForceUnmap()
// Necessary on Windows, file length cannot be modified without unmapping
// Also, generally a good practice to eagerly unmap rather than leave it to GC (KAFKA-4614)
safeForceUnmap()

raf.setLength(roundedNewSize)
_length = roundedNewSize
mmap = raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, roundedNewSize)
Expand Down