System.DmlException: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this recordData skew. Your top Account has 50,000 Contacts. Two users try to update the same parent field simultaneously. Lock contention brings your org to a halt. The whole system freezes waiting for a lock that never releases.
2,400 developers search for this error every month. It's the silent killer of enterprise Salesforce orgs—data skew accumulates over years until one day, everything locks up.
Data skew occurs when a single parent record has more than 10,000 child records. Salesforce's locking mechanism can't handle concurrent updates to the same parent when thousands of children are involved. The result: lock timeouts, failed updates, and angry users.
Account-Contact
10,000+
Parent record lock contention
Account-Opportunity
10,000+
Sharing recalculation timeout
Custom Object-Parent
10,000+
Query performance degradation
Average downtime from lock contention incidents
Lock wait timeout before the error is thrown
Tools that detect data skew before deployment
Explicit locking on a parent record with 50,000 children. A recipe for lock contention disaster.
// ❌ BAD: Updating parent record when children have data skew
// Top Account has 50,000+ Contacts (data skew)
public void updateAccountIndustry(List<Contact> contacts) {
Set<Id> accountIds = new Set<Id>();
for (Contact c : contacts) {
accountIds.add(c.AccountId);
}
// Lock contention on Account with 50,000 children
List<Account> accounts = [
SELECT Id, Industry
FROM Account
WHERE Id IN :accountIds
FOR UPDATE // ❌ Lock wait timeout!
];
for (Account acc : accounts) {
acc.Industry = 'Technology';
}
update accounts;
}Why this is dangerous: When multiple users or processes try to lock the same skewed parent record, Salesforce can't acquire the lock within the 5-10 second timeout. The transaction fails, and if this is in a trigger, every record in the batch fails.
Jataka's data skew analyzer detects parent records with excessive child counts and warns before lock contention occurs.
Data Skew Detected
Parent record has excessive child records. Lock contention risk high.
Recommendation: Remove FOR UPDATE clause or use async processing to avoid concurrent lock attempts on this skewed parent record.
Avoid explicit locking on skewed parent records. Use selective updates or async processing.
// ✅ GOOD: Avoid locking skewed parent records
// Use selective updates without parent locking
public void updateAccountIndustry(List<Contact> contacts) {
Set<Id> accountIds = new Set<Id>();
for (Contact c : contacts) {
accountIds.add(c.AccountId);
}
// Update without explicit lock
List<Account> accounts = [
SELECT Id, Industry
FROM Account
WHERE Id IN :accountIds
// No FOR UPDATE - let Salesforce handle locking
];
// Batch updates to reduce contention
Database.update(accounts, false); // Partial success allowed
// Or: Use async processing for high-volume updates
// System.enqueueJob(new AccountUpdateJob(accounts));
}Result: No explicit lock on parent. Updates proceed without contention. Partial success mode allows individual record failures without blocking the entire batch.
Detect data skew before it locks
Book a demo and watch Jataka analyze your data model for skew. Your org stays fast under load.