MCPcopy Create free account
hub / github.com/apache/impala / _wait_until_fetchable

Method _wait_until_fetchable

tests/stress/query_runner.py:213–243  ·  view source on GitHub ↗

Wait up until timeout_unix_time until the query results can be fetched (if it's a SELECT query) or until it has finished executing (if it's a different query type like DML). If the timeout expires raises a QueryTimeout exception.

(self, cursor, report, timeout_unix_time)

Source from the content-addressed store, hash-verified

211 mem_limit_mb, self.impalad.host_name, timeout_secs, query.sql)
212
213 def _wait_until_fetchable(self, cursor, report, timeout_unix_time):
214 """Wait up until timeout_unix_time until the query results can be fetched (if it's
215 a SELECT query) or until it has finished executing (if it's a different query type
216 like DML). If the timeout expires raises a QueryTimeout exception."""
217 # Loop until the query gets to the right state or a timeout expires.
218 sleep_secs = 0.1
219 secs_since_log = 0
220 # True if we incremented num_queries_started_running_or_cancelled for this query.
221 started_running_or_cancelled = False
222 while True:
223 query_state = cursor.status()
224 # Check if the query got past the PENDING/INITIALIZED states, either because
225 # it's executing or hit an error.
226 if (not started_running_or_cancelled and query_state not in ('PENDING_STATE',
227 'INITIALIZED_STATE')):
228 started_running_or_cancelled = True
229 increment(self._metrics[NUM_QUERIES_STARTED_RUNNING_OR_CANCELLED])
230 # Return if we're ready to fetch results (in the FINISHED state) or we are in
231 # another terminal state like EXCEPTION.
232 if query_state not in ('PENDING_STATE', 'INITIALIZED_STATE', 'RUNNING_STATE'):
233 return
234
235 if time() > timeout_unix_time:
236 if not started_running_or_cancelled:
237 increment(self._metrics[NUM_QUERIES_STARTED_RUNNING_OR_CANCELLED])
238 raise QueryTimeout()
239 if secs_since_log > 5:
240 secs_since_log = 0
241 LOG.debug("Waiting for query to execute")
242 sleep(sleep_secs)
243 secs_since_log += sleep_secs
244
245 def _wait_until_cancelled(self, cursor, query_id):
246 """Wait until 'cursor' is in a CANCELED or ERROR status."""

Callers 1

run_queryMethod · 0.95

Calls 5

incrementFunction · 0.90
timeFunction · 0.85
QueryTimeoutClass · 0.85
statusMethod · 0.45
debugMethod · 0.45

Tested by

no test coverage detected