Loading

Salesforce DML: Order of Execution When a Row Lock Error Occurs in Master-Detail Relationships

게시 일자: Jun 2, 2026
상세 설명

In Salesforce, when two concurrent database transactions attempt to perform DML (Data Manipulation Language) operations on related records in a Master-Detail relationship, a row lock conflict can occur. When a parent record (the Master) is locked by one transaction, a second transaction attempting a DML operation on a related child record (the Detail) must wait up to 10 seconds for the lock to be released. This article explains the exact order of execution that occurs during a row lock scenario, and what happens when the lock is not released in time.

솔루션

Example Scenario: Object A (Master) and Object B (Detail)

Object A and Object B have a Master-Detail relationship. Object A is the Master and Object B is the Detail.

  1. Record A is locked by Transaction 1.
  2. Transaction 2 begins a new DML operation on Record B.
  3. Salesforce loads Record B from the database (or initializes it for an upsert/insert operation).
  4. Salesforce executes order-of-execution steps 1–15 for Record B Order of execution (triggers, validation rules, workflow rules, etc.).
  5. At step 16, Salesforce internally attempts to acquire a lock on the parent Record A. Because Record A is already locked by Transaction 1, the lock cannot be placed immediately.
  6. Record B waits up to 10 seconds for Salesforce to obtain a lock on Record A.

If the lock on Record A is released within 10 seconds: Salesforce acquires the lock on Record A and proceeds with order-of-execution steps 1–15 for Record A.


If the lock on Record A is NOT released within 10 seconds: Salesforce throws the "Unable to lock row — Record currently unavailable" error. The DML operation for Record B is rolled back to the previous savepoint (the state before the update or insert was attempted). Because an exclusive lock on Record A was never obtained, Order of execution steps 1–15 for Record A are also not executed.

Knowledge 기사 번호

000386567

 
로드 중
Salesforce Help | Article