-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Two of FrameworksTest gets "undefined class/module Mysql2:: (ArgumentError)" since #39723 #42968
Comments
Thanks for reporting this issue! Looking at those 2 railties tests, they are trying to establish a connection to the database and expecting a connection failure. The exception is:
config:
Both tests are failing because of the conditional check:
I'm going to dig into those 2 tests and see if I can find out what's happening. |
I have looked into this a little more. I can see that we are simulating unhealthy db check by using an incorrect host which is now caught here
This means that an exception is now raised much earlier than what's expected in those tests, as in the exception is now raised on app boot here
In the failing tests, we are not expecting an exception on app boot rather, the app should continue to boot but an exception is now being raised. That code was introduced #40119, @byroot I could not find a way to simulate the connection error based off the new code, any ideas? |
Whoops, apologies for accidentally closing 😅 |
Also... on my machine both tests are now failing on 2.7, 3.0 too, I wonder why CI only caught ruby head. |
Hum, I only had a quick glance (late here) I'll have a closer look tomorrow. But yeah, normally all DB access during boot should rescue any connection errors (this is to ensure you can deploy a fix to production if your DB is down). So either something make it connect from an unexpected code path, or the exception raised is different than the one expected so the protection no longer works. |
In the linked PR I tried to rescue those errors on the AR railtie, but that never worked will have another look tomorrow. There is an issue with parallel testing or the reporter which is not serialising the error from the test correctly so I added
|
Ok it's what I thought, this model is trying to hit the database as soon as it's loaded, it shouldn't. |
Oh, and there was a rescue there: rails/activerecord/lib/active_record/encryption/encryptable_record.rb Lines 124 to 130 in da911da
ConnectionNotEstablished .
|
Thanks Jean, rescuing inside encryptable_record has fixed those tests. 👌 I'm wondering why encryptable_record is loaded at this point because we never seem to be using it -- prob an entirely different issue though. |
I think #43009 should have fixed it. |
Those tests are still failing on main branch and on that PR |
Closing because this was fixed by the commit cabe311 |
Since #39723 has been merged to main branch ,two of FrameworksTest gets "undefined class/module Mysql2:: (ArgumentError)". https://buildkite.com/rails/rails/builds/79982#a24742cc-7394-4ff0-8713-aa64164fd925
Steps to reproduce
Expected behavior
Both of them should finish successfully.
Actual behavior
System configuration
Rails version: main branch
Ruby version:ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin21]
The text was updated successfully, but these errors were encountered: