jason810496 commented on code in PR #74119:
URL: https://github.com/apache/airflow/pull/74119#discussion_r4173804008
##########
go-sdk/airflow/dag.go:
##########
@@ -288,6 +305,12 @@ func (d *DagRef) markRegistered() {
))
}
}
+ if cycle := d.cycleLocked(); cycle != nil {
Review Comment:
`cycleLocked` only follows edges from `Inputs`, `Before` and `After`.
`IfRef.Then`/`Else` store the target on the `IfRef` without recording an edge,
so a cycle through a condition passes `Register`:
```go
extracted := dag.Task(extract)
loaded := dag.Task(load)
dag.If(hasRows, Inputs(extracted)).Then(loaded)
loaded.Before(extracted) // load -> extract -> hasRows -> load
bundle.Register(dag) // no panic
```
`IfRef.setTask` in `if.go` (not in this diff, so not a one-click suggestion)
already holds `d.mu`, so recording the edge there fixes it:
```diff
*slot = task
+ d.addEdgeLocked(g.task, task, "")
}
```
It also gives the Then/Else task the condition as an upstream, which the
serialized Dag will need.
--
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]