Files
archie/internal/infrastructure/postgres/migrations/0038_workflow_call_key.sql
T
sam b7fd13923a fix(workflow): key a workflow.call on its declared step path
A call site had no durable identity, so any retry of it -- a lost
EnqueueCallTask reply, a failed call-step record, a requeued attempt that
re-runs the stage -- started a second child and its work happened twice.

The call step's declared path within the run is that identity: wrapStep
sets it (branch-qualified, restored on return), a workflow.call step must
declare an id so two call sites cannot share one, and the key crosses
EnqueueCallTaskRequest.call_key into tasks.call_key, which EnqueueCallTask
upserts on so the retry returns the child already started.
2026-10-08 22:31:07 +11:00

17 lines
727 B
SQL

-- tasks.call_key is a workflow.call call site's durable identity: the call
-- step's declared path within the calling run. With the parent it is the key
-- EnqueueCallTask upserts on, so a retry of one call site -- a lost
-- EnqueueCallTask reply, a failed step record, a requeued attempt -- returns
-- the child already started instead of starting a second one. The index is
-- partial: every task that is not a workflow.call callee carries the empty key.
-- +goose Up
ALTER TABLE tasks ADD COLUMN call_key text NOT NULL DEFAULT '';
CREATE UNIQUE INDEX idx_tasks_call_key ON tasks (call_parent_task_id, call_key) WHERE call_key <> '';
-- +goose Down
DROP INDEX idx_tasks_call_key;
ALTER TABLE tasks DROP COLUMN call_key;