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

Add a job timeout configuration to time out jobs that have run too long #19

Closed
bensheldon opened this issue Mar 9, 2020 · 1 comment

Comments

@bensheldon
Copy link
Owner

Timeouts in Ruby are rather dangerous so this should be given some thought as it's probably unavoidable to entirely avoid the risk of corruption of shared state.

Concurrent Ruby has Cancellations but it seems impossible to safely cancel a uncontrolled code (e.g. active job): http://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/Cancellation.html

I think the biggest danger around an ActiveJob is corrupting the ActiveRecord database pool. So adding a timeout solely around the ActiveJob code, but within the executor wrap might work. Even better would be running it within an ActiveJob around hook so that it could potentially be caught by ActiveJob's rescue_from/retry_on handlers.

@bensheldon
Copy link
Owner Author

Killing threads is not something actually supported by Concurrent Ruby because of the difficulty in doing it safely with user code. Added instructions for configuring timeouts in user code: #39

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

1 participant