Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 9e16caa

Browse files
committed
Check timeout after cache fetch
1 parent 6066dd9 commit 9e16caa

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

graphql/accessor_general.lua

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,21 @@ local function match_using_re(obj, pcre)
817817
return true
818818
end
819819

820+
--- Check whether we meet deadline time.
821+
---
822+
--- The functions raises an exception in the case.
823+
---
824+
--- @tparam table qcontext
825+
---
826+
--- @return nothing
827+
local function check_deadline_clock(qcontext)
828+
if clock.monotonic64() > qcontext.deadline_clock then
829+
error(e.timeout_exceeded((
830+
'query execution timeout exceeded timeout_ms limit (%s ms)'):format(
831+
tostring(qcontext.query_settings.timeout_ms))))
832+
end
833+
end
834+
820835
--- Perform unflatten, skipping, filtering, limiting of objects. This is the
821836
--- core of the `select_internal` function.
822837
---
@@ -868,11 +883,8 @@ local function process_tuple(self, state, tuple, opts)
868883
cache_hit_objects_cnt = opts.cache_hit_tuples_cnt,
869884
})
870885

871-
if clock.monotonic64() > qcontext.deadline_clock then
872-
error(e.timeout_exceeded((
873-
'query execution timeout exceeded timeout_ms limit (%s ms)'):format(
874-
tostring(state.qcontext.query_settings.timeout_ms))))
875-
end
886+
check_deadline_clock(qcontext)
887+
876888
local collection_name = opts.collection_name
877889
local pcre = opts.pcre
878890
local resolveField = opts.resolveField
@@ -1703,7 +1715,7 @@ function accessor_general.new(opts, funcs)
17031715
index_lookup_cnt = stat.index_lookup_cnt
17041716
})
17051717

1706-
-- XXX: check timeout
1718+
check_deadline_clock(qcontext)
17071719

17081720
return fetch_id
17091721
end,

0 commit comments

Comments
 (0)