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


##########
common/kvstore/src/main/java/org/apache/spark/util/kvstore/RocksDBIterator.java:
##########
@@ -270,20 +280,30 @@ static int compare(byte[] a, byte[] b) {
     return a.length - b.length;
   }
 
-  private record ResourceCleaner(RocksIterator rocksIterator, RocksDB rocksDB) 
implements Runnable {
+  private static class ResourceCleaner implements Runnable {
+
+    private final RocksIterator rocksIterator;
+    private final RocksDB rocksDB;
+    private final AtomicBoolean status = new AtomicBoolean(true);
+
+    public ResourceCleaner(RocksIterator rocksIterator, RocksDB rocksDB) {
+      this.rocksIterator = rocksIterator;
+      this.rocksDB = rocksDB;
+    }
 
     @Override
     public void run() {
-      rocksDB.getIteratorTracker().removeIf(ref -> {
-        RocksDBIterator<?> rocksDBIterator = ref.get();
-        return rocksDBIterator != null && 
rocksIterator.equals(rocksDBIterator.it);
-      });
-      synchronized (rocksDB.getRocksDB()) {
-        org.rocksdb.RocksDB _db = rocksDB.getRocksDB().get();
-        if (_db != null) {
-          rocksIterator.close();
-        }
+      if (status.compareAndSet(true, false)) {
+        rocksDB.getIteratorTracker().removeIf(ref -> {

Review Comment:
   Is it possible to reuse the `db.notifyIteratorClosed`?
   



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to