aglinxinyuan opened a new issue, #9411:
URL: https://github.com/apache/texera/issues/9411

   ### What happened?
   
   Root cause: the engine runs the input an operator reads first, such as the 
If's Condition port, a HashJoin's build side or a two-input Python UDF's port 
0, before the operator has any output port 
(`RegionExecutionManager.executeDependeePortPhase` connects no channels), so a 
state the operator sends then reaches no one. A loop's message that arrives 
only on that input is processed there and goes no further. #9366 records a 
message's id only once the worker has an output port, so that the copy of Loop 
Start's message on the operator's second input is processed and sent on; that 
copy also puts back the values a change on the first input replaced.
   
   ```
   Loop Start (K = 2) -> U1 (process_state sets K = 3) -> port 0 of a two-input 
UDF M; Loop Start -> port 1 of M; M -> Loop End
   
   main:        M fails when it reads K: "loop variable K got two different 
values in one iteration, 3 and 2"; Loop End gets Loop Start's message only (K = 
2)
   with #9366:  M reads K = 2, with no error; Loop End gets Loop Start's 
message only (K = 2)
   wanted:      M reads K = 3, the later value, and U1's change reaches Loop End
   ```
   
   Expected: a later value wins, and a copy of a message an operator already 
processed changes nothing. An operator that reads one input before another 
holds what it sends while it has no output port and sends it once it has one, 
and remembers the ids of the messages it processed then, so the copy of Loop 
Start's message on its second input is dropped: the operator keeps `K = 3`, and 
U1's change reaches the operators after it and Loop End. The If is affected the 
same way when Loop Start's message carries its condition's variable, since its 
copy then sets the route back.
   
   Found in the review of #9366, which leaves this case out of its scope.
   
   ### How to reproduce?
   
   ```
   Text Input ("a", "b")
     -> Loop Start   initialization: i = 0; K = 2   output: table.iloc[i]
     -> U1 (Python UDF)              process_state: state["K"] = 3; return state
     -> M (two-input Python UDF)     port 0 from U1, port 1 from Loop Start;
                                     process_tuple on port 1 yields {"line": 
tuple_["line"], "K": self.loop_variables["K"]}
     -> Loop End     update: i += 1; got = K        condition: i < len(table)
   ```
   
   - With #9366 (fa08044725): M yields `K = 2` for both rows, and Loop End's 
update reads `K = 2`.
   - On main (4fba9ebcfa): M fails when it reads `K` for its first row.
   - With U1 also feeding M's port 1, so that the change reaches both inputs, M 
reads `K = 3` with #9366.
   
   ### Version/Branch
   
   1.4.0-incubating-SNAPSHOT (main)
   
   ### Commit Hash (Optional)
   
   fa08044725ad32b6f886eb1e6e1f5fe8cf1a5ce2 (head of #9366; on main the same 
workflow fails instead, see above)
   
   ### What browsers are you seeing the problem on?
   
   _No response_
   
   ### Relevant log output
   
   ```shell
   main:       loop variable K got two different values in one iteration, 3 and 
2: a loop's variables must not change inside its body
   with #9366: none; M and Loop End read K = 2
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to