# How do you handle UNABLE_TO_LOCK_ROW errors triggered during high-volume updates on parent records?

**Topic:** Apex Trigger · **Difficulty:** Hard · **Asked at:** Salesforce, Amazon, Uber, Deloitte · **Tags:** apex-trigger, trigger, record-locking, performance

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-you-handle-unable-to-lock-row-errors-triggered-during-high-volume-updates-on-parent-records

## Answer

`UNABLE_TO_LOCK_ROW` occurs when concurrent transactions try to update the same record (often a parent that is locked by child inserts/roll-ups).

**Mitigations:**
- Reduce parallelism: use serial mode in Bulk API, smaller batch sizes
- Sort data by parent Id so transactions lock rows in the same order
- Avoid data skew (more than ~10,000 children under one parent)
- Use `FOR UPDATE` in short transactions deliberately
- Retry using `Database.update` with error inspection, or re-enqueue via Queueable
- Avoid unnecessary parent updates (update only when values change)

---
Source: ForceChallenges · last updated 2026-10-21
