You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by li...@apache.org on 2018/10/21 19:09:39 UTC

[kafka] branch 2.1 updated: Revert 09007db677ddd79b1677e13a269d0791de85b146 MINOR: AbstractIndex.close should unmap (#5757)

This is an automated email from the ASF dual-hosted git repository.

lindong 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 31758ae  Revert 09007db677ddd79b1677e13a269d0791de85b146 MINOR: AbstractIndex.close should unmap (#5757)
31758ae is described below

commit 31758aef580e7408004d83ccefc81cf253522a16
Author: Dong Lin <li...@gmail.com>
AuthorDate: Sun Oct 21 12:07:07 2018 -0700

    Revert 09007db677ddd79b1677e13a269d0791de85b146 MINOR: AbstractIndex.close should unmap (#5757)
    
    This is based on discussion in #5778
---
 core/src/main/scala/kafka/log/AbstractIndex.scala | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/core/src/main/scala/kafka/log/AbstractIndex.scala b/core/src/main/scala/kafka/log/AbstractIndex.scala
index bf5cc25..ec9d55f 100644
--- a/core/src/main/scala/kafka/log/AbstractIndex.scala
+++ b/core/src/main/scala/kafka/log/AbstractIndex.scala
@@ -223,7 +223,13 @@ abstract class AbstractIndex[K, V](@volatile var file: File, val baseOffset: Lon
    *         not exist
    */
   def deleteIfExists(): Boolean = {
-    closeHandler()
+    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()
+    }
     Files.deleteIfExists(file.toPath)
   }
 
@@ -245,14 +251,9 @@ 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()
     }