diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2023-06-20 21:55:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-20 21:55:08 +0300 |
commit | a8da69781970b585e2b4af58f763dfb240445d92 (patch) | |
tree | 12badb5e608dc9371efb3719702499fe1b59216a /database | |
parent | 428113b20203ce5fb891061db7105dd55e09a6b4 (diff) |
Fix /api/v2/contexts,nodes,nodes_instances,q before match (#15223)
* readers should be able to recursively acquire the lock, even when there is a writer waiting
* in /api/v2/contexts/nodes/nodes_instances/q calls, when the context is collected, before should be matched against now, not the latest cached retention
Diffstat (limited to 'database')
-rw-r--r-- | database/contexts/api_v2.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/database/contexts/api_v2.c b/database/contexts/api_v2.c index 801b0eccfa..3e8a6a3007 100644 --- a/database/contexts/api_v2.c +++ b/database/contexts/api_v2.c @@ -141,7 +141,7 @@ static FTS_MATCH rrdcontext_to_json_v2_full_text_search(struct rrdcontext_to_jso dfe_start_read(rc->rrdinstances, ri) { if(matched) break; - if(ctl->window.enabled && !query_matches_retention(ctl->window.after, ctl->window.before, ri->first_time_s, ri->last_time_s, 0)) + if(ctl->window.enabled && !query_matches_retention(ctl->window.after, ctl->window.before, ri->first_time_s, (ri->flags & RRD_FLAG_COLLECTED) ? ctl->now : ri->last_time_s, 0)) continue; if(unlikely(full_text_search_string(&ctl->q.fts, q, ri->id)) || @@ -152,7 +152,7 @@ static FTS_MATCH rrdcontext_to_json_v2_full_text_search(struct rrdcontext_to_jso RRDMETRIC *rm; dfe_start_read(ri->rrdmetrics, rm) { - if(ctl->window.enabled && !query_matches_retention(ctl->window.after, ctl->window.before, rm->first_time_s, rm->last_time_s, 0)) + if(ctl->window.enabled && !query_matches_retention(ctl->window.after, ctl->window.before, rm->first_time_s, (rm->flags & RRD_FLAG_COLLECTED) ? ctl->now : rm->last_time_s, 0)) continue; if(unlikely(full_text_search_string(&ctl->q.fts, q, rm->id)) || @@ -200,7 +200,7 @@ static ssize_t rrdcontext_to_json_v2_add_context(void *data, RRDCONTEXT_ACQUIRED RRDCONTEXT *rc = rrdcontext_acquired_value(rca); - if(ctl->window.enabled && !query_matches_retention(ctl->window.after, ctl->window.before, rc->first_time_s, rc->last_time_s, 0)) + if(ctl->window.enabled && !query_matches_retention(ctl->window.after, ctl->window.before, rc->first_time_s, (rc->flags & RRD_FLAG_COLLECTED) ? ctl->now : rc->last_time_s, 0)) return 0; // continue to next context FTS_MATCH match = ctl->q.host_match; |