4

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?

3

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 Mar 14 at 15:36
  • Assuming this does cause record locking errors, how would you suggest we prevent this from happening? – M H Mar 14 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 Mar 14 at 15:52
  • Okay thank you, I might post a separate question about how we can potentially address this issue. – M H Mar 15 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.