diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2022-06-23 13:48:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-23 13:48:06 +0300 |
commit | 75f29fd4d623a0995e8e534982c5a9c3987bb5cd (patch) | |
tree | 35330e200e31b2d38b8b870e5a4b267232035b43 | |
parent | a878ed36431db17bebb53004200e41bb91e9248f (diff) |
Add configuration for dbengine page fetch timeout and retry count (#13194)
* Add configuration for page cache fetch timeout and retry count
Change page cache wait default timeout to 3 seconds
* Issue info message in the error.log if values not within expected lower range
* Fix compilation errors with --disable-dbengine
-rw-r--r-- | daemon/main.c | 14 | ||||
-rw-r--r-- | database/engine/pagecache.c | 6 | ||||
-rw-r--r-- | database/engine/pagecache.h | 3 | ||||
-rwxr-xr-x | database/engine/rrdengineapi.c | 2 | ||||
-rw-r--r-- | database/engine/rrdengineapi.h | 2 |
5 files changed, 23 insertions, 4 deletions
diff --git a/daemon/main.c b/daemon/main.c index 6a07add1c9..35f2c189e4 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1231,6 +1231,20 @@ int main(int argc, char **argv) { // initialize the log files open_all_log_files(); +#ifdef ENABLE_DBENGINE + default_rrdeng_page_fetch_timeout = (int) config_get_number(CONFIG_SECTION_GLOBAL, "dbengine page fetch timeout", PAGE_CACHE_FETCH_WAIT_TIMEOUT); + if (default_rrdeng_page_fetch_timeout < 1) { + info("\"dbengine page fetch timeout\" found in netdata.conf cannot be %d, using 1", default_rrdeng_page_fetch_timeout); + default_rrdeng_page_fetch_timeout = 1; + } + + default_rrdeng_page_fetch_retries = (int) config_get_number(CONFIG_SECTION_GLOBAL, "dbengine page fetch retries", MAX_PAGE_CACHE_FETCH_RETRIES); + if (default_rrdeng_page_fetch_retries < 1) { + info("\"dbengine page fetch retries\" found in netdata.conf cannot be %d, using 1", default_rrdeng_page_fetch_retries); + default_rrdeng_page_fetch_retries = 1; + } +#endif + get_system_timezone(); // -------------------------------------------------------------------- // get the certificate and start security diff --git a/database/engine/pagecache.c b/database/engine/pagecache.c index 5c56df72ab..9a5891d41e 100644 --- a/database/engine/pagecache.c +++ b/database/engine/pagecache.c @@ -1067,9 +1067,9 @@ pg_cache_lookup_next(struct rrdengine_instance *ctx, struct pg_cache_page_index int retry_count = 0; while (1) { descr = find_first_page_in_time_range(page_index, start_time, end_time); - if (NULL == descr || 0 == descr->page_length || retry_count == MAX_PAGE_CACHE_RETRY_WAIT) { + if (NULL == descr || 0 == descr->page_length || retry_count == default_rrdeng_page_fetch_retries) { /* non-empty page not found */ - if (retry_count == MAX_PAGE_CACHE_RETRY_WAIT) + if (retry_count == default_rrdeng_page_fetch_retries) error_report("Page cache timeout while waiting for page %p : returning FAIL", descr); uv_rwlock_rdunlock(&page_index->lock); @@ -1115,7 +1115,7 @@ pg_cache_lookup_next(struct rrdengine_instance *ctx, struct pg_cache_page_index if (!(flags & RRD_PAGE_POPULATED)) page_not_in_cache = 1; - if (pg_cache_timedwait_event_unsafe(descr, 1) == UV_ETIMEDOUT) { + if (pg_cache_timedwait_event_unsafe(descr, default_rrdeng_page_fetch_timeout) == UV_ETIMEDOUT) { error_report("Page cache timeout while waiting for page %p : retry count = %d", descr, retry_count); ++retry_count; } diff --git a/database/engine/pagecache.h b/database/engine/pagecache.h index 0ba4639cec..6c157dfba2 100644 --- a/database/engine/pagecache.h +++ b/database/engine/pagecache.h @@ -11,7 +11,8 @@ struct extent_info; struct rrdeng_page_descr; #define INVALID_TIME (0) -#define MAX_PAGE_CACHE_RETRY_WAIT (3) +#define MAX_PAGE_CACHE_FETCH_RETRIES (3) +#define PAGE_CACHE_FETCH_WAIT_TIMEOUT (3) /* Page flags */ #define RRD_PAGE_DIRTY (1LU << 0) diff --git a/database/engine/rrdengineapi.c b/database/engine/rrdengineapi.c index 0792ebe001..180623ca02 100755 --- a/database/engine/rrdengineapi.c +++ b/database/engine/rrdengineapi.c @@ -5,6 +5,8 @@ struct rrdengine_instance multidb_ctx; int db_engine_use_malloc = 0; +int default_rrdeng_page_fetch_timeout = 3; +int default_rrdeng_page_fetch_retries = 3; int default_rrdeng_page_cache_mb = 32; int default_rrdeng_disk_quota_mb = 256; int default_multidb_disk_quota_mb = 256; diff --git a/database/engine/rrdengineapi.h b/database/engine/rrdengineapi.h index 798545d9d7..7073d020bb 100644 --- a/database/engine/rrdengineapi.h +++ b/database/engine/rrdengineapi.h @@ -13,6 +13,8 @@ #define RRDENG_FD_BUDGET_PER_INSTANCE (50) extern int db_engine_use_malloc; +extern int default_rrdeng_page_fetch_timeout; +extern int default_rrdeng_page_fetch_retries; extern int default_rrdeng_page_cache_mb; extern int default_rrdeng_disk_quota_mb; extern int default_multidb_disk_quota_mb; |