-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Avoid timing out when no timeout is set #4653
Conversation
redash/tasks/worker.py
Outdated
@@ -50,8 +50,11 @@ def stop_executing_job(self, job): | |||
self.log.warning("Job %s has been cancelled.", job.id) | |||
|
|||
def soft_limit_exceeded(self, job): | |||
seconds_under_monitor = (utcnow() - self.monitor_started).seconds | |||
return seconds_under_monitor > job.timeout + self.grace_period | |||
if job.timeout < 0: |
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.
Shouldn't it be <=
? Or zero timeout has some special meaning?
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.
Maybe we should use explicit -1 here? So it's clear what is it about? I would also consider defining a constant for it, so it's clear where this magic number coming from.
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.
@kravets-levko only -1 means "run infinitely". While I agree that a 0 doesn't make sense, someone might want to choose to set their Redash instance to time out immediately (🤷🏻♂️), so soft_limit_exceeded
should include those. I agree with @arikfr's approach regarding explicitness.
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.
I would also consider defining a constant for it, so it's clear where this magic number coming from.
Decided to avoid constant since it wouldn't be re-used in settings. Went for a descriptive variable name instead.
What type of PR is this? (check all applicable)
Description
Following #4626, query execution jobs were set to never time out by default, but our
Worker
implementation would enforce a hard limit if soft limits + grace period (15s) are not handled. In this case, if a time limit is not set, jobs would time out after-1 + 15 = 14
seconds.