6

Suppose the following:

  • There's a master-detail relationship between two custom objects
  • There are no roll-up summary fields on the master object
  • There are no declarative automations or Apex triggers that update the master based on detail records

In such a scenario, will master records get locked when their detail records are being created or updated or deleted?

1 Answer 1

4

Yes, the database always locks the parents before the children. It does this pre-emptively, even if there are no triggers, workflow rules, flows, etc configured. The documentation does not state that parents are locked conditionally, so we must presume they are always locked. However, given this scenario, a user should never experience a lock timeout for such a lightly configured object, as there is a generous lock delay before a transaction would time out.

4
  • Hmm thanks for that. I wonder if this will be problematic given that we will have up to 150 users all creating or updating details records of the same master object (synchronously)... What do you think?
    – M H
    Commented Mar 14, 2021 at 15:36
  • Assuming this does cause record locking errors, how would you suggest we prevent this from happening?
    – M H
    Commented Mar 14, 2021 at 15:37
  • @MH Eventually, you'll run in to data skew issues. No parent should have more than 10,000 children to avoid problems. If 150 users are all trying to hit the same parent at once, that could cause issues, as the lock delay isn't nearly that long. You would want to redesign your solution to avoid things like this from happening.
    – sfdcfox
    Commented Mar 14, 2021 at 15:52
  • Okay thank you, I might post a separate question about how we can potentially address this issue.
    – M H
    Commented Mar 15, 2021 at 4:13

You must log in to answer this question.

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