cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to stop SparkSession within notebook without errr

gkrilis
New Contributor

I want to run an ETL job and when the job ends I would like to stop SparkSession to free my cluster's resources, by doing this I could avoid restarting the cluster, but when calling

 

spark.stop()

 

the job returns with status failed even though it has finished successfully, since the notebook automatically detach and the following error occurs:

The spark context has stopped and the driver is restarting. Your notebook will be automatically reattached. 

I have read in this community's post that stopping the spark session is not recommended, but I do not understand the reason behind this. As far as I know, it is recommended to end the spark session after finishing the job in order the JVMs to close and free the resources. 

Is there a recommended way to stop/restart SparkSession in a databricks job?

1 REPLY 1

PremadasV
New Contributor II

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group