anishshri-db commented on code in PR #42066:
URL: https://github.com/apache/spark/pull/42066#discussion_r1281021882


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -636,17 +691,46 @@ object StateStore extends Logging {
     if (SparkEnv.get == null) {
       throw new IllegalStateException("SparkEnv not active, cannot do 
maintenance on StateStores")
     }
-    loadedProviders.synchronized { loadedProviders.toSeq }.foreach { case (id, 
provider) =>
-      try {
-        provider.doMaintenance()
-        if (!verifyIfStoreInstanceActive(id)) {
-          unload(id)
-          logInfo(s"Unloaded $provider")
-        }
-      } catch {
-        case NonFatal(e) =>
-          logWarning(s"Error managing $provider, stopping management thread")
-          throw e
+    loadedProviders.synchronized {
+      loadedProviders.toSeq
+    }.foreach { case (id, provider) =>
+      // check exception
+      if (threadPoolException.get() != null) {
+        val exception = threadPoolException.get()
+        logWarning("Error in maintenanceThreadPool", exception)
+        throw exception
+      }
+      if (processThisPartition(id)) {
+        maintenanceThreadPool.execute(() => {
+          val startTime = System.currentTimeMillis()
+          try {
+            provider.doMaintenance()
+            if (!verifyIfStoreInstanceActive(id)) {
+              unload(id)
+              logInfo(s"Unloaded $provider")
+            }
+          } catch {
+            case NonFatal(e) =>
+              logWarning(s"Error managing $provider, stopping management 
thread", e)
+              threadPoolException.set(e)
+              throw e

Review Comment:
   is this exception caught by a higher level thread pool utility function ? 
Will it just log this exception in that case ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to