Salesforce Masking: Resolving Row_Lock Issues Using the Sorting Feature (KBA11031)
KBA
KBA#Issue
When executing a masking job with the default configuration and parallel batch processing, you can encounter ROW_LOCK issues which lead to a large number of unmasked records.
ROW_LOCK issues are seen only when:
- There is a 1:M relationship between Parent and Child objects.
- And, when M is a large number of records that can spill across N number of batches being executed in parallel by Salesforce.
For example, when updating a record in a child object (such as Opportunity), the system attempts to acquire a lock on its parent object (such as Account) record. Therefore, if two batches are getting masked in parallel and referring to the same parent record, one of these batches fails to acquire the lock. Although Salesforce attempts to acquire the lock multiple times, after a certain number of attempts, it eventually gives up, resulting in a ROW_LOCK error for each failed record.
Resolution
To mitigate this challenge, an option is provided to allow you to sort the rows in the object being masked based on one of its fields which references the parent record. This ensures that most records with the same parent record remain in the same batch. Consequently, when updating records, the likelihood of encountering ROW_LOCK errors is significantly reduced if not eliminated.
Considerations
- If you sort on a non-indexed field it can lead to high latency for read operations.
- Sorting does not always guarantee 100% masking in the first execution. It ensures fewer executions.
- In the case of not being able to mask 100% and encountering row_lock issues even after sorting. You can attempt serial batch processing.
It is slower and should only be used when dealing with a limited number of records.
Related Articles
The following articles may provide more information or related information to this article:
- N/A