You need to sign in to do that
Don't have an account?
Ranu Jain SFDC
Unable to lock row
I am getting Unabe to Lock Row wile inseting reocrods -
1. I am fetching Inventory reserve records form database by using SOQL query. Inventory reserve has a look up of sales order line. -> So I am gettinh SO Lines from inventory reserves.-> I am updating list of sales order lines
I am gettig unable to lock row while updating sales order line.
I can use "FOR UPDATE" key word while quering Inventory reserve records, but my doubt that error is coming while updating sales order lines , so It will work??
Thanks
Ranu
1. I am fetching Inventory reserve records form database by using SOQL query. Inventory reserve has a look up of sales order line. -> So I am gettinh SO Lines from inventory reserves.-> I am updating list of sales order lines
I am gettig unable to lock row while updating sales order line.
I can use "FOR UPDATE" key word while quering Inventory reserve records, but my doubt that error is coming while updating sales order lines , so It will work??
Thanks
Ranu
ROW_LOCK issue is very common if you have multiple users updating the record at the same time .Or say a batch job is running and is updating a record and same record another trigger or code snippet (usually a future method) is updating.
Using FOR UPDATE keyword helps to achieve a lock a client end to prevent this locking issues .
Here is a small article on sharing model to avoid this granular locking:
https://help.salesforce.com/articleView?id=How-can-I-avoid-getting-lock-errors-in-my-organization-1327109108393&language=en_US&type=1
Regards,
Here are few hints/thoughts:
- When child record is updated (DML) both child and parent is LOCKED. Inventory has lookup(SO Lines).
- When you run your update, identify which all processes are running which is trying to modify SO Lines object.
- When does this problem occures? Always? certain time of day? That will hint towards other running processes.
- How many Inventory records are there? How many SO Lines records are there? What are the chances of other users using the same record update?
- Do you see any Data Skew scenario?
- Using 'FOR UPDATE' for simple reasons might put the system into resource constraint mode because of intentional record lock.