Skip to content
Merged
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
13 changes: 6 additions & 7 deletions core/src/main/scala/kafka/log/AbstractIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,7 @@ abstract class AbstractIndex[K, V](@volatile var file: File, val baseOffset: Lon
* not exist
*/
def deleteIfExists(): Boolean = {
inLock(lock) {
// On JVM, a memory mapping is typically unmapped by garbage collector.
// However, in some cases it can pause application threads(STW) for a long moment reading metadata from a physical disk.
// To prevent this, we forcefully cleanup memory mapping within proper execution which never affects API responsiveness.
// See https://issues.apache.org/jira/browse/KAFKA-4614 for the details.
safeForceUnmap()
}
closeHandler()
Files.deleteIfExists(file.toPath)
}

Expand All @@ -251,9 +245,14 @@ abstract class AbstractIndex[K, V](@volatile var file: File, val baseOffset: Lon
/** Close the index */
def close() {
trimToValidSize()
closeHandler()
}

def closeHandler(): Unit = {
// On JVM, a memory mapping is typically unmapped by garbage collector.
// However, in some cases it can pause application threads(STW) for a long moment reading metadata from a physical disk.
// To prevent this, we forcefully cleanup memory mapping within proper execution which never affects API responsiveness.
// See https://issues.apache.org/jira/browse/KAFKA-4614 for the details.
inLock(lock) {
safeForceUnmap()
}
Expand Down