"deadlock detected" errors on Rails 2.3.14 site -- Passenger 3.0.9, Ruby 1.9.2
About every 3rd time my app serves a particular update action (two that I've found so far), it bombs out with a "deadlock detected" error.
I haven't been able to trace it to any of our own application code. It seems that the action completes, but then this crash happens as either Rails or Passenger is wrapping it up. (It doesn't happen from just saving records in script/console.)
开发者_如何学编程Here is what comes up in the logs when it happens: https://gist.github.com/1259104
What's going on, and what do I do about it?
(note: have switched to RVM-based Ruby 1.9.2, and issue persists.)
The issue appears to be this:
https://rails.lighthouseapp.com/projects/8994/tickets/5736-connections-not-released-in-rails-3
However, above issue only pertains to Rails 3. We are seeing it in Rails 2.3.14 under Ruby 1.9.2.
The patch to connection_pool.rb given there works for us. That particular file appears to be identical between 2.3.14 and 3.1.0 beta so the patch is likewise the same. We had to patch the gem itself -- doing it by loading the new file/class as part of the Rails app itself didn't do the trick -- but the behavior is the same for us as is being reported there -- instead of deadlocking/running out of db connections, there's a short delay. In conjunction with bumping up the pool size in the production db config in database.yml, this works pretty acceptably, though I do hope for an even better solution.
& Thanks to Alex Caudill for finding this for us!
精彩评论