All the Things I Thought I Couldn't Do
summary
Implements granular connection swapping for Active Record by moving role tracking into a shard→pool_config map and adding a pool manager, plus a public API like connected_to_many to swap multiple connections without nested blocks. Ships to production at GitHub (15 databases), reduces unnecessary primary queries, and lands in rails 6.1 as opt‑in via legacy_connection_handling. Shows concrete bugs found (prevent_writes and multiple abstract classes), fixes made, and that the feature actually works under real load.
AI-written summary · about
chapters (10)
- 0:00Start
- 28:54Why a Rails Application Might Need Multiple Databases
- 30:27Automatic Switcher
- 31:51Manual Switching
- 32:27Brief History of Connection Management
- 39:46Nesting Calls
- 54:04Why We Think Our Pairing Is Successful
- 1:03:05Learn a Foreign Language
- 1:03:54Measure Progress
- 1:05:16Measuring Progress
related talks
45mTechnically, a Talk
30mUsing Multiple Databases with Active Record
41mKeynote: Technically, a Talk
20mSafely Decomposing a Highly Available Rails App
43mThe Magic of Rails
34mRefactoring Rails
24mFrom Expensive Queries to Smart Caching: A DBA’s Guide for Rails
39mPostgres & Rails 6 Multi-DB: Pitfalls, Patterns, Performance
