Evaluation order of inputs saveInto's and outputs in process model

We had a question pop up in our design review output the evaluation order of Data Input Save Input and Data Outputs. I know there is no guarantee on the order of Data Output execution, but I was wondering if there is a guarantee that Data Input Save Into's are evaluated first.

For example: Say before a script task, pv!index=0

And has the Data Inputs configured as below

And Data Outputs configured as

Would the order evaluation be:

  1. ac!index value = pv!index + 1 = 1
  2. Save Into pv!index -> ac!index = 1
  3. Outputs
    • pv!index -> pv!index+1 = 2

So after execution: pv!index is guaranteed to be 2

Or could it potentially be:

  1. ac!index value = pv!index + 1 =1
  2. Outputs and Save Into's
    • pv!index -> pv!index+1 = 1
    • Save Into pv!index -> ac!index = 1

So after execution: pv!index could be 1 or 2 depending on the order of the Save Into's and Outputs were evaluated

A member of my team had heard that Save Into's and Outputs are evaluated together.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    As far as I've been able to put together:

    1. all inputs are evaluated at the same time, in no particular (or guaranteed) order, when the node starts
      1. (at least, to set the ac! values, not necessarily external saves - i believe these are saved on completion)
    2. when the node ends (even if right away), all outputs are evaluated at the same time, in no particular order

    I do NOT believe it's accurate to say that inputs and outputs are evaluated all together.  Though in a script task or other node type with no significant wait before start and end, you should assume that the outputs will be evaluated almost instantly after the inputs are evaluated.

    In your example there's a bit of a race condition, since pv!index is receiving outputs both from the input and from the output.  I'd need to test it out a bit to see, but I suspect that the rule output will override/overwrite anything saved from the rule input.

  • Hi Mike,

    Thanks for the response. That's exactly what I'm trying to determine. Is there a race condition or not on pv!index when using Inputs Save Into and Outputs? Slight smile

    If pv!index is guaranteed to be committed from Save Into before evaluating outputs, then there's not. However, if this is not guaranteed the case, then there is.

Reply Children
  • 0
    Certified Lead Developer
    in reply to joshuaj985

    In my experience, you should be saving into pv!index in only one of those two places.

    My intuition is that the execution order is something like this:

    1. node inputs are evaluated
    2. node outputs are evaluated
    3. node input saves are saved
    4. node output saves are saved

    however it's hard to prove this one way or the other, and I don't believe there is any guarantee either way.  Therefore you should avoid the race condition and if you're saving into it from the node output, then again I recommend you save into it ONLY from the node output.