Rafi Loom's blog

Things I find interesting.

I write about whatever catches my attention. Lately that's mostly databases and how backends hold up under load.

Start with the series →

New posts also come out on the RSS feed.

Browse by topic

All topics →

Latest

More from the archive

All articles →

SQLITE_BUSY in WAL Mode With busy_timeout Set: Use BEGIN IMMEDIATE

SQLITE_BUSY: database is locked still fires in WAL mode with busy_timeout set. Why a read-then-write transaction skips the wait, and the fix for each driver.

502 Bad Gateway After Every Deploy: Causes and Fixes

502 Bad Gateway on every deploy? Two causes: the old pod dies mid-request, or the proxy reuses a closed keep-alive socket. Fixes for Kubernetes, ALB and nginx.

The Transactional Outbox Pattern, Explained Simply

How the transactional outbox pattern fixes the dual write problem, with diagrams, Postgres SQL, polling vs CDC, ordering, duplicates and the metric to watch.

Idempotency Keys Explained: How to Make API Retries Safe

What idempotency keys are, why every payments API uses them, and how to build them on the server with Postgres, with diagrams, SQL and common mistakes.

FATAL: sorry, too many clients already: Find Who Holds Them

PostgreSQL 'FATAL: sorry, too many clients already': count who holds the connections, do the pool math, and use PgBouncer without breaking your sessions.

Postgres as a Job Queue: How SKIP LOCKED Works (and When It Breaks)

How to build a reliable job queue in PostgreSQL with FOR UPDATE SKIP LOCKED, with copy-paste SQL, diagrams, and the three ways it breaks in production.