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


##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/LevelDBIterator.java:
##########
@@ -280,4 +285,23 @@ static int compare(byte[] a, byte[] b) {
     return a.length - b.length;
   }
 
+  private record ResourceCleaner(DBIterator dbIterator, LevelDB levelDB) 
implements Runnable {
+    @Override
+    public void run() {
+      levelDB.getIteratorTracker().removeIf(ref -> {
+        LevelDBIterator<?> levelDBIterator = ref.get();
+        return levelDBIterator != null && 
dbIterator.equals(levelDBIterator.it);

Review Comment:
   When is `levelDBIterator` going to be `null` ?
   Also, instead of `equals` here shouldnt it not be instance check (`==`) ?
   
   +CC @LuciferYang, looks like there is a leak in the DB, iterator's weak ref 
is never cleaned up from the tracker ?
   



##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/LevelDBIterator.java:
##########
@@ -182,23 +189,21 @@ public boolean skip(long n) {
 
   @Override
   public synchronized void close() throws IOException {
-    db.notifyIteratorClosed(this);
     if (!closed) {
-      it.close();
-      closed = true;
-      next = null;
+      try {
+        cleanable.clean();

Review Comment:
   This is changing the locking semantics. Is this intentional ?



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