0

Does multiple asynchronous process like Queueable, future etc running concurrently that are updating same record create row lock issues.

We are facing row lock issues in async transactions that updates same record (same record ID) and we doubt that multiple async transaction that we are doing is the main cause

So, does multiple different async transaction can create row lock issues on same record?

Thanks for the answer in advance!

1
  • By definition - yes; think of two users interacting with the same record on separate computers -- they are separate transactions; async transactions are still transactions.
    – cropredy
    Commented Aug 26, 2022 at 18:52

1 Answer 1

0

Yes, multiple transactions locking the same record can cause locking issues. Also note that locking child records also lock the parent. For example, two asynchronous updates to separate contacts on the same account will block one of the updates until the other completes. Always lock parent records before child records to avoid deadlocks.

2
  • Thanks @sfdcfox! Wanted to mention we have not locked the record ( we haven't used FOR UPDATE), we are only doing DML. Does salesforce have OOB mechanism to lock? Commented Aug 26, 2022 at 13:52
  • @sfdeveloper Initiating a DML operation automatically locks a record and its parent. However, the lock timeout is much smaller if you do this. I strongly recommend locking the records with FOR UPDATE for a better experience.
    – sfdcfox
    Commented Aug 26, 2022 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .