Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/9143#discussion_r43446276
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/scheduler/ReceivedBlockTracker.scala
---
@@ -82,34 +85,45 @@ private[streaming] class ReceivedBlockTracker(
}
/** Add received block. This event will get written to the write ahead
log (if enabled). */
- def addBlock(receivedBlockInfo: ReceivedBlockInfo): Boolean =
synchronized {
+ def addBlock(receivedBlockInfo: ReceivedBlockInfo): Boolean = {
try {
- writeToLog(BlockAdditionEvent(receivedBlockInfo))
- getReceivedBlockQueue(receivedBlockInfo.streamId) +=
receivedBlockInfo
- logDebug(s"Stream ${receivedBlockInfo.streamId} received " +
- s"block ${receivedBlockInfo.blockStoreResult.blockId}")
- true
+ val writeResult = writeToLog(BlockAdditionEvent(receivedBlockInfo))
+ if (writeResult) {
+ afterBlockAddAcknowledged(receivedBlockInfo)
+ logDebug(s"Stream ${receivedBlockInfo.streamId} received " +
+ s"block ${receivedBlockInfo.blockStoreResult.blockId}")
+ } else {
+ logDebug(s"Failed to acknowledge stream
${receivedBlockInfo.streamId} receiving " +
+ s"block ${receivedBlockInfo.blockStoreResult.blockId} in the
Write Ahead Log.")
+ }
+ writeResult
} catch {
- case e: Exception =>
+ case NonFatal(e) =>
logError(s"Error adding block $receivedBlockInfo", e)
false
}
}
+ /** Update in-memory state after block add event has been logged to WAL.
*/
+ private def afterBlockAddAcknowledged(receivedBlockInfo:
ReceivedBlockInfo): Unit = synchronized {
--- End diff --
Does this one line thing need to be moved to a different function?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]