diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2022-05-12 22:39:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-12 22:39:18 +0300 |
commit | 60ee48f7bb01e5bb4b60424c062aeb571af209ed (patch) | |
tree | aec7e2c2e068ebb172eab2a1f29e5b92f8c8ab51 /aclk | |
parent | 73bb8888f3bffcb36b99b9341f15d21b3de844d0 (diff) |
Take into account the in queue wait time when executing a data query (#12885)
Take into account the in queue wait time when executing a query with a timeout
Diffstat (limited to 'aclk')
-rw-r--r-- | aclk/aclk_query.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/aclk/aclk_query.c b/aclk/aclk_query.c index bd3b7a572c..502272057d 100644 --- a/aclk/aclk_query.c +++ b/aclk/aclk_query.c @@ -111,13 +111,15 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query) w->tv_in = query->created_tv; now_realtime_timeval(&w->tv_ready); - if (query->timeout && (dt_usec(&query->created_tv, &w->tv_ready) / 1000.0) > query->timeout) { - log_access("QUERY CANCELED: QUEUE TIME EXCEEDED %0.2f ms (LIMIT %d ms)", - dt_usec(&query->created_tv, &w->tv_ready) / 1000.0, query->timeout); - retval = 1; - w->response.code = HTTP_RESP_BACKEND_FETCH_FAILED; - aclk_http_msg_v2_err(query_thr->client, query->callback_topic, query->msg_id, w->response.code, CLOUD_EC_SND_TIMEOUT, CLOUD_EMSG_SND_TIMEOUT, NULL, 0); - goto cleanup; + if (query->timeout) { + double in_queue = (int)dt_usec(&w->tv_in, &w->tv_ready) / 1000; + if (in_queue > query->timeout) { + log_access("QUERY CANCELED: QUEUE TIME EXCEEDED %0.2f ms (LIMIT %d ms)", in_queue, query->timeout); + retval = 1; + w->response.code = HTTP_RESP_BACKEND_FETCH_FAILED; + aclk_http_msg_v2_err(query_thr->client, query->callback_topic, query->msg_id, w->response.code, CLOUD_EC_SND_TIMEOUT, CLOUD_EMSG_SND_TIMEOUT, NULL, 0); + goto cleanup; + } } RRDHOST *temp_host = NULL; |