[ https://issues.apache.org/jira/browse/IMPALA-6449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Ho resolved IMPALA-6449. -------------------------------- Resolution: Fixed Fix Version/s: Impala 2.12.0 Impala 3.0 https://github.com/apache/impala/commit/30c0375ed358f8040d28fe756a17c6e3965177b1 IMPALA-6449: Use CLOCK_MONOTONIC in ConditionVariable ConditionVariable is a thin wrapper around pthread_cond_*. Currently, pthread_cond_timedwait() uses the default attribute CLOCK_REALTIME. This is susceptible to adjustment to the system clock from various sources such as NTP and time may go backward. This change fixes the problem by switching to using CLOCK_MONOTONIC so time will be monotonic although the frequency of the clock ticks may still be adjusted by NTP. Ideally, we should use CLOCK_MONOTONIC_RAW but it's available only on Linux kernel 2.6.28 or latter. This change also get rids of some usage of boost::get_system_time() which suffers from the same problem. Change-Id: I81611cfd5e7c5347203fe7fa6b0f615602257f87 Reviewed-on: http://gerrit.cloudera.org:8080/9158 Reviewed-by: Michael Ho <k...@cloudera.com> Tested-by: Impala Public Jenkins > Use CLOCK_MONOTONIC in ConditonVariable > --------------------------------------- > > Key: IMPALA-6449 > URL: https://issues.apache.org/jira/browse/IMPALA-6449 > Project: IMPALA > Issue Type: Bug > Components: Backend > Affects Versions: Impala 2.7.0, Impala 2.8.0, Impala 2.9.0, Impala 2.10.0, > Impala 2.11.0, Impala 2.12.0 > Reporter: Michael Ho > Assignee: Michael Ho > Priority: Minor > Fix For: Impala 3.0, Impala 2.12.0 > > > There are various places in the code which call > {{ConditionVariable::WaitUntil()}} or {{ConditionVariable::WaitFor()}} with a > time computed from {{boost::get_system_time()}}. > {noformat} > 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)); > } > {noformat} > blocking-queue.h: > {noformat} > 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); > {noformat} > thrift-server.cc: > {noformat} > 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)) { > {noformat} > 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. -- This message was sent by Atlassian JIRA (v7.6.3#76005)