xuechendi commented on a change in pull request #32534:
URL: https://github.com/apache/spark/pull/32534#discussion_r636202533



##########
File path: core/src/main/scala/org/apache/spark/storage/memory/MemoryStore.scala
##########
@@ -385,9 +390,33 @@ private[spark] class MemoryStore(
     }
   }
 
+  def manual_close[T <: MemoryEntry[_]](entry: T): T = {
+    val entryManualCloseTasks = Future {
+      entry match {
+        case e: DeserializedMemoryEntry[_] => e.value.foreach {
+          case o: AutoCloseable =>
+            try {
+              o.close
+            } catch {
+              case NonFatal(e) =>
+                logWarning(s"Got NonFatal exception during remove")
+            }
+          case _ =>
+        }
+        case _ =>
+      }
+    }
+    entryManualCloseTasks.onComplete {

Review comment:
       @srowen , to make sure, I tested to throw one NonFatal and one Fatal 
errors in close function, and the behavior is as expected. 
   ```
   case class NativeObject(alloc: DummyAllocator, size: Int)
         extends KnownSizeEstimation
         with AutoCloseable {
   
         alloc.alloc(size)
         var allocated_size: Int = size
         override def estimatedSize: Long = allocated_size
         override def close(): Unit = synchronized {
           Thread.sleep(10)
           alloc.release(allocated_size)
           allocated_size = 0
           throw new NotImplementedError()
           // throw new OutOfMemoryError()
         }
       }
   ```
   
![image](https://user-images.githubusercontent.com/4355494/119004235-f4fcce00-b9c0-11eb-9fbb-b6804efe6bd8.png)
   
   
![image](https://user-images.githubusercontent.com/4355494/119003362-3f317f80-b9c0-11eb-9c24-4c783bff3fe0.png)
   
   and Then I tried to throw OutOfMemoryError as a FatalError, and UT will break
   
![image](https://user-images.githubusercontent.com/4355494/119004160-e57d8500-b9c0-11eb-9a08-bd4a3f2c61a9.png)
   




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to