BigQuery: Avoid too long(10 seconds) interval for bigquery api to get results #7342
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Description
On BigQuery runner, query results is fetched by calling BigQuery's getQueryResults API below.
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/getQueryResults
As the default timeout for the API is 10 seconds, redash BigQuery runner calls another API after 10 seconds timeout. But, redash runner sleep for another 10 seconds before calling API again.
So, the situation is like below:
(Please note that the API call is synchronous. The HTTP connection is kept for up to 10 seconds.)
...
So, if the query finished within 0-10 seconds, it is OK and the results was fetched on time.
But, if the query finished within 10-20 seconds, redash runner always wait for 20 seconds (even if query takes just 11 seconds.)
Same after that.
If the query finished within 20-30 seconds, it is OK and the results was fetched on time.
If the query finished within 30-40 seconds, redash runner always wait for 40 seconds
This PR fixes the issue by changing sleep time from 10 seconds to 1 second.
How is this tested?
I run the query that took about 14 seconds and see the worker log.
Before PR:
(worker log)
Getting query results took more than 20 seconds as the second API was called after 20 seconds.
After PR:
(worker log)
Getting query results just took 14 secods.