Why does SparkContext randomly close, and how do you restart it from Zeppelin?

The Puma picture The Puma · Feb 19, 2016 · Viewed 18k times · Source

I am working in Zeppelin writing spark-sql queries and sometimes I suddenly start getting this error (after not changing code):

Cannot call methods on a stopped SparkContext.

Then the output says further down:

The currently active SparkContext was created at:

(No active SparkContext.)

This obviously doesn't make sense. Is this a bug in Zeppelin? Or am I doing something wrong? How can I restart the SparkContext?

Thank you

Answer

user1314742 picture user1314742 · Mar 7, 2016

I have faced this problem a couple of times.

If you are setting your master as yarn-client, it might be due to the stop / restart of Resource Manager, the interpreter process may still be running but the Spark Context (which is a Yarn application) does not exists any more.

You could check if Spark Context is still running by consulting your Resource manager web Interface and check if there is an application named Zeppelin running.

Sometimes restarting the interpreter process from within Zeppelin (interpreter tab --> spark --> restart) will solve the problem.

Other times you need to:

  • kill the Spark interpreter process from the command line
  • remove the Spark Interpreter PID file
  • and the next time you start a paragraph it will start new spark context