Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-6449

Use CLOCK_MONOTONIC in ConditonVariable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Impala 2.7.0, Impala 2.8.0, Impala 2.9.0, Impala 2.10.0, Impala 2.11.0, Impala 2.12.0
    • Fix Version/s: Impala 3.0, Impala 2.12.0
    • Component/s: Backend
    • Labels:
      None
    • Epic Color:
      ghx-label-9

      Description

      There are various places in the code which call ConditionVariable::WaitUntil() or ConditionVariable::WaitFor() with a time computed from boost::get_system_time().

        template <typename duration_type>
        bool WaitFor(boost::unique_lock<boost::mutex>& lock,
            const duration_type& wait_duration) {
          return WaitUntil(lock, to_timespec(boost::get_system_time() + wait_duration));
        }
      

      blocking-queue.h:

        template <typename V>
        bool BlockingPutWithTimeout(V&& val, int64_t timeout_micros) {
          MonotonicStopWatch timer;
          boost::unique_lock<boost::mutex> write_lock(put_lock_);
          boost::system_time wtime = boost::get_system_time() +
              boost::posix_time::microseconds(timeout_micros);
      

      thrift-server.cc:

        system_time deadline = get_system_time() +
            posix_time::milliseconds(ThriftServer::ThriftServerEventProcessor::TIMEOUT_MS);
      
        // Loop protects against spurious wakeup. Locks provide necessary fences to ensure
        // visibility.
        while (!signal_fired_) {
          // Yields lock and allows supervision thread to continue and signal
          if (!signal_cond_.WaitUntil(lock, deadline)) {
      

      The above are susceptible to clock adjustment from various sources such as NTP. We should switch to using clock_gettime(CLOCK_MONOTONIC, ...) for such elapsed time measurement.

        Attachments

          Activity

            People

            • Assignee:
              kwho Michael Ho
              Reporter:
              kwho Michael Ho
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: