Skip to content

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

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

Open
Recodify opened this issue Oct 4, 2022 · 1 comment

Comments

@Recodify
Copy link

Recodify commented Oct 4, 2022

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
Copy link

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.

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

No branches or pull requests

2 participants