From: Pavel Rochnyack Date: Mon, 17 Jul 2017 05:26:16 +0000 (+0700) Subject: rrdtool plugin: Respect RandomTimeout while calling CacheFlush handler X-Git-Tag: collectd-5.6.3~12 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f5177e4f60648ac19d785235a91235e6e401f0cb;p=collectd.git rrdtool plugin: Respect RandomTimeout while calling CacheFlush handler The CacheFlush implementation does not respect RandomTimeout value. All cache values, whose flush is deferred by RandomTimeout variance, will be flushed. That can cause a partial or full cache flush, depending on the value of RandomTimeout. --- diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 27acc997..f94669ad 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -6469,12 +6469,12 @@ it writes all values for a certain RRD-file if the oldest value is older than (or equal to) the number of seconds specified by B. That check happens on new values arriwal. If some RRD-file is not updated anymore for some reason (the computer was shut down, the network is broken, -etc.) some values may still be in the cache. If B is set, then the -entire cache is searched for entries older than B seconds and -written to disk every I seconds. Since this is kind of expensive and -does nothing under normal circumstances, this value should not be too small. -900 seconds might be a good value, though setting this to 7200 seconds doesn't -normally do much harm either. +etc.) some values may still be in the cache. If B is set, then +every I seconds the entire cache is searched for entries older than +B + B seconds. The entries found are written to +disk. Since entire cache scan is kind of expensive and does nothing under normal +circumstances, this value should not be too small. 900 seconds might be a good +value, though setting this to 7200 seconds doesn't normally do much harm either. Default value for this option is 10x of B. If value of B less than value of B then default value diff --git a/src/rrdtool.c b/src/rrdtool.c index 0f02ffc2..dd2df0fe 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -726,7 +726,7 @@ static int rrd_cache_insert(const char *filename, const char *value, if ((cache_timeout > 0) && ((cdtime() - cache_flush_last) > cache_flush_timeout)) - rrd_cache_flush(cache_timeout); + rrd_cache_flush(cache_timeout + random_timeout); pthread_mutex_unlock(&cache_lock);