Lock Contention

A situation in which one process tries to acquire a lock held by another process.

Paralell processing enables faster loading of data but can cause lock contention on records.

When we insert AccountTeam record, Account will be locked. When two AccountTeam records for the same account is getting processed in two different batches, we will face Lock Contention.

Lock Contention can be avoided by
1. Organizing data in batches. Child records with same Parent Id should be in the same batch.
2. Using serial mode.

The following operations are likely to cause lock contention and necessitate using serial mode:

  • Creating new users
  • Updating ownership for records with private sharing
  • Updating user roles
  • Updating territory hierarchies

If you encounter errors related to these operations, create a separate job to process the data in serial mode.

Leave a Reply