function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

UNABLE_TO_LOCK_ROW after select... for update

I'm trying to do a process a large batch or records, where I need to do a web service call out for each record.


I'm using an action poller to process the batch a chunk at a time. The first thing I do is select a set of records, using the "for update" keyword. I'm then doing all the callouts together and caching the results before doing all the updates. I'm doing this as I was getting DML errors if I mixed callouts with updates.


When I do go to do the updates, I sometimes get the UNABLE_TO_LOCK_ROW error which is surprising given that the records were selected for update. (I'm not easily able to distill the code used, but have verified that the select with update took place via debug log analysis).


For a test, I changed code to all as above without the callout and everything works just fine... all records are updated with no lock issues. Are there any known issues with callouts affecting the status of previously locked sObjects? Or any known issues where you can do a select for update, yet then still fail with an unable to lock row error?