Rails Connection Pool Exhaustion: Fixing ActiveRecord::ConnectionTimeoutError
ActiveRecord::
Deep dives on the systems that have to stay correct when things go wrong: background jobs, Postgres, and AI backends. Each one is grounded in open-source code I build and ship.
Sidekiq runs jobs at least once, so duplicates happen. The 5 windows where a job re-runs — and how to stop double-charges with idempotent workers.
At-least-once delivery · the retry loop
ActiveRecord::
Why Postgres kills one transaction on a deadlock, how to read the 40P01 log, the lock-ordering rule that prevents it, and the SQL to diagnose it live.
Why read-modify-write leaks race conditions in Rails, how SELECT FOR UPDATE blocks, and when to use advisory locks — with real production code.
Solid Queue vs Sidekiq isn't a throughput threshold — it's about where your complexity lives and whether your database can absorb the queue. A decision framework.
Slow job? It either waited in the queue or ran slowly. Measure which with Sidekiq::
Solid Queue runs jobs on Postgres, not Redis. How the dispatcher, SKIP LOCKED claims, and polling actually work under the hood — and the trade-offs.
Open-source systems and experiments behind the ideas I write about.
Support queues fill with unclassified tickets, but moving triage to an LLM puts a slow, non-deterministic, failure-prone call in the request path.
Ruby on Rails · PostgreSQL · Sidekiq · Redis · OpenAI API · Structured Outputs
International-student career data lives across slow, rate-limited third-party services; fetching it inline would make the product slow and fragile.
Ruby on Rails · PostgreSQL · Sidekiq · AWS
LLM lead scoring is asynchronous, but users expect results to appear live — without adding a single-page app to get real-time UI.
Ruby on Rails · Rails 8 · Solid Queue · Hotwire · Turbo Streams · ActionCable · OpenRouter