-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Does good_job hold on to advisory locks for finished jobs? #177
Comments
Yikes! Advisory locks should only be held for the duration of each job. If you're seeing the advisory locks being held, that is a bug. I'm fairly certain there are tests that assert that advisory locks are released. The job code that locks it is here: Lines 134 to 148 in cbbb377
And the advisory lock implementation of good_job/lib/good_job/lockable.rb Lines 125 to 135 in cbbb377
|
Ok, thanks, Ben. I'll work on getting a vanilla rails app with a repro and get back to you. |
@bensheldon, I think I've got a pretty straightforward repro in this repo : https://github.com/deepakinseattle/good_job_locks_repro It's a stock Rails 6.0.3.4 app with good_job 1.3.4, configured to preserve job records, and operate in the external execution mode The job itself doesn't do much. The README of the repo has the steps to reproduce the issue, but the TL;DR is
Let me know if I can provide any more details or help in any other way. |
@deepakinseattle Thank you! This is really helpful. You've helped track down one bug related to locked jobs not being unlocked when they are not preserved #178 But I'm curious because your repro is preserving jobs. I'll dig into that next. |
Great, thanks for the update, Ben! |
@deepakinseattle I found the problem: Postgres 12 changes the behavior of CTEs, which GoodJob uses to lock jobs. I have PR #179 that addresses the problem (🎉 ) and I also was able to reproduce with your repo and verify that it is fixed (🎉🎉 ). I can release a patch tomorrow. |
Great news, Ben, thanks so much! I'm happy to try out the patch and report back if it's helpful to you. I really appreciate the engagement and quick turn around! |
@deepakinseattle I just published GoodJob v1.3.5 that includes the change. Hope it fixes the problem! |
Ben, tested it out in that vanilla rails app, and things look great. There are exactly 0 advisory locks after the jobs are finished. Thanks again for the quick turnaround on this. I'd love to buy you a beer or coffee the next time I'm down in the Bay Area (post COVID). |
First off, thanks for this Gem. We've been running it under a light workload in production for a few months now, and it's been terrific.
Second, a question, possibly looking for advise or to help troubleshoot. Our configuration/stack looks like the following
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux-musl]
6.0.3.4
1.3.4
PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11), 64-bit
bundle exec good_job start #1 process, 5 threads
GoodJob.preserve_job_records = true
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> #RAILS_MAX_THREADS is set to 5 as well
Yesterday we began processing a larger volume of jobs (~15K/hour), and a few hours after we started doing that, began to notice the following exception
We bumped the
max_locks_per_transactions
to 1024 (from the default of 64) to buy us some time to troubleshoot.Question : It appears GoodJob seems to keep advisory locks around for finished jobs. Is that expected? I would think that besides just the storage overhead,
preserve_job_records
wouldn't need to hold on to advisory locks.Appendix
In Rails :
Number of locks
Number of connections
The text was updated successfully, but these errors were encountered: