Hello,

is there a way to prevent (i.e. kill) runaway queries?

i.e. set a maximum timeout after which a query will be terminated?

I assume that there is no way of knowing when the target data source (I am talking specifically about postgres is under heavy load and terminate the corresponding query causing the load?)

Thanks.

Yes. We do this with hosted Redash. Queries are cutoff at five minutes, two hours, or twelve hours depending on billing tier. You just add a timeout to the code that enqueues jobs.

So timeouts are not supported in the open source version, right?

Yes, they are totally supported in open source! I don’t have the celery code in front of me right now but here’s the relevant line on the current tip of master.

Does this correspond to REDASH_JOB_EXPIRY_TIME env var?

No, the environment variables are:

REDASH_SCHEDULED_QUERY_TIME_LIMIT

and

REDASH_ADHOC_QUERY_TIME_LIMIT

And if you want to use fancy logic, you can implement your own query_time_limit method as described in the docstring here.

The REDASH_JOB_EXPIRY_TIME env var is the default TTL for a redis job, which is unrelated.