Github user harishreedharan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8417#discussion_r40011222
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/receiver/BlockGenerator.scala
 ---
    @@ -140,6 +140,16 @@ private[streaming] class BlockGenerator(
           }
         }
     
    +    // When we arrive here, no data will be added to `currentBuffer`. 
However, `currentBuffer` may
    +    // not be empty. If so, we should wait until all data in 
`currentBuffer` is consumed, because
    +    // `blockIntervalTimer.stop(interruptTimer = false)` doesn't guarantee 
calling
    +    // `updateCurrentBuffer` for us.
    +    var isCurrentBufferEmpty = synchronized { currentBuffer.isEmpty }
    +    while(!isCurrentBufferEmpty) {
    +      Thread.sleep(blockIntervalMs)
    +      isCurrentBufferEmpty = synchronized { currentBuffer.isEmpty }
    --- End diff --
    
    A better fix would be to ensure that `updateCurrentBuffer` is called when 
`blockIntervalTimer` is called. This can be done by simply adding a parameter 
to `RecurringTimer` to ensure that the callback is made in the `stop` method. 
    
    The advantage is that we won't be burning CPU here.


---
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]

Reply via email to