MB-13024: Prevent zero time delta for defragmenter ProgressTracker
MB-13024: Prevent zero time delta for defragmenter ProgressTracker

When calculating how much time has passed since the last defragmenter
progress check, we calcuate the delta between now and the last time a
check was made. However, this delta can sometimes be zero if the
underlying "high resolution" clock has a relatively coarse period, and
the defragmenter has only visited a small number of items.

As a consequence the zero delta triggered a divide-by-zero error
causing memcached to crash.

Address this issue by adding the period of the high resolution clock
to the calculated delta. This slightly decreases the precision of the
time delta (from ±2 * clock_period to ±3 * clock_period) but ensures
that a zero delta is no longer possible.

Note: This issue was encountered on CentOS 6.5, where
std::chrono::high_resolution_clock only has a period of 1 microsecond
(when using GCC 4.4). Interestingly upgrading to GCC 4.8 improves this
to 1 nanosecond, and appears to solve this issue; however as we are
currently still using GCC 4.4 (and other platforms may also have
similary low precision clocks) this code-change has been made.

Change-Id: I242b41eb2aca8155d1c276373dc172911769780c
Reviewed-on: http://review.couchbase.org/44838
Reviewed-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>
Reviewed-by: Michael Wiederhold <a17fed27eaa842282862ff7c1b9c8395a26ac320@couchbase.com>
Tested-by: Dave Rigby <a09264da4832c7ff1d3bf1608a19f4b870f93750@couchbase.com>
Reviewed-by: Jim Walker <1cd02e31b43620d7c664e038ca42a060d61727b9@couchbase.com>

owendCB/ep-engine,owendCB/ep-engine,sriganes/ep-engine,membase/ep-engine,teligent-ru/ep-engine,jimwwalker/ep-engine,sriganes/ep-engine,couchbase/ep-engine,daverigby/ep-engine,owendCB/ep-engine,jimwwalker/ep-engine,sriganes/ep-engine,daverigby/kv_engine,teligent-ru/ep-engine,daverigby/ep-engine,jimwwalker/ep-engine,daverigby/kv_engine,membase/ep-engine,sriganes/ep-engine,teligent-ru/ep-engine,couchbase/ep-engine,hisundar/ep-engine,membase/ep-engine,couchbase/ep-engine,couchbase/ep-engine,hisundar/ep-engine,hisundar/ep-engine,hisundar/ep-engine,teligent-ru/ep-engine,daverigby/ep-engine,membase/ep-engine,owendCB/ep-engine,daverigby/ep-engine,jimwwalker/ep-engine,daverigby/kv_engine,daverigby/kv_engine