Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-51264][SQL][JDBC] JDBC write keeps driver connection open unnecessarily #50014

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SauronShepherd
Copy link

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

@github-actions github-actions bot added the SQL label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant