Skip to content
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

active_record: fix for MySQL on connection error #327

Merged
merged 1 commit into from
Dec 20, 2018
Merged

active_record: fix for MySQL on connection error #327

merged 1 commit into from
Dec 20, 2018

Conversation

mssola
Copy link
Contributor

@mssola mssola commented Dec 14, 2018

Signed-off-by: Miquel Sabaté Solà [email protected]

@mssola
Copy link
Contributor Author

mssola commented Dec 14, 2018

Basically, when upgrading my application to Rails 5, I had the issue being mentioned here. The workaround was to add an initializer that manually serialized the parameters.

That being said, in MySQL, this involves a connection attempt (for some reason this is not the case for PostgreSQL). This was all fine for me, but recently I had to run some tasks which specifically forbid having the database around (kind of a weird scenario, I know 😅). These tasks failed miserably on MySQL because the database was purposely turned off (again, same scenario on PostgreSQL support was fine).

This PR rescues this case (connection not being established), ignoring the failure and logging a warning (as it is done when the database was not found). I've tried to use higher-level exceptions (that is, from ActiveRecord and such), but it all seemed to fail on MySQL. The only thing that worked is to rescue this low-level error from the MySQL backend.

I don't know if there's a better solution for this. If so, I'll gladly update this PR in whatever direction it is decided.

@pokonski
Copy link
Member

Hey @mssola, yeah this will do since we already catch related errors as you noticed in the code.

Thanks for this!

@pokonski pokonski merged commit 0a521d4 into public-activity:1-6-stable Dec 20, 2018
@mssola mssola deleted the mysql-fix branch December 20, 2018 10:14
@mssola
Copy link
Contributor Author

mssola commented Dec 20, 2018

@pokonski thanks a lot for this 😄

One question though: because of this issue, we had to fork this gem and release a patch-level release that included this fix. Would it be possible from your side to release a patch-level release that includes this fix (as you did, for example, for the 1.6.2 release). This way I'll be able to get rid off this fork 😁

@pokonski
Copy link
Member

pokonski commented Dec 20, 2018

@mssola Funny you should ask, this is now released as 1.6.3 💥 😁

@mssola
Copy link
Contributor Author

mssola commented Dec 20, 2018

Nice! Thanks 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants