Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-4813

ContextWaiter didn't handle 'spurious wakeup'

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.3, 1.1.2, 1.2.1, 1.3.0
    • Component/s: DStreams
    • Labels:
      None

      Description

      According to javadocs,

      A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

      synchronized (obj)

      Unknown macro: { while (<condition does not hold>) obj.wait(timeout); ... // Perform action appropriate to condition }

      `wait` should always occur in loops.

      But now ContextWaiter.waitForStopOrError doesn't.

        def waitForStopOrError(timeout: Long = -1) = synchronized {
          // If already had error, then throw it
          if (error != null) {
            throw error
          }
      
          // If not already stopped, then wait
          if (!stopped) {
            if (timeout < 0) wait() else wait(timeout)
            if (error != null) throw error
          }
        }
      

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              zsxwing Shixiong Zhu

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment