d4software / QueryTree

Data reporting and visualization for your app
http://querytreeapp.com
GNU Lesser General Public License v3.0
335 stars 121 forks source link

Caution using this in production - scheduled emails creates many long running queries #141

Open Recodify opened 1 year ago

Recodify commented 1 year ago

I created a simple report based on a view. The view normally takes around 13secs with a select * from. When an email report is schedule, hangfire retries the job in the event of an exception. My db ground to a halt. Looking at the processes, I see lots of queries being run (presumably by hangfire).

image

I'm currently investigating the root cause of the email exception and also why the queries aren't being terminated on exception, but in the meantime, BE CAREFUL SCHEDULING AN EMAIL IN PRODUCTION

harpsicord86 commented 1 year ago

Hi @Recodify,

I think I may know what this is... Hangfire is designed to automatically retry the recurring job up to 10 times if it fails. You can change this by adding the following code to the top of the BuildScheduledEmail method of the ScheduledEmailManager:

[AutomaticRetry(Attempts = 5)] [DisableConcurrentExecution(10 * 60)] public void BuildScheduledEmail(string queryName, string editUrl, string recipients, int queryId) This sets the retries to 5 and also turns off any jobs of the same type running concurrently (with a timeout of 10 minutes). Let me know if this works for you.