ivoson commented on code in PR #54136:
URL: https://github.com/apache/spark/pull/54136#discussion_r2894299705
##########
core/src/main/scala/org/apache/spark/storage/BlockManager.scala:
##########
@@ -314,6 +318,32 @@ private[spark] class BlockManager(
shuffleManager.shuffleBlockResolver.asInstanceOf[MigratableResolver]
}
+ // Timeout waiting for ShuffleManager initialization when receiving shuffle
migration requests
+ private val shuffleManagerInitWaitingTimeoutMs =
+ conf.get(config.STORAGE_SHUFFLE_MANAGER_INIT_WAITING_TIMEOUT)
+
+ /**
+ * Wait for the ShuffleManager to be initialized before handling shuffle
migration requests.
+ * This is necessary because BlockManager is registered with the driver
before ShuffleManager
+ * is initialized in Executor, which could cause NPE if shuffle migration
requests are received
+ * before ShuffleManager is ready.
+ *
+ * @throws ShuffleManagerNotInitializedException if ShuffleManager is not
initialized within
+ * the configured timeout
+ */
+ private def waitForShuffleManagerInit(): Unit = {
+ if (!SparkEnv.get.isShuffleManagerInitialized) {
+ logInfo(log"Waiting for ShuffleManager initialization before handling
shuffle operations")
+
+ if
(!SparkEnv.get.waitForShuffleManagerInit(shuffleManagerInitWaitingTimeoutMs)) {
+ logWarning(log"ShuffleManager not initialized within " +
+ log"${MDC(TIMEOUT, shuffleManagerInitWaitingTimeoutMs)}ms " +
+ log"while handling shuffle operations}")
Review Comment:
thx, updated.
--
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]