activerecord-import: Using activerecord-import with Rails 6.1.0.rc1 results in SystemStackError: stack level too deep
Using activerecord-import with Rails 6.1.0.rc1 results in SystemStackError: stack level too deep any time we attempt to establish our own connection.
The line in question is:
activerecord-import-1.0.7/lib/activerecord-import/import.rb:250:in `establish_connection'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 22 (12 by maintainers)
Commits related to this issue
- Load connection pool when importing, rather than on every connection This resolves an error in Rails 6.1 which was causing our application to exceed the limits of the stack, as AR Import looped betwee... — committed to codeodor/activerecord-import by codeodor 4 years ago
- Limit patching AR::Base to the adapter that needs it Fixes #715. Only SeamlessDatabasePool seems to need the patch, so allow other adapters to run without it. — committed to codeodor/activerecord-import by codeodor 3 years ago
Whew man, I’m glad you were able to get to the bottom of this one. I feel bad this negatively impacted your tests. I wonder if mocking libraries are working on this issue with prepended modules?
@codeodor after finally doing some research into this, I think I discovered the root cause of the issue. It seems like your code or another gem in your project is using
alias_method
on AR::Base#establish_connection. Can you confirm if this is happening?See:
Hey, to clarify: I didn’t have an issue directly with an attempted import. I didn’t even try it. The problem was that AR::Import code was causing my app to have this error when I made my own calls to AR::Base#establish_connection.
I’m gonna try to give an example app later this week, but I am a little swamped so I apologize in advance for the delay.
What’s weird is the PR that introduced the
prepend
was fixing a stack level too deep error: https://github.com/zdennis/activerecord-import/issues/647 😅Hey thanks for all digging into this! I’ll have to see look this over a little bit, but I think your proposed solution seems very reasonable 👍