Clearing delayed_jobs queue

869 views
Skip to first unread message

Andrew Matthews

unread,
Aug 29, 2013, 9:17:09 AM8/29/13
to canvas-l...@googlegroups.com
I've had a problem for awhile now with emails not sending from Canvas. I recently got things working in development and staging environments, but I'm still waiting to try production.  In development, once I ran 'ruby script/delayed_job run' everything started working. The issue is it sent out all the emails that had built up in the queue. I don't want this to happen if I have to do the same thing in production. Who knows how many times people have requested a password reset email...

Rather than bombarding users with a bunch of emails they should have gotten long ago, is there a way to clear the delayed_jobs queue before restarting the daemon? Or maybe some other kind of caution against this?

Thanks,

Andrew

Cody Cutrer

unread,
Aug 29, 2013, 10:21:55 AM8/29/13
to canvas-l...@googlegroups.com
Andrew,

There are a few ways to go about this. You can either access the database directly, and run "DELETE FROM delayed_jobs;", or open up script/console and run "Delayed::Job.delete_all". However, both of those are very blunt axes, and will probably delete some jobs that want/need to run. Instead, you should filter by tag: "DELETE FROM delayed_jobs WHERE tag='Message#deliver';" or "Delayed::Job.where(tag: 'Message#deliver').delete_all". Or you can go the slightly-friendlier route, and go to http://<your-canvas-install>/jobs and use the UI. You can select pending jobs there, and delete them.

On a final note, in a production environment you should generally have jobs *always* running, so you should rarely have this situation occur where there is a build up of messages that are no longer current.

Good luck,

Cody Cutrer
Software Engineer
Instructure


--
 
---
You received this message because you are subscribed to the Google Groups "Canvas LMS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andrew Matthews

unread,
Aug 29, 2013, 10:54:35 AM8/29/13
to canvas-l...@googlegroups.com
I went ahead and tried the friendly route with the UI, but it tells me I don't have permission to access that page.  We only have 1 account, of which I'm an admin.  What other permissions do I need?

Cody Cutrer

unread,
Aug 29, 2013, 10:58:53 AM8/29/13
to canvas-l...@googlegroups.com
Andrew,

There are actually two accounts. The default account that presumably you have access to, and one called "Site Admin". I'm not sure how the TurnKey Linux box is set up; it sounds like they gave you a non-site-admin user. In script/console, you can do `Account.site_admin.add_user(User.find(<your canvas user id>))` to make yourself a Site Admin.

Cody Cutrer
Software Engineer
Instructure

Andrew Matthews

unread,
Aug 29, 2013, 11:21:35 AM8/29/13
to canvas-l...@googlegroups.com
And the wool is lifted from my eyes...

It worked.  Thanks!
Reply all
Reply to author
Forward
0 new messages