Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/repository/sqlcv1/concurrency.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ WHERE
;

-- name: CheckStrategyActive :one
-- A strategy is active if the workflow is not deleted, and it is attached to the latest workflow version or it has
-- at least one concurrency slot that is not filled (the concurrency slot could be on the parent).
-- A strategy is active if the workflow is not deleted and it has at least one concurrency slot
-- (the concurrency slot could be on the parent). Strategies on idle workflows will be deactivated
-- and re-activated by the after_v1_concurrency_slot_insert trigger when new work arrives.
WITH latest_workflow_version AS (
SELECT DISTINCT ON("workflowId")
"workflowId",
Expand Down Expand Up @@ -118,10 +119,11 @@ WITH latest_workflow_version AS (
SELECT
EXISTS(SELECT 1 FROM latest_workflow_version) AND
(
-- We must match the first active strategy, otherwise we could have another concurrency strategy
-- that is active and has this concurrency strategy as a child.
-- A task can flow through multiple step concurrency strategies sequentially via
-- v1_concurrency_slot.next_strategy_ids. If this strategy is not the lowest-id active
-- strategy on the workflow version, an earlier strategy is still draining and may
-- hand off a task here next — so we can't deactivate even if no slots exist yet.
(first_active_strategy.id != @strategyId::bigint) OR
latest_workflow_version."workflowVersionId" = @workflowVersionId::uuid OR
EXISTS(SELECT 1 FROM active_slot) OR
EXISTS(SELECT 1 FROM active_parent_slot)
) AS "isActive"
Expand Down
12 changes: 7 additions & 5 deletions pkg/repository/sqlcv1/concurrency.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading