-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
ActiveRecord connections leaking when referencing an undefined local in a class method #499
Comments
I'm not sure what to tell you besides "don't do that"? Why are you calling undefined locals/methods in the first place? |
I was not doing it intentionally :) In my specific case, a typo in my model was triggering connection pool exhaustion in my test suite. Certainly, my solution at the time was to correct the typo. Regardless, It's not expected behavior and so my thought was that it could trip someone else up as well, hence the report. Would it better to put this in the gotchas page? |
Sure? Seems like the real solution is to fix the bugs in your code 😉 |
This does seem to be a bug with the I have more debugging available at nullstyle/celluloid-ar-leaker#1 |
I have tracked things further. |
This is incorrect. The |
This is a scary backtrace.
|
What? You don't think calling |
@mperham or on an exception caused by AR |
This bug is independent of the @nullstyle can you confirm that this branch fixes the problem? https://github.com/celluloid/celluloid/compare/no-crash-exceptions |
This is backtrace when running in pooled-mode.
|
I have pushed a new PR: nullstyle/celluloid-ar-leaker#2 |
@halorgium your branch at https://github.com/celluloid/celluloid/compare/no-crash-exceptions does indeed fix the problem for me :) Thanks so much for digging into it! |
@nullstyle you'll still have problems with pools, because that is a different code path. |
@tarcieri it turns out that if a Call is aborted via an AR exception (one which calls into |
Seems like this is an OK commit: halorgium/rails@8599bf2 |
A simpler repro: https://gist.github.com/halorgium/2778b0db4286b907343a |
Closing as stale. If you are still interested in this issue, please reopen it. |
I couldn't easily decide if this is a celluloid or an activerecord issue, so I'm deciding to post this here first. Apologies if this would better be submitted to activerecord's repo.
Repro code: https://github.com/nullstyle/celluloid-ar-leaker
Overview
When referencing an undefined local variable or calling an undefined method within
a class method defined on an ActiveRecord::Base subclass in the calling context of a
Celluloid::Pool, ActiveRecord connection objects are not properly returned to the
connection pool.
Notes:
subclass. The following does not trigger the leak: Calling an instance method
on an AR::Base subclass, calling a class method on a non-AR::Base subclass,
calling a module method.
local. The following does not trigger the leak: Referencing an undefined constant,
raising a NameError directly, raising any other Exception.
The text was updated successfully, but these errors were encountered: