zhaomin1423 commented on code in PR #43502:
URL: https://github.com/apache/spark/pull/43502#discussion_r1398084223


##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/LevelDBIterator.java:
##########
@@ -280,4 +302,43 @@ static int compare(byte[] a, byte[] b) {
     return a.length - b.length;
   }
 
+  static class ResourceCleaner implements Runnable {
+
+    private final DBIterator dbIterator;
+
+    private final LevelDB levelDB;
+
+    private final AtomicBoolean started = new AtomicBoolean(true);
+
+    ResourceCleaner(DBIterator dbIterator, LevelDB levelDB) {
+      this.dbIterator = dbIterator;
+      this.levelDB = levelDB;
+    }
+
+    @Override
+    public void run() {
+      if (started.compareAndSet(true, false)) {
+        levelDB.notifyIteratorClosed(dbIterator);
+        synchronized (levelDB.getLevelDB()) {
+          DB _db = levelDB.getLevelDB().get();
+          if (_db != null) {
+            try {
+              dbIterator.close();
+            } catch (IOException e) {
+              throw new UncheckedIOException(e);

Review Comment:
   Good suggestion, I re-examined it,the JniDBIterator  can't throw an 
IOException, could we just ignore it?
   
   <img width="632" alt="image" 
src="https://github.com/apache/spark/assets/49054376/4c5c9e6c-4c06-4175-9a1f-e12577a6f86a";>
   
   



##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/LevelDBIterator.java:
##########
@@ -280,4 +302,43 @@ static int compare(byte[] a, byte[] b) {
     return a.length - b.length;
   }
 
+  static class ResourceCleaner implements Runnable {
+
+    private final DBIterator dbIterator;
+
+    private final LevelDB levelDB;
+
+    private final AtomicBoolean started = new AtomicBoolean(true);
+
+    ResourceCleaner(DBIterator dbIterator, LevelDB levelDB) {
+      this.dbIterator = dbIterator;
+      this.levelDB = levelDB;
+    }
+
+    @Override
+    public void run() {
+      if (started.compareAndSet(true, false)) {
+        levelDB.notifyIteratorClosed(dbIterator);
+        synchronized (levelDB.getLevelDB()) {
+          DB _db = levelDB.getLevelDB().get();
+          if (_db != null) {
+            try {
+              dbIterator.close();
+            } catch (IOException e) {
+              throw new UncheckedIOException(e);

Review Comment:
   Good suggestion, I re-examined it,the JniDBIterator  can't throw an 
IOException, could we just ignore it?
   
   <img width="632" alt="image" 
src="https://github.com/apache/spark/assets/49054376/4c5c9e6c-4c06-4175-9a1f-e12577a6f86a";>
   
   



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

To unsubscribe, e-mail: [email protected]

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