Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Pipeline ForEach Activity parallel execution interferes with Set Variable

Hello everyone!   I have a pipeline like this:   If I set the ForEach activity to sequential execution, everything works fine.   However, if I set it to parallel, the variable gets ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    When running in parallel, variables can indeed behave unpredictably because they are not thread-safe. This can lead to the kind of unexpected behavior you’re seeing, where the variable gets set multiple times before the copy activity executes.

     

    Since variables are not thread-safe, try to avoid using them within parallel loops. Instead, consider using parameters or passing values directly to activities.

     

    If possible, stick with sequential execution for activities that depend on variable values. This ensures that each iteration completes before the next one starts, maintaining the correct order of operations.

    Also I think you can look at this document: Running a ForEach activity in parallel mode - Microsoft Q&A

     

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.