MonkeyCanCode commented on code in PR #59952:
URL: https://github.com/apache/spark/pull/59952#discussion_r4434528053
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogManager.scala:
##########
@@ -526,6 +551,34 @@ private[sql] class DefaultCatalogManager(
}
v1SessionCatalog.setCurrentDatabase(conf.defaultDatabase)
}
+
+ // Unregister every catalog loaded by this manager, and close the ones that
are `AutoCloseable`.
+ // `defaultSessionCatalog` is not closed since it is owned by the caller,
not by this manager.
+ // Closing is terminal: loading a catalog afterwards fails instead of
creating an instance
+ // that would never be closed.
+ //
+ // SPARK-56939: catalog implementations are closed outside of the manager
lock so that a
+ // catalog calling back into the manager while closing cannot deadlock.
+ override private[sql] def close(): Unit = {
+ val loaded = synchronized {
+ closed = true
+ val entries = catalogs.toSeq
+ catalogs.clear()
+ entries
+ }
+ loaded.foreach {
+ case (name, closeable: AutoCloseable) =>
+ try {
+ closeable.close()
+ } catch {
+ // A catalog loaded by a session classloader can fail with a
`LinkageError` while
+ // closing. It must not prevent the other catalogs from being closed.
+ case e @ (NonFatal(_) | _: LinkageError) =>
Review Comment:
Fixed.
--
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]