You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2018/10/11 00:23:50 UTC
[kafka] branch 2.1 updated: MINOR: AbstractIndex.close should unmap
(#5757)
This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/2.1 by this push:
new 09007db MINOR: AbstractIndex.close should unmap (#5757)
09007db is described below
commit 09007db677ddd79b1677e13a269d0791de85b146
Author: Ismael Juma <is...@juma.me.uk>
AuthorDate: Wed Oct 10 17:22:28 2018 -0700
MINOR: AbstractIndex.close should unmap (#5757)
Reviewers: Dong Lin <li...@gmail.com>, Jun Rao <ju...@gmail.com>
---
core/src/main/scala/kafka/log/AbstractIndex.scala | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/core/src/main/scala/kafka/log/AbstractIndex.scala b/core/src/main/scala/kafka/log/AbstractIndex.scala
index ec9d55f..bf5cc25 100644
--- a/core/src/main/scala/kafka/log/AbstractIndex.scala
+++ b/core/src/main/scala/kafka/log/AbstractIndex.scala
@@ -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)
}
@@ -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()
}