Code Room
On-callHardoc-g437
Subject Lock contentionLevel Senior–Staff~35 minCommon in Concurrency · Distributed systems interviewsIndustries Technology, Software development

Question

A nightly batch pipeline that processes a queue of jobs from a Postgres `jobs` table used to finish in 20 minutes; since you scaled the workers from 4 to 40 it now takes 3 hours and barely uses CPU. Workers claim jobs with `SELECT ... FROM jobs WHERE status='pending' ORDER BY created_at LIMIT 1 FOR UPDATE`, then update the row. With more workers, throughput went DOWN. `pg_stat_activity` shows most workers blocked on `Lock`. Triage and mitigate.

What a strong answer looks like

Stop the bleeding first (mitigate), then form hypotheses from real signals. Separate root cause from symptom, communicate status as you go, and close with what prevents a repeat.

Diagram & narrate the incident
Loading whiteboard…
Run or narrate your approach, then ask the coach.