File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ object StateStore extends Logging {
128
128
@ GuardedBy (" loadedProviders" )
129
129
private val loadedProviders = new mutable.HashMap [StateStoreId , StateStoreProvider ]()
130
130
131
+ /**
132
+ * Runs the `task` periodically and automatically cancels it if there is an exception. `onError`
133
+ * will be called when an exception happens.
134
+ */
131
135
class MaintenanceTask (periodMs : Long , task : => Unit , onError : => Unit ) {
132
136
private val executor =
133
137
ThreadUtils .newDaemonSingleThreadScheduledExecutor(" state-store-maintenance-task" )
@@ -210,7 +214,7 @@ object StateStore extends Logging {
210
214
/** Start the periodic maintenance task if not already started and if Spark active */
211
215
private def startMaintenanceIfNeeded (): Unit = loadedProviders.synchronized {
212
216
val env = SparkEnv .get
213
- if (env != null && (maintenanceTask == null || ! maintenanceTask.isRunning) ) {
217
+ if (env != null && ! isMaintenanceRunning ) {
214
218
val periodMs = env.conf.getTimeAsMs(
215
219
MAINTENANCE_INTERVAL_CONFIG , s " ${MAINTENANCE_INTERVAL_DEFAULT_SECS }s " )
216
220
maintenanceTask = new MaintenanceTask (
You can’t perform that action at this time.
0 commit comments