Skip to main content
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

 
3 answers
  1. Jul 10, 2018, 3:43 AM
    Istead of using 'FOR UPDATE' blindly, I would recommend identifying the root cause of the proble. This will solve this problem for all. Not only that, there might be more underlying architectural problem that might be causing this issue.

    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.
0/9000