@cryptotaxi247 / netdata-1 / commits / 9a6c9b5bb

Set a page wait timeout to 1 second (#12836)

Retry 3 times, to queue the page request before giving up

Stelios Fragkakis committed May 6, 2022 at 22:35 UTC 9a6c9b5bb5eeecf7d2f5f976571472982d8b023a
2 files changed +10 -2
database/engine/pagecache.c
+9 -2
@@ -1067,10 +1067,13 @@ pg_cache_lookup_next(struct rrdengine_instance *ctx, struct pg_cache_page_index
1067
1068 page_not_in_cache = 0;
1069 uv_rwlock_rdlock(&page_index->lock);
1070 + int retry_count = 0;
1071 while (1) {
1072 descr = find_first_page_in_time_range(page_index, start_time, end_time);
1072 - if (NULL == descr || 0 == descr->page_length) {
1073 + if (NULL == descr || 0 == descr->page_length || retry_count == MAX_PAGE_CACHE_RETRY_WAIT) {
1074 /* non-empty page not found */
1075 + if (retry_count == MAX_PAGE_CACHE_RETRY_WAIT)
1076 + error_report("Page cache timeout while waiting for page %p : returning FAIL", descr);
1077 uv_rwlock_rdunlock(&page_index->lock);
1078
1079 pg_cache_release_pages(ctx, 1);
@@ -1114,7 +1117,11 @@ pg_cache_lookup_next(struct rrdengine_instance *ctx, struct pg_cache_page_index
1117 print_page_cache_descr(descr);
1118 if (!(flags & RRD_PAGE_POPULATED))
1119 page_not_in_cache = 1;
1117 - pg_cache_wait_event_unsafe(descr);
1120 +
1121 + if (pg_cache_timedwait_event_unsafe(descr, 1) == UV_ETIMEDOUT) {
1122 + error_report("Page cache timeout while waiting for page %p : retry count = %d", descr, retry_count);
1123 + ++retry_count;
1124 + }
1125 rrdeng_page_descr_mutex_unlock(ctx, descr);
1126
1127 /* reset scan to find again */
database/engine/pagecache.h
+1
@@ -11,6 +11,7 @@ struct extent_info;
11 struct rrdeng_page_descr;
12
13 #define INVALID_TIME (0)
14 +#define MAX_PAGE_CACHE_RETRY_WAIT (3)
15
16 /* Page flags */
17 #define RRD_PAGE_DIRTY (1LU << 0)