Browse Source

/api/v2/X part 6 (#14785)

* additional check for consistency of rrdr

* do not query the host if the contexts are not initialized for it
Costa Tsaousis 2 years ago
parent
commit
def14d13f5
2 changed files with 4 additions and 1 deletions
  1. 3 0
      database/contexts/query_scope.c
  2. 1 1
      web/api/queries/weights.c

+ 3 - 0
database/contexts/query_scope.c

@@ -72,6 +72,9 @@ ssize_t query_scope_foreach_host(SIMPLE_PATTERN *scope_hosts_sp, SIMPLE_PATTERN
 
 ssize_t query_scope_foreach_context(RRDHOST *host, const char *scope_contexts, SIMPLE_PATTERN *scope_contexts_sp,
                                    SIMPLE_PATTERN *contexts_sp, foreach_context_cb_t cb, bool queryable_host, void *data) {
+    if(unlikely(!host->rrdctx.contexts))
+        return 0;
+
     ssize_t added = 0;
 
     RRDCONTEXT_ACQUIRED *rca = NULL;

+ 1 - 1
web/api/queries/weights.c

@@ -1103,7 +1103,7 @@ static void rrdset_weights_multi_dimensional_value(struct query_weights_data *qw
     ONEWAYALLOC *owa = onewayalloc_create(16 * 1024);
     RRDR *r = rrd2rrdr(owa, query_target_create(&qtr));
 
-    if(rrdr_rows(r) != 1 || !r->d)
+    if(rrdr_rows(r) != 1 || !r->d || r->d != r->internal.qt->query.used)
         goto cleanup;
 
     QUERY_VALUE qv = {