SEPURI-SAI-KRISHNA commented on PR #74541:
URL: https://github.com/apache/airflow/pull/74541#issuecomment-6291285139

   Confirming this fix independently, and adding three things the issue does 
not cover.
   
   Verified on `5a64dfcc78`; `partial_subset` is byte for byte unchanged at 
current main `12df3270b8`, so this is still live.
   
   **1. Loop task groups are affected too.** `SerializedLoopTaskGroup` has the 
same slots shape as the mapped one, so the same aliasing applies:
   
   ```
   SerializedLoopTaskGroup.__slots__ = ('max_iterations', 'has_until', 
'terminal_task_id', 'gate_task_id')
   ```
   
   A plain `TaskGroup` nested inside a `create_loop` body crashes through a 
different path, with no `include_upstream` or `include_downstream` set:
   
   ```text
   routes/public/task_instances.py:1323  post_clear_task_instances
   services/public/task_coordinates.py:100  task_coordinate_responses
   models/task_coordinates.py:191  prefetch_regions
   models/task_coordinates.py:213  _is_in_loop
   models/task_coordinates.py:86  enclosing_loop
   ReferenceError: weakly-referenced object no longer exists
   ```
   
   **2. Group edges are stripped, not only `children` replaced.** Because the 
upstream and downstream sets are aliased as well, the `intersection_update` 
pass at the end of `partial_subset` narrows the original group's edges. This 
happens even when the subset excludes the group entirely:
   
   ```text
   subset of an unrelated task, mapped group excluded
   tg.downstream_task_ids  {'after'} -> set()
   ```
   
   **3. Breadth on the clear endpoint.** Counting only legal `POST 
/dags/{dag_id}/clearTaskInstances` requests that should answer 200:
   
   | Dag shape | before | with this PR |
   |---|---|---|
   | mapped group holding a nested group | 14 of 20 fail | 0 of 20 |
   | mapped group holding a mapped group | 8 of 12 fail | 0 of 12 |
   | plain group nested in a loop body | 8 of 16 fail | 0 of 16 |
   
   All 30 are the same `ReferenceError`, and five of them pass neither include 
flag. This one line takes all three shapes to zero and restores the edges in 
point 2.
   
   Two more call sites worth listing alongside the ones in the issue: 
`cli/commands/task_command.py`, and `SerializedDAG.set_task_instance_state`, 
`set_task_group_state` and `clear`.
   
   Happy to contribute the reproduction as a test here if that is useful.
   


-- 
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