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

ContextWaiter didn't handle 'spurious wakeup'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.0.3, 1.1.2, 1.2.1, 1.3.0
    • DStreams
    • 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

              Unassigned Unassigned
              zsxwing Shixiong Zhu
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: