Skip to content
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

Merged
merged 2 commits into from
Feb 18, 2020

Conversation

rauchy
Copy link
Contributor

@rauchy rauchy commented Feb 18, 2020

What type of PR is this? (check all applicable)

  • Bug Fix

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.

@rauchy rauchy requested a review from arikfr February 18, 2020 12:43
@rauchy rauchy changed the title soft limits should not exceed if they are set to run infinitely Avoid timing out when not timeout is set Feb 18, 2020
@rauchy rauchy changed the title Avoid timing out when not timeout is set Avoid timing out when no timeout is set Feb 18, 2020
@@ -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:
Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@arikfr arikfr merged commit 7124bc9 into master Feb 18, 2020
@arikfr arikfr deleted the avoid-timing-out-when-no-timeout-specified branch February 18, 2020 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants