SauronShepherd opened a new pull request, #50014: URL: https://github.com/apache/spark/pull/50014
### What changes were proposed in this pull request? Close connection before `saveTable` calls in `org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider`. Check if the connection has been already closed before the last `close` in the `finally` block. ### Why are the changes needed? A JDBC connection was created in the `JdbcRelationProvider` class to truncate, drop, or create the table. However, this connection remained open and idle throughout the entire save process, which could take some time. This caused unnecessary resource consumption on both the Spark driver and the database. Additionally, the idle connection was at risk of being dropped by the database, firewall, or proxy. Best practices recommend releasing resources as soon as they are no longer needed. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Local tests + Spark unit tests ### Was this patch authored or co-authored using generative AI tooling? No -- 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