Ruby on Rails: Connection Resilience and Performance Wins
Today we're diving into some solid reliability improvements for Rails applications, with Clay Harmon's MySQL connection error handling fix taking center stage, plus a nice performance boost from Shinichi Maeshima's number formatting optimization. We also get a quick CI infrastructure update courtesy of neumayr.
Duration: PT3M48S
Transcript
Hey there, Rails developers! Welcome back to another episode of Ruby on Rails. I'm your host, and wow, do we have some great improvements to talk about today, March 26th, 2026. You know those moments when your app just works a little bit better, and your users never even know something was fixed behind the scenes? That's exactly what we're celebrating today.
So let's dive right into the good stuff. Clay Harmon just landed a really thoughtful fix that's going to make MySQL connections way more resilient. Here's the story - you know how sometimes your database connection gets reset, maybe after sitting idle for too long, or your proxy decides to restart? Well, when MySQL reconnects, it might forget which database it was supposed to be using. Then boom - error 1046: "No database selected."
Now here's the clever part of Clay's fix. Before this change, Rails would treat this as a statement error and just give up. But Clay realized this is really a connection problem, not a query problem. So now Rails classifies this error the same way it handles other connection issues, which means the built-in retry logic kicks in automatically. Your app reconnects, remembers which database to use, and tries the query again. It's one of those fixes that makes your application more robust without you having to change a single line of your own code.
The implementation is beautifully simple too - just a couple lines in the MySQL adapter to properly categorize that error code. Plus Clay included solid tests to make sure this behavior sticks around. Jean Boussier merged this one in, and honestly, this is the kind of attention to detail that makes Rails such a joy to work with.
Speaking of making things work better, Shinichi Maeshima found and fixed a sneaky performance issue with number formatting. You know the `number_to_delimited` helper that puts commas in your big numbers? Well, there was some optimization work done a while back that made it way faster, but due to a default value quirk, most apps were still using the slower path. Shinichi spotted this and made the fast behavior the default. It's a small change in the code but potentially a nice performance bump for any app that formats a lot of numbers.
And hey, neumayr kept our CI infrastructure fresh by bumping the GitHub Actions upload-artifact action to version 7. It might seem small, but staying current with these tools means better performance and security for everyone building Rails apps.
What I love about today's commits is they represent the best of open source collaboration. Clay noticed a real-world problem with database connections and didn't just work around it - he dug in and made Rails better for everyone. Shinichi caught an unintended performance regression and fixed it. These aren't flashy new features, but they're the kind of solid improvements that make our apps more reliable every single day.
Today's Focus time - here's what you can do with this knowledge. First, if you're running MySQL with Rails and you've been seeing those "No database selected" errors occasionally, this fix should make them disappear in your next Rails update. Second, if you're doing heavy number formatting in your app, you might see a nice little performance boost when you upgrade. And finally, take a moment to appreciate how these contributors found edge cases and took the time to fix them properly.
That's a wrap for today's episode! Keep building amazing things, keep contributing back when you can, and remember - every small improvement makes the entire Rails ecosystem stronger. I'll catch you tomorrow with more Rails goodness. Happy coding, everyone!