Run dispatch and queue execution
Run dispatch and queue execution move workflow runs from created step work to workers and back into workflow control. The engine selects eligible work, protects capacity with leases and concurrency rules, records each state change durably, and uses results or recovery actions to release the next work.
Execution model
Run and step work
A workflow run is one execution instance. A step run is one executable unit in that run. The engine places an eligible step in a tenant queue until its dependencies, routing rules, and capacity allow dispatch. Each attempt keeps a stable task identity, insertion time, and retry count so later results apply only to the intended attempt.
Batch-enabled steps also carry a batch key. The key groups compatible step work for one batch run, and the engine keeps it with the task as work moves from creation to queueing and runtime execution. When a batch step has no key, the system uses a shared default key so those items can still join the configured batch.
The database is the source of truth for task state, queue work, and task events. In-memory schedulers speed up selection, but they do not replace the durable assignment. This boundary lets another engine instance recover work after a scheduler or dispatcher stops.
References: pkg/…/scheduler_queue.go• L51-98 pkg/…/task.go• L161-187 pkg/…/task.go• L2473-2629 pkg/…/tasks-overwrite.go• L11-164 pkg/…/scheduling.go• L13-40
Task state storage
Task state and task events use time-based storage so active work and retained history can grow without sharing one unbounded table. Scheduled maintenance creates future partitions, adds payload uniqueness rules, removes old partitions, and repairs parent index state when the database supports that repair.
One shared lease limits partition maintenance to one controller at a time. The maintenance pass commits creation and cleanup before it runs the separate index repair pass. Lock and deadlock conflicts are retryable maintenance outcomes. They do not become task failures.
The same maintenance cycle keeps stream message and payload partitions ahead of current time. It removes idle topics and expires messages by the shared and tenant retention rules. This preserves the data needed for durable callbacks while limiting old delivery data.
The OLAP controller projects task events and audit records for status views and operational history. Audit records first wait in a durable core-database outbox, so a slow or unavailable OLAP database does not block the request that records the audit event. The controller retries queued records until the OLAP copy succeeds.
References: pkg/…/task.go• L30-49 pkg/…/task.go• L492-671 pkg/…/task.go• L5461-5657 pkg/…/tasks.sql• L1-182 internal/…/controller.go• L335-471 internal/…/controller.go• L977-1259
Execution states
The engine represents each step attempt with an operational state. A retry creates another attempt within the same broader workflow run.
| State | Meaning | Main transition cause |
|---|---|---|
| Queued | The step can run but has not received worker capacity. | A trigger or released dependency creates queue work. |
| Held | The step waits because its workflow or a rate-limit key is paused. | Pause handling moves it out of active queue selection. |
| Assigned or running | The engine accepted a worker assignment and created the runtime for the attempt. | Queue selection persists the assignment. |
| Completed | The worker returned a successful result. | The task controller commits completion. |
| Failed | The attempt ended and cannot continue, or it reached its retry limit. | Failure handling exhausts retry options. |
| Cancelled | The engine stopped the attempt by request, timeout, or policy. | Cancellation is committed and may reach the worker. |
| Backoff | The engine will try the attempt again after a delay. | A retryable failure schedules another attempt. |
| Scheduling timed out | The step waited too long for admission or required capacity. | The scheduling deadline expires. |
| Evicted | A durable step lost its active session while waiting for a durable event. | The engine releases its runtime so the step can restore after reconnection. |
The workflow run status comes from its step results and dependency graph. A terminal step result can release later steps or make the whole run terminal. Dispatch controls executable step work; it does not alone determine the final workflow result. Terminal monitoring for a DAG orchestrator is emitted only for its current attempt, so a retried attempt does not make the workflow look finished.
Concurrency admission can cancel work before worker dispatch. This prevents a policy such as keeping only the newest or oldest queued work from consuming capacity after the policy changes.
References: pkg/…/models.go• L233-242 pkg/…/models.go• L2062-2069 pkg/…/concurrency-overwrite.go• L684-918 pkg/…/task.go• L207-235 pkg/…/queue.sql• L1288-1562 internal/…/controller.go• L530-623 internal/…/controller_orchestrator_status_test.go• L75-210
Queue ownership and selection
Resource leases
The lease manager gives one engine instance ownership of the resources it may schedule. It renews ownership for workers, tenant queues, concurrency strategies, and batch resources. Lease changes update the tenant managers, which start or stop queue loops and worker capacity views.
Leases prevent two engine instances from consuming the same queue or using the same worker capacity at the same time. New workers and queues can be acquired when they appear rather than waiting for a full lease refresh.
References: pkg/…/lease_manager.go• L22-66 pkg/…/lease_manager.go• L149-217 pkg/…/lease_manager.go• L272-337 pkg/…/lease_manager.go• L624-639
Queue polling
Each owned queue polls a bounded set of items. Enqueue notifications can wake the loop early. Empty queues use backoff. Items are ordered by priority and then by queue identity so high-priority work is considered first with stable ordering.
The queuer keeps selected items in an in-flight set while it asks the scheduler for a decision. Items that cannot run return to that set for a later pass. This prevents duplicate selection while durable writes are in progress.
Rate-limited items wait outside normal queue storage until their refill time. A queue tick moves due items back in one database operation. A paused workflow or rate-limit key uses a separate held state, and release checks move work back to normal queues or concurrency admission when the pause ends. The queue stays active only when it moves work.
Inactive queues with pending items are reactivated during cleanup. This prevents old activity markers from hiding work that still needs selection.
References: pkg/…/queuer.go• L20-31 pkg/…/queuer.go• L177-253 pkg/…/queuer.go• L509-568 pkg/…/scheduler_queue.go• L179-251 pkg/…/scheduler_queue.go• L997-1024 pkg/…/queue.sql• L641-814 pkg/…/queue.sql• L1183-1203 pkg/…/queue.sql• L1506-1630
Worker eligibility
The scheduler matches a queue item to workers that support its action. It checks worker slot types and requested units, then applies routing rules such as labels, affinity, sticky worker choice, rate limits, and batch policy. Work with no eligible capacity remains unassigned.
Selection runs in a tenant-scoped event loop. The loop refreshes worker capacity from durable data and reconciles assignments that finish during a refresh. Worker heartbeats and listener changes notify the tenant scheduler partition when a worker becomes available or changes dispatcher ownership. The notification uses a short detached send, so a request ending does not cancel the wake-up.
References: pkg/…/scheduler.go• L28-80 pkg/…/scheduler.go• L307-345 pkg/…/scheduler.go• L934-1078 pkg/…/scheduler.go• L1134-1160 internal/…/worker_notify.go• L14-74 internal/…/server.go• L479-496
Concurrency admission
Concurrency admission limits how many related step attempts run at one time. A concurrency slot can wait for a parent group, become active, or expire while waiting. The engine applies the policy as one durable decision so it can promote allowed work and cancel disallowed work together.
Child groups inherit the parent result. Round-robin policies share parent capacity across child groups. Newest and oldest policies rank waiting work before they mark slots active or cancelled. A slot that waits beyond its scheduling deadline becomes a scheduling timeout rather than a worker failure.
References: pkg/…/concurrency-overwrite.go• L11-100 pkg/…/concurrency-overwrite.go• L175-357 pkg/…/concurrency-overwrite.go• L684-918 pkg/…/tasks.sql• L1185-1202
Assignment persistence
After selection, the queuer writes the scheduling result as one database operation. An accepted assignment removes queue work, creates or refreshes the task runtime, records the worker, and creates the runtime slot records. The write matches the exact task attempt so a restored or duplicate item cannot replace another attempt.
The queue-to-runtime transition is atomic: a queue item is removed only for an assignment that matches the task and is eligible for a runtime. The result tells the dispatcher which items received a worker and which items were only removed. This prevents a failed or stale decision from silently losing work.
The same decision path handles work that is not dispatched at once. A scheduling timeout releases the task. Buffered work gets a buffered runtime. Batch work moves to batch storage and keeps its evaluated batch key through batch activation. Rate-limited work moves to delayed storage. Paused work moves to held storage and later returns through normal queue or concurrency admission. If the database does not confirm the assignment, the scheduler releases its reservation and the item can be considered again.
An optimistic trigger path can select and persist work in the transaction that creates it. Locally owned assignments return to the caller so dispatch can start without waiting for a queue notification.
References: pkg/…/queuer.go• L635-804 pkg/…/scheduler_queue.go• L253-573 pkg/…/scheduler_queue.go• L997-1024 pkg/…/queue.sql• L324-482 pkg/…/tenant_manager.go• L586-678 pkg/…/tasks.sql• L292-331
Worker dispatch
Dispatch paths
Accepted work is grouped by worker. It can go directly to a worker in the same engine process or through the task-processing queue to the dispatcher that owns the worker. Both paths carry the task attempt, workflow run, input, retry, and routing context.
The dispatcher keeps worker sessions, loads the durable task data, resolves parent outputs when needed, and sends a start action. A delayed assignment is checked against its worker and retry count before dispatch. If the task has moved to another attempt, the dispatcher skips it. A send or data-read failure requeues only the still-current attempt so an assignment does not disappear.
Dispatch uses a bounded send window. The normal queue path can finish consuming its message while sends continue. The optimistic path waits for its sends so its reserved capacity remains valid. Failed sends become failure messages for retry handling.
References: internal/…/scheduler.go• L88-110 internal/…/scheduler.go• L1280-1289 internal/…/dispatcher.go• L555-624 internal/…/dispatcher.go• L977-1151 internal/…/dispatcher.go• L1198-1248
Worker sessions
The worker session is the boundary between dispatch and execution. A stream session serializes sends and applies flow control. An in-engine session calls the worker operator directly. A successful send means only that the worker accepted the start action.
Each listener has a session identity. A newer listener can replace an older one, and only the current session can mark the worker inactive when it closes. A heartbeat records process health, but a worker with no active listener is not eligible for new work. This keeps in-flight work from being reassigned only because its stream needs to reconnect.
Worker completion and failure return to the task controller. The controller updates durable state and emits internal events. Those events can release dependent steps and wake their queues.
References: internal/…/subscribed_worker.go• L15-53 internal/…/subscribed_worker_v1.go• L73-184 internal/…/server.go• L187-427 internal/…/server.go• L429-496 internal/…/controller.go• L691-767
Batch dispatch
Batch-enabled steps first wait in batch storage instead of taking an individual worker slot. The system evaluates a batch key when it creates or replays queued work. The batch scheduler then groups compatible items by that key when the size, time, worker, or shutdown rule allows activation.
Batch activation reserves the batch key and commits the selected items together. The reservation counts only batch runs that still have active task runtimes, so an empty reservation cannot block new work. The scheduler then sends one batch-start action while each item keeps its own task identity and result path.
If one active batch task times out, the timeout applies to every task in that batch so the batch cannot remain partly active. Batch metadata stays attached to each runtime during later updates, which keeps timeout and result handling tied to the correct batch. If the target worker is no longer connected, the dispatcher requeues only items that still belong to that batch and worker.
References: pkg/…/scheduler.go• L722-841 pkg/…/scheduler_queue.go• L1027-1353 internal/…/scheduler.go• L999-1167 internal/…/dispatcher.go• L1153-1373 pkg/…/tasks.sql• L1546-1607 pkg/…/tasks.sql.go• L264-290 pkg/…/tasks.sql.go• L3745-3789
Result and recovery paths
Completion handling
The task controller accepts a worker result and commits it only for the matching task attempt. Completion releases queue and concurrency resources, publishes terminal task data, and emits internal events that can create or release dependent steps. For a completed DAG orchestrator, it also publishes a status-only terminal monitoring event and delivers satisfied durable entries so downstream control sees the terminal result without duplicating the regular task event.
Failure uses the same durable boundary with an added retry decision. The repository evaluates the retry result for each task, distinguishes application failure from internal failure, applies retry limits and delay rules, releases the matching runtime, and returns retry work separately from terminal failure. A late result cannot revive a task that was already cancelled or released because the failure queries require the current runtime. Monitoring marks a failed attempt as retrying when another attempt remains active and emits terminal status only when the current attempt ends.
Terminal orchestrator status messages use a bounded retry when the message broker is unavailable. The controller keeps the status-only event separate from the normal task event, and places completion or failure detail in the event payload while cancellation detail uses the event message.
References: internal/…/controller.go• L530-623 internal/…/controller.go• L710-892 internal/…/controller_orchestrator_status_test.go• L75-210 pkg/…/task.go• L889-1205 pkg/…/task.go• L2226-2269 pkg/…/tasks.sql• L388-595 pkg/…/tasks.sql.go• L557-905
Retry and reassignment
Application failures can enter retry backoff. A bounded recovery pass deletes only due retry items and moves their current attempts toward queued execution. When it releases retry work, the task controller wakes the tenant scheduler with the affected queue names or the first concurrency strategy for each task. This avoids waiting for a quiet queue's next poll. It also publishes the queued monitoring state for the released attempts.
Worker-requested retry delays are clamped to the controller's maximum retry delay before the repository stores them. This keeps a task from creating an unbounded wait while preserving the task's retry decision.
Internal failures from reassignment use the same failure path and the engine's internal retry limit. A timeout also enters failure handling. Reassignment covers both workers that stopped sending heartbeats and assignments that remain unacknowledged after the dispatch handoff. The recovery query skips evicted durable work and locks candidates in bounded batches. Reassignment and timeout work is converted into failure decisions before the matching task runtime is released. A dead-lettered assignment after dispatcher shutdown also becomes task failure handling so assigned work does not remain stuck.
References: internal/…/process_retry_queue_items.go• L19-116 internal/…/process_reassignments.go• L19-109 internal/…/process_timeouts.go• L18-99 internal/…/controller.go• L895-978 internal/…/controller.go• L1678-1769 pkg/…/tasks.sql• L548-743 pkg/…/tasks.sql.go• L2865-2973 pkg/…/tasks.sql.go• L3618-3669
Cancellation and timeout
Cancellation changes durable task state first. If the task is running and notification is requested, the controller sends a cancel action through the dispatcher that owns the worker. A timeout follows the same pattern and enters failure handling with the task's timeout reason.
Concurrency policy can cancel queued work without a worker message. For active work, the scheduler keeps the worker identity from the release decision and sends a direct cancellation. Queue notifications then let other work use the released capacity. A batch timeout applies to all active tasks in that batch, using the batch metadata carried by the timeout scan. Held work can also expire while a workflow remains paused, based on its configured pause lifetime. If cancellation releases a DAG orchestrator with no worker, the controller also cancels its unfinished durable children because no worker remains to produce their terminal events.
Timeout recovery first applies the failure and retry decision, then sends cancellation signals for the timed-out runtimes that still have a worker. This keeps worker control messages tied to the durable timeout result.
References: internal/…/process_timeouts.go• L18-99 internal/…/controller.go• L980-1117 internal/…/controller.go• L1258-1316 internal/…/scheduler.go• L931-997 pkg/…/task.go• L1618-1745 pkg/…/task.go• L1836-1883 pkg/…/tasks.sql.go• L2975-3068 pkg/…/queue.sql• L1734-1750
Paused-work expiry
The task controller reconciles queue work held by workflow and rate-limit pauses. When a workflow is unpaused, it returns stranded held items to normal queue or concurrency admission and wakes the affected scheduler partition. It also repeats this check during the periodic expiry pass because pause changes and queue writes can race.
Items that remain held beyond the workflow pause lifetime are cancelled. The expiry path releases dependent work, wakes queues, signals internal events, dispatches satisfied durable entries, and publishes cancellation status for monitoring. Expired rate-limit pauses use the same return path without waiting for workflow pause expiry.
The same controller pass requeues work released from an expired rate-limit pause and notifies the scheduler with either its queue or concurrency strategy. This lets both kinds of held work resume without waiting for normal polling.
References: internal/…/controller.go• L329-336 internal/…/controller.go• L1507-1592 internal/…/process_paused_workflow_ttl.go• L16-117
Durable task execution
Durable steps can pause for a sleep, user event, child run, or other durable signal. The dispatcher keeps a route for the active worker session. It can use either a worker stream or an in-engine operator session, so both execution modes receive the same durable-task responses.
When a durable event is satisfied, the dispatcher sends the completion to that route. If no live route exists, the completion can be delivered again after reconnection. Ordered completions wait for earlier entries. A permanent gap causes eviction so the durable task can restart. Invocation counts prevent an old execution from evicting a newer one.
Durable-task requests use an in-flight byte budget per stream and per tenant on each engine instance. A request holds its share until its handler sends its response; when the budget is full, the receive loop pauses, which applies transport backpressure instead of allowing request memory to grow without bound. The in-engine operator session uses the same routing and cleanup model without a network stream.
Eviction marks the runtime and releases worker capacity. If all durable entries are already satisfied, the engine publishes an immediate restore request. A recovery scan also finds evicted orchestrator tasks that have passed the grace period and have no unsatisfied durable entries. A separate lookup finds unfinished durable orchestrator children so recovery can avoid leaving child work without a terminal event. Retained stream data supports callback delivery after reconnect.
When a restore request arrives, the task controller restores only evicted current attempts. It publishes a durable-restoring status and wakes the restored queues so the scheduler can select them again. Satisfied callback entries use the same durable dispatch path as completion and event matching.
References: internal/…/durable_callbacks.go• L19-152 internal/…/controller.go• L765-780 internal/…/server_v1.go• L336-376 internal/…/server_v1.go• L471-714 internal/…/server_v1.go• L700-855 internal/…/server_v1.go• L859-949 internal/…/server_v1.go• L1379-1459 internal/…/server_v1.go• L1635-1733 internal/…/durable_task_budget.go• L17-104 pkg/…/tasks.sql• L1408-1520 pkg/…/tasks.sql.go• L1664-1765 pkg/…/task.go• L2119-2224 pkg/…/task.go• L5541-5621
Execution flow
The flow below shows how queued step work reaches a worker and how completion, retry, cancellation, timeout, pause, and durable wait return control to the engine.
flowchart LR
A[Trigger or released dependency] --> B[Queued step attempt]
B --> C[Owned queue poll]
C --> D{Eligible worker capacity?}
D -- No --> C
D -- Rate limited --> E[Delayed retry or refill wait]
E --> C
D -- Workflow or key paused --> F[Held work]
F --> G{Pause released or hold expires?}
G -- Released --> C
G -- Expired --> H[Failed or cancelled step]
D -- Concurrency policy --> I[Admit or cancel slot]
I -- Scheduling timeout --> J[Timed-out step]
I -- Admitted --> K[Persist assignment and reserve capacity]
K --> L{Assignment succeeds?}
L -- No --> C
L -- Yes --> M[Dispatcher or local worker]
M --> N[Worker executes step]
N --> O{Result or control signal}
O -- Complete --> P[Release resources and create next work]
O -- Retryable failure --> Q[Retry backoff]
Q --> C
O -- Terminal failure --> R[Failed step and run decision]
N --> S[Cancel or timeout]
S --> T[Persist state and notify worker]
T --> U[Cancelled or failed step]
N --> V[Durable wait]
V --> W{Live session?}
W -- Yes --> X[Deliver ordered completion]
W -- No --> Y[Redeliver after reconnect or evict]
X --> N
Y --> C
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the queue assignment result, task runtime update, and worker identity contract aligned. A mismatch can remove work without creating a dispatchable runtime.
- Keep task identity, insertion time, and retry count aligned in queue flushes, worker results, retries, and cancellation messages. The repository uses this identity to reject late results.
- Keep batch-key evaluation and normalization aligned between new task creation, replay, queue work, batch reservation, and runtime metadata. A missing key can split one logical batch or join unrelated work.
- Keep active-runtime checks aligned between batch-run counting and batch reservation. Stale batch reservations must not block new active runs.
- Keep worker listener session, active flag, heartbeat, and dispatcher ownership updates aligned. A stale session must not deactivate a newer listener or route new work to a streamless worker.
- Keep worker and dispatcher ownership updates aligned with scheduler notifications. Selection must not see capacity before the owning dispatcher can receive work.
- Keep the task-assignment message shape aligned between the scheduler, dispatcher, and dead-letter handler so each side can rebuild worker-to-task groups.
- Preserve wake-up notifications when completion, cancellation, retry, reassignment, rate-limit refill, pause release, durable restore, or database-triggered retry release returns work to queue or concurrency admission.
- Keep concurrency operation results aligned with task state changes. A running, cancelled, or scheduling-timeout result must not leave a slot or queue item behind.
- Keep held-queue fields aligned with workflow pause state, rate-limit pause deadlines, concurrency slots, and pause TTL expiry. A move must not leave the same attempt in two waiting stores.
- Keep pause reconciliation aligned with unpause writes and scheduler notifications. A race must not strand an item in held storage after its workflow or rate-limit pause ends.
- Keep terminal monitoring events scoped to current non-retried orchestrator attempts. Preserve the distinction between event message text for cancellation and event payload text for completion or failure.
- When cancellation releases an orchestrator without a worker, keep unfinished durable-child lookup and batched child cancellation aligned with the parent cancellation event.
- Keep queue reactivation aligned with queue items in normal and rate-limited storage. An old activity marker must not hide pending work.
- Keep invocation counts, satisfied order, and callback routing aligned across worker streams, operator sessions, and redelivery messages.
- Keep durable-task request budgets paired with handler completion and session cleanup. A missing release can pause a stream or consume a tenant's budget after the request is done.
- Keep stream cancellation, receive handoff, invocation deregistration, and response-channel closure aligned for network and in-engine durable-task sessions.
- Keep eviction paired with restore when durable events are already satisfied. Otherwise an evicted task can wait with no future wake-up.
- Keep batch-key reservation atomic with batch activation. Apply a batch timeout to every active task in that batch.
- Keep task and stream partition creation, retention, cleanup, and parent-index repair behind their shared maintenance lease. Use the database path that supports the required DDL and session behavior.
- Keep audit-log writes tied to the core outbox and the OLAP flusher. A change to either side must preserve retry and delivery behavior when the OLAP database is unavailable.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Assignment is stored but the dispatcher cannot send it | The step stays assigned without starting. | Convert the send failure to task failure handling. |
| Worker heartbeat stops during execution | The task does not progress and its capacity stays occupied. | Reassignment releases the task and retries or fails it. |
| A worker listener closes after a newer listener takes over | The live worker can be marked inactive by the old session. | Deactivation checks the recorded listener session identity. |
| A result uses an old retry count | A late result can affect the wrong attempt. | Match task ID, insertion time, and retry count before updating. |
| Queue or worker ownership expires | Two engine instances could select the same resource. | Lease refresh removes local ownership. |
| Queue flush fails after capacity reservation | Capacity can be lost or work can be duplicated. | Release the reservation and keep the item eligible. |
| A task is held without its pause state or deadline | Paused work can run too early or remain stuck. | Move the full queue item contract and recompute release conditions. |
| A workflow is unpaused while queue writes still use the old pause state | Work can remain in held storage after the pause ends. | Periodic reconciliation requeues held items for unpaused workflows and expired rate-limit pauses. |
| A retry item is released by the database but the scheduler is not notified | The retry waits for the next queue poll, which can delay execution. | Notify the tenant scheduler for the task queue or its first concurrency strategy. |
| A queue is inactive while it still has items | Work is not selected by the normal queue loop. | Reactivate queues that contain pending normal or rate-limited items. |
| A batch key is lost between task creation and activation | Compatible items split across batches or unrelated items share a batch. | Carry the evaluated key through queue and runtime records. |
| A stale batch reservation has no active runtimes | New work can be blocked by a batch that no longer runs. | Count and lock only batch reservations joined to active runtimes. |
| A concurrency slot exceeds its scheduling deadline | The step can remain in admission storage. | Remove the expired slot and record a scheduling timeout. |
| A batch task times out | Other tasks in the batch can remain active. | Fail every active task in the batch. |
| A DAG orchestrator is cancelled after its worker is gone | Unfinished durable children can remain without a parent terminal event. | Find and batch-cancel unfinished children when the released parent has no worker. |
| A durable session disappears during event delivery | The run can wait with no response route. | Redeliver after reconnect and evict stale invocations. |
| Ordered durable completion has a permanent gap | Later completions remain buffered. | Evict after the gap timeout and restore the task. |
| An old invocation evicts a newer one | Active work can lose its runtime. | Compare invocation counts before eviction. |
| Durable-task handlers consume more in-flight request bytes than the stream or tenant budget allows | The receive loop pauses until earlier handlers finish. | Charge each request and release its weight after the response path returns. |
| A durable-task handler panics | One request can fail without stopping the session's other request handling. | Recover per request and keep the worker-status runner alive. |
| A durable-task stream is canceled while receive is blocked | Dispatcher shutdown can wait for a stream that no longer has useful work. | Cancel registered sessions and let the receive handoff observe context cancellation. |
| An assigned message dead-letters after dispatcher shutdown | The step can remain assigned forever. | Convert the dead letter to task failure handling. |
| Partition maintenance conflicts with active queries | Cleanup or repair can fail or contend with task work. | Serialize maintenance and retry lock or deadlock conflicts. |
| Stream data expires before a durable callback is consumed | A reconnecting task may miss a needed event. | Retain messages and payloads for the configured retention window. |
| The OLAP database is unavailable after an audit record is accepted | The audit record remains pending for later copy instead of blocking the request. | Keep the core outbox durable and let the OLAP controller retry the queued record. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/lease_manager.go | Shows ownership of workers, queues, concurrency strategies, and batch resources. |
| pkg/…/queuer.go | Shows queue polling, item buffering, assignment outcomes, and flush behavior. |
| pkg/…/scheduler.go | Shows worker eligibility, slot selection, rate limits, and capacity reservation. |
| pkg/…/tenant_manager.go | Shows how tenant queues and optimistic trigger scheduling connect to the scheduler. |
| pkg/…/scheduler_queue.go | Shows the durable boundary for queue removal, runtime creation, delayed work, and batch activation. |
| pkg/…/queue.sql | Shows atomic queue-to-runtime assignment, delayed and held queue movement, batch queue selection, and queue reactivation. |
| pkg/…/queue.sql.go | Shows the generated query contract used by queue selection and held-work recovery. |
| pkg/…/concurrency-overwrite.go | Shows how concurrency policies promote, cancel, or time out related work. |
| pkg/…/tasks-overwrite.go | Shows task creation rules that preserve batch grouping data. |
| pkg/…/tasks.sql | Shows durable queries for retries, timeout, reassignment, durable restore, batch capacity, and active batch reservations. |
| pkg/…/tasks.sql.go | Shows the generated task query contract used for recovery, cleanup, and batch reservation. |
| pkg/…/task.go | Shows task creation and replay, result transitions, bounded recovery scans, held-work expiry, durable eviction and restore, batch timeout scope, and retention maintenance. |
| internal/…/scheduler.go | Shows how assignments become dispatcher messages and how cancellation and dead letters recover. |
| internal/…/dispatcher.go | Shows how assigned work is loaded, checked against its current attempt, grouped, retried, and sent to worker sessions. |
| internal/…/durable_task_budget.go | Shows the per-stream and per-tenant in-flight budget that limits durable-task request work. |
| internal/…/server.go | Shows worker listener ownership, heartbeats, result messages, cancellation, timeout refresh, and durable restore requests. |
| internal/…/worker_notify.go | Shows how worker availability and dispatcher ownership wake the tenant scheduler. |
| internal/…/server_v1.go | Shows durable sessions, callback routing, ordered completion delivery, invocation checks, and restore recovery. |
| internal/…/server_v1_durable_task_test.go | Shows the durable-session guarantees for cancellation, channel response routing, handler recovery, and budget backpressure. |
| internal/…/subscribed_worker_v1.go | Shows worker-facing start and cancel actions. |
| internal/…/controller.go | Shows how worker results become completion, failure, cancellation, retry monitoring, terminal monitoring events, child cancellation, and downstream scheduler events. |
| internal/…/controller_orchestrator_status_test.go | Shows the current-attempt filter and bounded broker retry contract for terminal orchestrator status. |
| internal/…/durable_callbacks.go | Shows durable callback delivery and requeue of evicted tasks. |
| internal/…/process_retry_queue_items.go | Shows how due retry work is released and how the scheduler is woken for its queue or concurrency strategy. |
| internal/…/process_reassignments.go | Shows how lost worker assignments become retries or terminal failures. |
| internal/…/process_timeouts.go | Shows how timeout decisions lead to monitoring and worker cancellation signals. |
| internal/…/process_paused_workflow_ttl.go | Shows pause-race reconciliation, held-work expiry, scheduler wake-up, and cancellation monitoring for expired work. |
| internal/…/controller.go | Shows how task status events and audit records move into the analytical store without changing execution state. |
For the surrounding system, see workflow orchestration, workflow definitions and versions, triggers and scheduling, concurrency controls, and worker lifecycle and listener.