-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-2677] BasicBlockFetchIterator#next can wait forever #1632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9b7b7c1
(WIP) Modifying ConnectionManager.scala
sarutak a454239
Merge branch 'master' of git://git.apache.org/spark into SPARK-2677
sarutak 0174d6a
Modified ConnectionManager.scala to handle the case remote Executor c…
sarutak ade279a
Merge branch 'master' of git://git.apache.org/spark into SPARK-2677
sarutak 8a73974
Merge branch 'master' of git://git.apache.org/spark into SPARK-2677
sarutak 7cbb8ca
Modified to match with scalastyle
sarutak 0dd9ad3
Modified typo in ConnectionManagerSuite.scala
sarutak 9b620a6
Merge branch 'master' of git://git.apache.org/spark into SPARK-2677
sarutak 7ed48be
Modified ConnectionManager to use ackTimeoutMonitor ConnectionManager…
sarutak e85f88b
Removed useless synchronized blocks
sarutak d3bd2a8
Modified configuration.md for spark.core.connection.ack.timeout
sarutak cddbc7b
Removed Exception throwing when ConnectionManager#handleMessage recei…
sarutak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ import java.nio._ | |
| import java.nio.channels._ | ||
| import java.nio.channels.spi._ | ||
| import java.net._ | ||
| import java.util.{Timer, TimerTask} | ||
| import java.util.concurrent.atomic.AtomicInteger | ||
|
|
||
| import java.util.concurrent.{LinkedBlockingDeque, TimeUnit, ThreadPoolExecutor} | ||
|
|
@@ -61,17 +62,17 @@ private[spark] class ConnectionManager( | |
| var ackMessage: Option[Message] = None | ||
|
|
||
| def markDone(ackMessage: Option[Message]) { | ||
| this.synchronized { | ||
| this.ackMessage = ackMessage | ||
| completionHandler(this) | ||
| } | ||
| this.ackMessage = ackMessage | ||
| completionHandler(this) | ||
| } | ||
| } | ||
|
|
||
| private val selector = SelectorProvider.provider.openSelector() | ||
| private val ackTimeoutMonitor = new Timer("AckTimeoutMonitor", true) | ||
|
|
||
| // default to 30 second timeout waiting for authentication | ||
| private val authTimeout = conf.getInt("spark.core.connection.auth.wait.timeout", 30) | ||
| private val ackTimeout = conf.getInt("spark.core.connection.ack.wait.timeout", 60) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be documented in doc/configuration.md. When users expect long GC pauses, they may wish to increase timeouts across the board, so it's important that all timeout options are documented. |
||
|
|
||
| private val handleMessageExecutor = new ThreadPoolExecutor( | ||
| conf.getInt("spark.core.connection.handler.threads.min", 20), | ||
|
|
@@ -652,19 +653,27 @@ private[spark] class ConnectionManager( | |
| } | ||
| } | ||
| if (bufferMessage.hasAckId()) { | ||
| val sentMessageStatus = messageStatuses.synchronized { | ||
| messageStatuses.synchronized { | ||
| messageStatuses.get(bufferMessage.ackId) match { | ||
| case Some(status) => { | ||
| messageStatuses -= bufferMessage.ackId | ||
| status | ||
| status.markDone(Some(message)) | ||
| } | ||
| case None => { | ||
| throw new Exception("Could not find reference for received ack message " + | ||
| message.id) | ||
| /** | ||
| * We can fall down on this code because of following 2 cases | ||
| * | ||
| * (1) Invalid ack sent due to buggy code. | ||
| * | ||
| * (2) Late-arriving ack for a SendMessageStatus | ||
| * To avoid unwilling late-arriving ack | ||
| * caused by long pause like GC, you can set | ||
| * larger value than default to spark.core.connection.ack.wait.timeout | ||
| */ | ||
| logWarning(s"Could not find reference for received ack Message ${message.id}") | ||
| } | ||
| } | ||
| } | ||
| sentMessageStatus.markDone(Some(message)) | ||
| } else { | ||
| var ackMessage : Option[Message] = None | ||
| try { | ||
|
|
@@ -836,9 +845,23 @@ private[spark] class ConnectionManager( | |
| def sendMessageReliably(connectionManagerId: ConnectionManagerId, message: Message) | ||
| : Future[Message] = { | ||
| val promise = Promise[Message]() | ||
|
|
||
| val timeoutTask = new TimerTask { | ||
| override def run(): Unit = { | ||
| messageStatuses.synchronized { | ||
| messageStatuses.remove(message.id).foreach ( s => { | ||
| promise.failure( | ||
| new IOException(s"sendMessageReliably failed because ack " + | ||
| "was not received within ${ackTimeout} sec")) | ||
| }) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| val status = new MessageStatus(message, connectionManagerId, s => { | ||
| timeoutTask.cancel() | ||
| s.ackMessage match { | ||
| case None => // Indicates a failure where we either never sent or never got ACK'd | ||
| case None => // Indicates a failure where we either never sent or never got ACK'd | ||
| promise.failure(new IOException("sendMessageReliably failed without being ACK'd")) | ||
| case Some(ackMessage) => | ||
| if (ackMessage.hasError) { | ||
|
|
@@ -852,6 +875,8 @@ private[spark] class ConnectionManager( | |
| messageStatuses.synchronized { | ||
| messageStatuses += ((message.id, status)) | ||
| } | ||
|
|
||
| ackTimeoutMonitor.schedule(timeoutTask, ackTimeout * 1000) | ||
| sendMessage(connectionManagerId, message) | ||
| promise.future | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HashedWheelTimer performance is better