Resolve row-level lock contention from SELECT FOR UPDATE
One session held a row with SELECT ... FOR UPDATE and a second sat behind it for 1.5 seconds on a transactionid wait. No table lock was involved, which is why the usual table-level lock queries show nothing.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
Row locks do not appear as a lock on the table. The waiting session shows a wait_event_type of Lock and a wait_event of transactionid, and the thing it is waiting for is another transaction finishing, not a relation. Table-level lock dashboards stay green while the application queues up behind a single row.
settlement_run takes SELECT ... FOR UPDATE on a row in waybill_settlements and then does slow work before committing. payout_api wants the same row and blocks.
Simple terms
A lock on a single row does not show up as a lock on the table, which is why your table-level lock dashboard stays green while the app crawls. The waiting session is really waiting on another transaction to finish: its wait type is "Lock" on a "transactionid". Once you know to look there, you can see one session stuck behind another that grabbed the row with SELECT ... FOR UPDATE and is slow to commit.
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
Card required. Cancel before day 7 and you are not charged.
More in this category
Other Locking & concurrency runbooks
Neighbouring incidents that share the same diagnostic surface.
Connected
How this connects to the rest of the library
A live view of this page's real cross-references, what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.