Entity locked during microflow execution

0
I have a process that does some work on 40,000 records or so. It loops through a list of these objects (subcontractors).    It takes about 30 minutes for this microflow to execute. I didn't commit these items originally and just added them to a list. Then at the end of the MF I committed the list.    When anyone used the app and needed to access one of the objects in this list, the microflow they were executing was frozen until this long process was completed.   So I changed the long running microflow to commit INSIDE the loop. It's not efficient, but that way the changes were immediate and I didnt have an object with a pending change sitting there for 30 minutes. However, after this change, users' microflows that retrieve a single record are STILL frozen until the long running MF executes.   Is there something that prevents an object from being retrieved in a microflow, if that object exists in a list (regardless if changes are made) in a Microflow that's still executing?
asked
1 answers
1

As you are updating the record inside a transaction the lock might be in place, see: https://hevodata.com/learn/postgresql-locks/#What_is_PostgreSQL_Locks

To prevent this you can change your microfow to retireve smaller batches, commit the batch outside the loop for performance and before retrieving the next batch use the EndTransaction java action from the Community Commons module so that the current transaction is ended and a new transaction is started.

This will improve perfromance and make sure that records aren't locked for too long a time.

answered