Flow and concurrency control
Image Source: Shutterstock.com
Power Automate
Sep 11, 2023 3:30 PM

Flow and concurrency control

by HubSite 365 about Timo Pertilä (Forward Forever) [MVP]

Power Platform Consultant, Microsoft Business Applications MVP

Citizen DeveloperPower AutomateLearning Selection

Power Platform’s tools can be used to implement a wide variety of solutions. But if the solution has requirements related to concurrency management, you should

The Power Platform tools are often used for various solutions implementation. However, if requirements for concurrency management are present, additional consideration is needed. With multiple users editing the same line or more than one instance of a flow executing simultaneously, conflicts could arise. This can especially be problematic with parallel executions of the Flow, as they can read and write the same records crosswise, leading to significant discrepancies in the resultant data.

To prevent parallel executions of Flow, one can control Concurrency. This can be done in the settings of the Flow's trigger. However, once it's turned on, the setting cannot be reverted back to its original state. Therefore, if the Flow starts several times almost immediately, only the first request will start with the rest waiting in queue until previous requests are complete.

When attempting to allow asynchronous responses due to Concurrency control being turned on, it may cause issues as the execution does not wait for the task to finish, but instead immediately returns information that the execution has been accepted. This means the return value can be empty if it's still in progress, which poses a challenge.

Implementing a custom lock was also considered. This included creating a lock table with a single row in Dataverse. At the beginning of the Flow's execution, the loop would continue until the lock table row is unlocked. Once the lock is released, actual procedures are performed. However, even if the lock value is checked every second, it's possible several executions will pass through the loop.

Flow's Concurrency Control and Canvas Power Apps experienced complications due to parallel executions of Flow. Attempts to resolve these have been made, such as the use of a Response action in place of Respond to a Power Apps or Flow. A key will be passed to Flow as a parameter and a table is created in Dataverse to store values, and a timer checks whether the Flow’s execution is finished and what the returned value is.

The ultimate solution includes creating a new Flow, which is called from Power Apps where its parallelism setting is not touched. This Flow does nothing but start the original Flow, which is then executed one at a time. Finally, the Flow returns the value it received from the parent Flow back to Power Apps.

Power Platform Limitations

There are limitations to this solution, including connection issues and timeout problems. The children Flow's actions cannot use the Power App's user's own connections, and Flow's operations are performed using predefined connections, causing potential problems. A connection timeout issue occurs if Power Apps have a response time of more than 120 seconds; as a result, only 12 executions can be in the queue if the Child Flow execution takes 10 seconds.

Additionally, an execution timeout issue occurs if Flow has to wait for a long period to execute the Child Flow. The action ends, retries, and if there are too many retries, the Child Flow might not be executed and the call will fail.

To handle this, Flows need to save status information about potential errors and the final result in their tables. If the connection times out, Power Apps can monitor the Flow's result from the board, informing the user about a successful execution, an error, or a failure to execute. This complicates the overall process.

 

Read the full article Flow and concurrency control

Learn about Flow and concurrency control

The text discusses about the Flow and concurrency control in Power Platform’s tools used to implement a wide range of solutions. It states that issues may occur in functionality when managing related concurrency. For example, several users using Canvas Power Apps to modify the same Dataverse line synchronously can lead to overwriting changes. Parallel flow instances may experience similar problems, leading to unexpected final outcomes.

The text then introduces a solution to prevent these issues by limiting Flow’s parallel executions. This is done by turning on the concurrency control in Flow’s settings and setting the maximum number of concurrent flows to one. However, this changes the original setting indefinitely. It should be noted that if numerous flows start at the same time, only the first one will start, with the rest waiting their turn. Ultimately, every user gets to perform, one at a time in order of submission.

 

More links on about Flow and concurrency control

Power Automate: What is Concurrency Control?
Sep 20, 2021 — If you build any Flow, the chances are that it has an “Apply to Each” action. The action will parse the elements sequentially from an array.
Advantages of Concurrency Control in Power Automate
Aug 9, 2023 — Concurrency control in Power Automate refers to the mechanism that allows multiple runs or loops of a Flow to run at the same time.
concurrency control in power automate
Jun 19, 2022 — Open settings on the Flow trigger. You'll find that the Concurrency is turn ON. And the Degree of Parallelism is set to a certain number. The ...
Understand Concurrency Control In Apply To Each Loop In ...
Mar 11, 2022 — After Step 1, Click on New Flow and select instant cloud flow and provide the trigger as Manually trigger a flow and click on Create as shown in ...
Limits of automated, scheduled, and instant flows
Aug 23, 2023 — This is the limit for how many runs a flow can have at the same time. Note: Concurrency Control is set in the flow's trigger settings and is off ...
Improving Microsoft Flow Runtime using Concurrency Control
Oct 22, 2019 — In Microsoft Flow, one of the most used controls is 'Apply Each' which is used to process a list of items. However, if there is a large list of ...
2 Concurrency options to better control speed in the Power ...
Feb 24, 2020 — The Power Platform has a number of places where you can set or control concurrency. In this post I will have a look at the concurrency ...
An Approach to Concurrent Control Flow Checking
Abstract: A control flow checking scheme capable of detecting control flow errors of programs resulting from software coding errors, hardware malfunctions, ...

Keywords

Microsoft expert guide, Microsoft Power Platform specialist, Microsoft flow concurrency control, Canvas Power Apps expert, Microsoft Dataverse professional