Destroy All Software is absolutely fantastic and without question worth $29/month. Probably more than any other single resource, DAS provided some of the most foundational ideas that still drive how I think about software.
You can also view a handful of the screencasts for free (no sign in needed). Some of my personal favorites.
This looks interesting, thanks for sharing! Most of the apps I work with run on Heroku, so I'd likely end up reaching for their [High Availability Postgres] feature, but nice to know of an alternative if I'm not on heroku.
That said, I don't think this would serve the intended purpose here. My specific use case was upgrading the postgres version I was using. To do that we introduced a follower, prevented writes to the primary (with the approach summarized in the post), upgraded the follower, and finally promoted the follower to be the new primary. Automatic failover to the follower during this process would likely confuse things.
PostgreSQL upgrades are indeed one of the use cases we have with the gem, the way we do it is:
1. Have app configured to connect to both main and replica.
2. Connect to the rails console and tell the app to stay in read only mode until told otherwise.
3. Disable replication
4. Upgrade main to new PostgreSQL version
5. Tell the app to move back to read-write mode
6. Re-create the replica
This flow helped us do hundreds of PostgreSQL major version upgrades in AWS RDS this quarter when we moved from PG 10 to 12.
And this is just a plus, using the gem during normal operations means that if a Redis or PostgreSQL main explodes for any reason the app keeps serving traffic, albeit in read-only.
> Automatic failover to the follower during this process would likely confuse things.
I believe here the problem is mostly naming. The gem "failover" to read-only mode to a replica, it doesn't promote replicas to main ever. Naming is hard.
Oh that's interesting, thanks for the additional detail! I'm intrigued by what you mean when you say: "tell the app to stay in read only mode until told otherwise". Does that mean use the read-only replica connection during that time? If so, did you have to configure some error handling for that timeframe?
> If so, did you have to configure some error handling for that timeframe?
Since this was an early goal in the project, the controllers are mostly away of the read-only mode already and know how to deal with it is most places.
The approach I shared worked really well for the use case I had (API, read-heavy traffic load, and a solid experience in the mobile apps with retry logic for failed writes), but I certainly wouldn't treat it as a silver bullet.
I would want to test the end-user experience before using it in another app, especially one with very different usage patterns, but for this case it ended up being a great optimization between simplicity and robustness.
Glad I didn't let you down :) In my defense, I did call the segment "Good Idea, Terrible Idea". This solution did end up being much better than what I was initially considering, but sometimes it takes a few bad ideas to get to the good one.
We also discussed the eventual solution I ended up with (which is summarized in this post) in this week's Bike Shed if you want to hear a bit more about it: https://www.bikeshed.fm/264.
'Maybe Haskell' is a fantastic intro to using types and why you might care about them. It's focused in scope and really meant to give you a taste of some functional ideas and a bit of Haskell, and in that effort it does a great job.
Also, you can't beat the price ($0). If nothing else, probably worth browsing through to see if something resonates with you.
Obviously I’m partial because of my history with the book, but having read a bunch of other introductory Haskell materials, this one is still my favorite. It’s my favorite in part because it doesn’t try to teach you the whole language, it just gives you a taste of some of its powerful abstractions, walking through them with just the `Maybe` type. I read the whole thing on a plane flight, and reread it on the flight back.
Hey there, I'm Chris, one of the thoughtbotters who helped build Upcase over the years. We're all super excited to take this step and share Upcase with the world, and I'm more than happy to answer any questions you all might have.
You can also view a handful of the screencasts for free (no sign in needed). Some of my personal favorites.
* https://www.destroyallsoftware.com/screencasts/catalog/funct... * https://www.destroyallsoftware.com/screencasts/catalog/a-com... * https://www.destroyallsoftware.com/talks/boundaries
Also, if podcasts are more your thing, we just had Gary as a guest on the Bike Shed podcast this week: https://www.bikeshed.fm/269.