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