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

Recommended method to set up job execution timeout #1090

Open
francois-ferrandis opened this issue Sep 26, 2023 · 1 comment
Open

Recommended method to set up job execution timeout #1090

francois-ferrandis opened this issue Sep 26, 2023 · 1 comment

Comments

@francois-ferrandis
Copy link
Contributor

Hello there! 👋

First of all, thank you for this great gem, it solves many problems that we have and it is wonderfully documented. 😍

This issue is kind of a followup to #19.

My team and I were wondering whether it is dangerous to use the Timeout.timeout method as demonstrated in README.md. We have come across several articles explaining that using this method puts you at risk:

So we got curious as to why there is no mention of the risks in the README even though you seem to know about them (#19)! Is there something that would make you consider the risks here are acceptable? We would love to have your input on this 👂

I just took a peek at other librairies that offer a timeout feature:

Most librairies don't offer that feature, for good reasons I presume.

Thank you so much for your time! 🙏

@bensheldon
Copy link
Owner

@francois-ferrandis great question!

Yes, it is dangerous to use Timeout.timeout in GoodJob. That's because GoodJob, like Puma, is multithreaded and Thread.raise/kill can leave shared resources (like Active Record database connection pool) in uncertain states.

we got curious as to why there is no mention of the risks in the README

Simply overlooked on my part. I think I wrote that in the very early days of GoodJob and that section is inadequate today. I think my thinking there was that if your code is safe to be wrapped in a Timeout.timeout then it's safe for GoodJob too... which is true, but doesn't mention that it's very, very, very likely that your code isn't safe to do that.

I do think the Readme should mention the dangers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Inbox
Development

No branches or pull requests

2 participants