cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
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
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.