You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "allisonwang-db (via GitHub)" <gi...@apache.org> on 2023/03/27 07:44:49 UTC

[GitHub] [spark] allisonwang-db commented on a diff in pull request #40557: [SPARK-42928][SQL] Make resolvePersistentFunction synchronized

allisonwang-db commented on code in PR #40557:
URL: https://github.com/apache/spark/pull/40557#discussion_r1148912737


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala:
##########
@@ -1719,7 +1719,8 @@ class SessionCatalog(
       name: FunctionIdentifier,
       arguments: Seq[Expression],
       registry: FunctionRegistryBase[T],
-      createFunctionBuilder: CatalogFunction => FunctionRegistryBase[T]#FunctionBuilder): T = {
+      createFunctionBuilder: CatalogFunction => FunctionRegistryBase[T]#FunctionBuilder
+  ): T = synchronized {

Review Comment:
   Let's say we have two threads. If a persistent function has not been loaded into the function registry, the `if` condition here can return false for both threads.
   ```
   if (registry.functionExists(qualifiedIdent)) {
     // This function has been already loaded into the function registry.
     registry.lookupFunction(qualifiedIdent, arguments)
   } 
   ```
   Then, if one thread successfully registers the persistent function in 
   ```
   registerFunction(
       funcMetadata,
       overrideIfExists = false,
       registry = registry,
       functionBuilder = createFunctionBuilder(funcMetadata))
   ```
   Then another thread can throw exceptions when trying to register this function again, due to `overrideIfExists = false`
   



-- 
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-unsubscribe@spark.apache.org

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


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