Unable to Lock Row error in Salesforce
Автор: Programming Made Easy
Загружено: 2026-03-05
Просмотров: 30
Описание:
he UNABLE_TO_LOCK_ROW error in Salesforce occurs when a transaction cannot obtain exclusive access to a record because another process is already locking it. This typically happens during concurrent operations like bulk updates, flows, or Apex triggers, especially when multiple processes attempt to modify related records—particularly parent records in master-detail relationships.
Key Causes:
Record contention: Multiple processes (e.g., batch jobs, flows, triggers) try to update the same parent record simultaneously.
Parent record locking: When child records are updated, the parent record is locked for the duration of the transaction (up to 10 seconds).
Data skew: A single parent record has too many child records, increasing the likelihood of lock conflicts.
Sharing rule recalculations: In private sharing models, updating child records can trigger sharing recalculations, prolonging locks.
Parallel test execution: In Apex tests, parallel execution can cause race conditions due to automatic rollback between test methods.
Common Solutions:
Use FOR UPDATE in SOQL queries to explicitly lock records at the start of a transaction, preventing other processes from modifying them until the transaction completes.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: