Tags: project-flogo/flow
Tags
FLOGO-18450: Concurrent execution of parallel transition branches (#218) * FLOGO-18450: Concurrent execution of parallel transition branches Activities on parallel transitions (fan-out branches) previously executed sequentially even though the flow models them as parallel. This adds opt-in concurrent execution of ready branches, gated behind the existing FLOGO_FLOW_CONCURRENT_TASK_EXECUTION env flag (default off). When the flag is off the sequential DoStep loop is byte-for-byte unchanged, so no existing flow regresses unless explicitly opted in. When on, FlowAction.Run drives a new IndependentInstance.RunConcurrent worker pool that runs ready tasks concurrently while preserving join semantics (a task runs only after all its incoming links resolve) and order-independent results. - support/env.go: GetConcurrentExecution(); instance/util.go IsConcurrentTaskExcutionEnabled delegates to it (one source of truth, shared with the change-tracker lock). - Two-lock design on IndependentInstance: coarse stateLock (traversal/scheduling, taskInsts/linkInsts/subflows) + attrsLock RWMutex (shared scope + returnData), both nil in sequential mode. Lock order: stateLock -> changeTracker -> attrsLock. - stepID/wiCounter/subflowCtr promoted to atomics. - Per-task cancellable context (TaskInst.evalCtx) so context-aware activities abort on sibling failure. - Drain-then-fail: first unhandled branch error cancels siblings, the pool waits for in-flight branches to return, then the global error handler fires once. - execTask and the new execTaskConcurrent share extracted evalTaskBehavior + handleEvalResult helpers (removes duplication). - Tests: unit + integration (parallelism, join-once, drain-then-fail, sequential parity), ~87% coverage of the new code; clean under -race. Also fixed pre-existing map-order-flaky TestGetErrorObject_* (def.Tasks()[0] -> def.GetTask("LogStart")). - Benchmarks + a when-to-enable guide (instance/PARALLEL_BENCHMARKS.md). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * update env var name * add log statement when parallel execution of branches is enabled * FLOGO-18450: address Copilot review (strict max-step, clear evalCtx, lock-order comment) - RunConcurrent: increment stepCtr while holding coordMu (before Unlock) so the max-step safeguard is enforced strictly, matching the sequential loop; workers can no longer pop past maxStepCount. - execTaskConcurrent: clear taskInst.evalCtx on exit so a TaskInst never retains a canceled group context after the pool tears down concurCtx; GoContext/GetGoContext fall back to the flow context on later reads. - Correct the lock-hierarchy comment to stateLock -> changeTracker -> attrsLock (leaf), matching the actual order (the change tracker calls GetReturnData under its own lock). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * FLOGO-18450: bump core to v1.6.20-rc.1 so the module builds out of the box Production code uses trace.TagDefs/ParseTagDefs (added in #219) which only exist in core v1.6.20-rc.1, but go.mod still pinned v1.6.17, so `go build ./...` failed with "undefined: trace.TagDefs". Bumped core via `go get` + `go mod tidy`; tidy also pruned now-unused transitive deps (x/net, go-redis, redsync, hashicorp/*, xxhash, go-rendezvous) that the newer core no longer requires. Verified build on windows/linux/darwin. Also fixed a pre-existing broken reference in action_test.go, previously masked by the TagDefs build failure: the dead RestartRequest test fixture referenced flow/support.Interceptor (a type removed long ago); pointed it at core/engine/support.Interceptor to match the canonical tester.RestartRequest so the flow package's tests compile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * FLOGO-18450: document pre-existing TestTaskBehaviour failure (propagateSkip shadowing) TestTaskBehaviour fails on `assert.True(t, skip)`. This is a pre-existing bug on master, unrelated to FLOGO-18450 — it was hidden because model/simple could not compile against the old pinned core (missing trace.TagDefs) and is exposed now that the module builds. Add an inline comment documenting the root cause (TaskBehavior.Skip's named return `propagateSkip` shadows the package-level var and is never assigned, so Skip always returns false; and the package var is init-cached so the test's os.Setenv is inert) and how to fix it. No production behavior change here, per decision to track the fix separately. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * FLOGO-18450: pin core to v1.6.20 (stable) now that it is released core v1.6.20 is now published (it is @latest and contains trace.TagDefs). Switch the pin from the v1.6.20-rc.1 release candidate to the stable release via `go get github.com/project-flogo/core@v1.6.20` + `go mod tidy`. No dependency-graph change beyond the version/hash; build verified on windows/linux/darwin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
PreviousNext