Newer Version Available
Organize Data to Minimize Lock Contention
The Salesforce Platform uses locks to ensure referential integrity of its data — similar to any application built on a relational database. Most transactional database operations only hold these locks for a short time, and the volume isn’t significant enough to cause contention. However, when dealing with large data volume objects or processing large jobs, record locks and contention can become an issue.
Although Bulk API 2.0 conceals the notion of a “batch”, Bulk API 2.0 jobs are still technically composed of batches. Batches are managed tacitly by Bulk API 2.0’s automated batch management functionality.
Be Aware of Operations that Increase Lock Contention with Bulk API 2.0
These operations are likely to cause lock contention:
- Creating users
- Updating ownership for records with private sharing
- Updating user roles
- Updating territory hierarchies
Organize Bulk API 2.0 Data to Minimize Lock Contention
For large data loads, sort main records based on their parent record to avoid having different child records (with the same parent) in different jobs.
- Example: When an AccountTeamMember record is created or updated, the corresponding Account for this record is locked during the transaction. If you upload different jobs that include AccountTeamMember records, and they all contain references to the same account, they all try to lock the same account, and it's likely that you experience a lock timeout. When working with AccountTeamMember records, organize your CSV data files by AccountId.
Bulk API 2.0 Automatic Record Lock Handling (PILOT)
Based on a popular suggestion in the Salesforce Idea Exchange, we're now offering a pilot feature that automatically checks for Bulk API 2.0 locking errors and handles them to increase the likelihood of successful job completion.
If you’re interested in a pilot to help you automatically minimize lock contention, contact your account team and ask to be nominated for the "Bulk API 2.0 Automatic Record Lock Handling Pilot".