Loading

Order of execution in Row lock seen in Master-Detail relationship

Publiceringsdatum: Oct 13, 2022
Beskrivning
When a parent record is locked in a transaction, the second transaction seeing the 'Unable to lock row error' will not execute the triggers, validation rules or workflow rules for the parent record.
Lösning

Example of Order of Execution

Object A and Object B have master detail relationship. A being the Master and B the detail.

1. Record A is locked in a Transaction
2. Record B starts a new DML operation.  
3. This is when the system loads the original Record B from the database or initializes the record for an upsert or insert statement.
  • Steps from 1-15 are executed for record B mentioned in Order of execution
  • At step 16,  Internally system checks if it can place lock on the Parent Record A ; but because Record A is already locked, we cannot place another lock. 
4. Record B waits for a maximum of 10 seconds for system to obtain lock over Record A.
  • If lock on Record A is released within the 10 seconds, system gets to place lock on Record A and proceed with steps 1 for Record A. 
  • If Record A process is still underway beyond 10 seconds, User sees the row lock error. At this point the DML operation is rolled back to the previous savepoint (Previous state before the record update/Insert). As the lock is exclusively not obtained on Record A, steps 1-15 in Order of execution are not executed for Record A

There's overview of various scenarios when Row lock errors are seen. 
Knowledge-artikelnummer

000386567

 
Laddar
Salesforce Help | Article