You need to sign in to do that
Don't have an account?
Stephanie Kellish
Scheduled Flows: prevent locked parent records/parallel batches
In our scheduled daily flow, which runs every morning, we fairly regularly get an error that the parent object ("Parent") of the object the flow is running on and updating ("Child") causes an UNABLE_TO_LOCK_ROW error, specifically referencing that Parent records are being locked multiple times and throwing an error. This seems to be because Child records that have the same parent are running/updating in parallel, in different batches, which causes the lock on the parent to be tripped twice (causing the error). There are no conflicting Apex jobs or other scheduled flows scheduled anywhere near this time period, and it is scheduled at a time where we do not have employees working.
I would like to know if there is any way to either
1) run the batches in a scheduled Flow serially, instead of in parallel, or
2) ensure that all child records with the same parent record are included in the same batch, so that the lock does not get placed twice and cause an error.
I would like to know if there is any way to either
1) run the batches in a scheduled Flow serially, instead of in parallel, or
2) ensure that all child records with the same parent record are included in the same batch, so that the lock does not get placed twice and cause an error.
Greetings!
I don't think we can run the batches in the scheduled flow serially as we can't change it from our end as it is flow.
But,you can actually process all the child records first based on the parent record to avoid the Row lock errors.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
I had the similar issue. I have a sceduled job running on a daily basis which set either Active or Inactive based on some Salesforce System fields (Service Contract Line Items). In my Original Flow Conditions I accepted two different conditions eigther set as Active or set as Inactive. The entry criteria was followed by a decision element telling the flow to set the record either as Active or Inactive.
I solved the Record Lock problem when I decided to Clone my flow and in the entry criteria only accepting one scenario and of course scedulded these flow to run on different time slots.