-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show queue position while waiting for query to execute #3583
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. I suggest you get familiar with how Celery handles the queue before implementing this. I doubt it's possible to reliably tell how many tasks await ahead of a given task in an environment where there are multiple workers processing the queue (because you don't know which one will get it).
Also once you try poking Celery to get to know how many queries are currently reserved, you will realize it's not feasible for a request that comes in every second (in terms of how long it takes all the workers to reply).
redash/tasks/queries.py
Outdated
@@ -71,12 +72,21 @@ def to_dict(self): | |||
else: | |||
query_result_id = None | |||
|
|||
queriesAhead = 0 | |||
if task_status == 'PENDING': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will get PENDING for non existing task id as well. In which case, it won't be found in the queue and you will report there are no queries ahead of it.
Query can be reserved by a worker (which I guess is also reported as PENDING), and then it won't be in get_waiting_in_queue
list.
@arikfr Maybe it would help if we stepped back to explain what we're trying to accomplish here. It's not necessarily important that we have an exactly correct count of how many queries are in front of the current one in the queue. What is important is that folks get an idea about the relative state of things. Is everything flowing smoothly and the queues are relatively empty, or are the queues relatively gummed up so the user can expect that the user should expect much higher latency than usual. Currently users click "execute" and experience wait times ranging from a few seconds to 5-10 minutes for the same query, depending on the overall load on the entire queue / data source system. We're hoping to make it so that, when wait times are long due to heavy load, the user at least gets an indication this is so. Given this requirement, how would you suggest we tackle the problem? |
Good idea! :-)
Based on this description, I would suggest a different solution. We recently added new screens for admins to see Celery status (#3057). Using the same raw data, we can create a less technical view for end users that will reflect the queues status. There is the question of what to show exactly, where to show it and then how to implement (for example, I would go for a separate API call that is no combined with job status polling). Can you open a new issue so we can discuss this? |
c1ca6e0
to
fa7f86b
Compare
@@ -207,7 +207,7 @@ <h3> | |||
<rd-timer timestamp="queryResult.getUpdatedAt()"></rd-timer> | |||
</div> | |||
<div class="alert alert-info m-t-15" ng-show="queryResult.getStatus() == 'waiting'"> | |||
Query in queue… | |||
Query in queue <span ng-if="queryResult && queryResult.queueStatus">(waiting on {{queryResult.queueStatus}} <ng-pluralize count=queryResult.queueStatus when="{'0': 'queries', 'one': 'query', 'other': 'queries'}"></ng-pluralize>)</span>… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0
case could be omitted (other
covers it)
if (this.getStatus() === 'waiting') { | ||
const p = $http.get(`/api/queue_status/${this.job.id}?data_source=${dataSourceId}`); | ||
p.then((response) => { | ||
$timeout(() => this.refreshQueueStatus(dataSourceId), 10000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When query page is left, does this interval halt?
This puts the number of queries currently waiting to be executed in the status for a job reported in the query execution page.