diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-03-31 12:58:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-03-31 12:58:11 +0000 |
commit | f99c4526d94d3e04124c5c48ab4a3da6ca53a458 (patch) | |
tree | a2ed8860030cc49f492b09b3222d593c65619800 /web/api/queries/query.c | |
parent | Adding upstream version 1.29.3. (diff) | |
download | netdata-f99c4526d94d3e04124c5c48ab4a3da6ca53a458.tar.xz netdata-f99c4526d94d3e04124c5c48ab4a3da6ca53a458.zip |
Adding upstream version 1.30.0.upstream/1.30.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/api/queries/query.c')
-rw-r--r-- | web/api/queries/query.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/web/api/queries/query.c b/web/api/queries/query.c index 663e4bd14..2a27a94fc 100644 --- a/web/api/queries/query.c +++ b/web/api/queries/query.c @@ -281,8 +281,14 @@ RRDR_GROUPING web_client_api_request_v1_data_group(const char *name, RRDR_GROUPI // ---------------------------------------------------------------------------- -static void rrdr_disable_not_selected_dimensions(RRDR *r, RRDR_OPTIONS options, const char *dims, RRDDIM *temp_rd) { - rrdset_check_rdlock(r->st); +static void rrdr_disable_not_selected_dimensions(RRDR *r, RRDR_OPTIONS options, const char *dims, + struct context_param *context_param_list) +{ + RRDDIM *temp_rd = context_param_list ? context_param_list->rd : NULL; + int should_lock = (!context_param_list || !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE)); + + if (should_lock) + rrdset_check_rdlock(r->st); if(unlikely(!dims || !*dims || (dims[0] == '*' && dims[1] == '\0'))) return; @@ -758,8 +764,8 @@ static int rrdr_convert_before_after_to_absolute( } // allow relative for before (smaller than API_RELATIVE_TIME_MAX) - if(abs(before_requested) <= API_RELATIVE_TIME_MAX) { - if(abs(before_requested) % update_every) { + if(ABS(before_requested) <= API_RELATIVE_TIME_MAX) { + if(ABS(before_requested) % update_every) { // make sure it is multiple of st->update_every if(before_requested < 0) before_requested = before_requested - update_every - before_requested % update_every; @@ -772,9 +778,9 @@ static int rrdr_convert_before_after_to_absolute( } // allow relative for after (smaller than API_RELATIVE_TIME_MAX) - if(abs(after_requested) <= API_RELATIVE_TIME_MAX) { + if(ABS(after_requested) <= API_RELATIVE_TIME_MAX) { if(after_requested == 0) after_requested = -update_every; - if(abs(after_requested) % update_every) { + if(ABS(after_requested) % update_every) { // make sure it is multiple of st->update_every if(after_requested < 0) after_requested = after_requested - update_every - after_requested % update_every; else after_requested = after_requested + update_every - after_requested % update_every; @@ -1060,10 +1066,11 @@ static RRDR *rrd2rrdr_fixedstep( // ------------------------------------------------------------------------- // disable the not-wanted dimensions - rrdset_check_rdlock(st); + if (context_param_list && !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE)) + rrdset_check_rdlock(st); if(dimensions) - rrdr_disable_not_selected_dimensions(r, options, dimensions, temp_rd); + rrdr_disable_not_selected_dimensions(r, options, dimensions, context_param_list); // ------------------------------------------------------------------------- @@ -1435,11 +1442,11 @@ static RRDR *rrd2rrdr_variablestep( // ------------------------------------------------------------------------- // disable the not-wanted dimensions - - rrdset_check_rdlock(st); + if (context_param_list && !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE)) + rrdset_check_rdlock(st); if(dimensions) - rrdr_disable_not_selected_dimensions(r, options, dimensions, temp_rd); + rrdr_disable_not_selected_dimensions(r, options, dimensions, context_param_list); // ------------------------------------------------------------------------- @@ -1591,8 +1598,12 @@ RRDR *rrd2rrdr( if (first_entry_t > after_requested) first_entry_t = after_requested; - if (context_param_list) + if (context_param_list && !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE)) { rebuild_context_param_list(context_param_list, after_requested); + st = context_param_list->rd ? context_param_list->rd->rrdset : NULL; + if (unlikely(!st)) + return NULL; + } #ifdef ENABLE_DBENGINE if (st->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) { |