-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Unclear error when database can't be reached #457
Comments
@clementf This is fantastic research. Thank you for digging into this; documenting what's happening and helping me reproduce it 🙌 I will do some more testing myself; and it's very topical given that I'm currently working on #454. I'm constantly learning new and interesting things that can trip up ActiveRecord during initialization. |
@bensheldon I've taken a look at #454 and indeed that sounds like it could all be related. Let me know if you need anything from my side, I'd be happy to help out. |
@clementf I just released |
That was fast! Thanks a lot @bensheldon 🙌 Going to try this new release. |
Hi @bensheldon, first of all, thanks for the great library 🙌
I've recently been trying good job in a setup where my database connections are quite limited, and I was encountering an error from time to time, which I could not place. Here's the stacktrace:
My setup
After some digging, I found that this is because I'm exhausting the max allowed connections of the pg instance I'm using.
When this happens, the pg adapter will raise an exception. In
job_performer.rb
,Concurrent::Delay
is used@job_query = Concurrent::Delay.new { GoodJob::Execution.queue_string(queue_string) }
If an exception happens during the execution of the block above, the value returned when calling
@job_query.value
will simply be nil, and the exception will be available at@job_query.reason
.This is also reproducible locally by shutting down your postgres db, and starting good_job from the CLI.
Another issue related to that is that if I turn the db back on, it won't recover by itself (while the Notifier will reconnect I believe).
Potential solution
Just poking around locally it seems that something like the following could log the right reason for not being able to connect, as well as handle reconnections:
I haven't read any of the code of this gem before this, so feel free to let me know if this doesn't make sense, or if I'm missing some other bits.
Thanks for reading!
The text was updated successfully, but these errors were encountered: