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

Set default query execution time limit to unlimited #4626

Merged
merged 2 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions redash/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@
os.environ.get("REDASH_STATIC_ASSETS_PATH", "../client/dist/")
)

# Time limit for scheduled queries. Set this to -1 to execute without a time limit.
SCHEDULED_QUERY_TIME_LIMIT = int(
os.environ.get("REDASH_SCHEDULED_QUERY_TIME_LIMIT", 3600)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I look at the existing implementation, I wonder if we should use -1 as the default to remain backward compatible?

Copy link
Member

@jezdez jezdez Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
+0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jezdez you have queries running longer than an hour?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if currently, but it happened in the past. Granted, we're probably not the average user group.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that an hour default value is definitely reasonable for most cases. I just wonder if we should cause issues for any existing deployments :\

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think I change my initial response to +0, since this is a settings we can set it to a larger value before deploy. IOW don't consider our use case as a blocker.

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 don't see any value in imposing a default limit. As long as it's configurable, a -1 sounds good.

)

# Time limit for adhoc queries. Set this to -1 to execute without a time limit.
ADHOC_QUERY_TIME_LIMIT = int(os.environ.get("REDASH_ADHOC_QUERY_TIME_LIMIT", 3600))

JOB_EXPIRY_TIME = int(os.environ.get("REDASH_JOB_EXPIRY_TIME", 3600 * 12))
JOB_DEFAULT_FAILURE_TTL = int(
os.environ.get("REDASH_JOB_DEFAULT_FAILURE_TTL", 7 * 24 * 60 * 60)
Expand Down
16 changes: 5 additions & 11 deletions redash/settings/dynamic_settings.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import os
from .helpers import int_or_none


# Replace this method with your own implementation in case you want to limit the time limit on certain queries or users.
def query_time_limit(is_scheduled, user_id, org_id):
scheduled_time_limit = int_or_none(
os.environ.get("REDASH_SCHEDULED_QUERY_TIME_LIMIT", None)
)
adhoc_time_limit = int_or_none(
os.environ.get("REDASH_ADHOC_QUERY_TIME_LIMIT", None)
)
from redash import settings

return scheduled_time_limit if is_scheduled else adhoc_time_limit
if is_scheduled:
return settings.SCHEDULED_QUERY_TIME_LIMIT
else:
return settings.ADHOC_QUERY_TIME_LIMIT


def periodic_jobs():
Expand Down