Caideyipi commented on code in PR #17872:
URL: https://github.com/apache/iotdb/pull/17872#discussion_r4374650694


##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/udf/service/UDFClassLoaderManager.java:
##########
@@ -64,12 +66,24 @@ private UDFClassLoaderManager() throws IOException {
   }
 
   public void initializeUDFQuery(String queryId) {
-    activeClassLoader.get().acquire();
-    queryIdToUDFClassLoaderMap.put(queryId, activeClassLoader.get());
+    final UDFClassLoader previousClassLoader;
+    synchronized (activeClassLoaderLock) {
+      final UDFClassLoader currentClassLoader = activeClassLoader.get();
+      currentClassLoader.acquire();
+      previousClassLoader = queryIdToUDFClassLoaderMap.put(queryId, 
currentClassLoader);
+    }
+    releaseClassLoader(queryId, previousClassLoader);

Review Comment:
   [P1] Give each TransformOperator its own resource registration instead of 
releasing a live registration. A real query such as SELECT top_k(s1, 'k'='2') 
FROM root.review.d ORDER BY s2 creates two TransformOperators in one driver. I 
reproduced an empty query map with activeQueriesCount=1 after it completed on a 
1C1D cluster. Both operators use the same DriverTask ID. If CREATE FUNCTION 
swaps the active loader between their initialization, releasing 
previousClassLoader here can close the deprecated loader while the first 
operator is still executing. Even without a swap, the first close now releases 
the only remaining registration, although the second operator still owns 
resources under the same ID. Include the operator ID in udtfQueryId and test 
independent cleanup instead of overwriting a live entry.



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

Reply via email to