Skip to main content

Cross-context incident runbook: a stuck order

Every context runbook stops at its own boundary. This page follows one order across the three contexts that move it to the dock: order-management (intake, allocation, release), wes-work-planning (work units, release to the floor) and fulfillment-execution (tasks, packages). It tells you which hop to check first and links to the context runbook that owns the fix.

Everything here works on the k3s cluster (nodes k3s-server and k3s-agent, namespace warehouse-systems, one Kafka broker). Kong, Grafana, Prometheus and Jaeger are ClusterIP Services, so the localhost URLs below exist only while warehouse-infra's scripts/k3s-edges.sh runs on your workstation (it runs kubectl port-forward bound to 127.0.0.1 and re-runs itself under sudo for port 80):

WhatURLService
Kong (every context under /api/<context>)http://localhost:8000kong-kong-proxy in kong
Grafanahttp://localhost:3000grafana in observability
Prometheushttp://localhost:9090prometheus-server in observability
Jaegerhttp://localhost:16686jaeger in observability
Alertmanagernot forwarded by the script: kubectl -n observability port-forward svc/prometheus-alertmanager 9093:9093prometheus-alertmanager in observability

The Kafka broker is the pod kafka-controller-0 (container kafka) in warehouse-systems: one combined controller and broker, so a restart or an out-of-memory kill of that pod stops every context's events at once. Kafka has no host-reachable listener, so every Kafka command here runs inside that pod.

The path an order takes​

Identifiers you carry from hop to hop:

HopKeyWhere it comes from
order-managementorder idPOST /orders response
wes-work-planningwork unit <orderId>-line-<lineNo>, reference = order idApplyOrderAllocated (one work unit per allocated line)
fulfillment-executiontask orderRef = the work unit id <orderId>-line-<lineNo>ConsumeWorkReleased; Pack tasks fulfillment-execution creates itself carry the order id

Every hop goes through a transactional outbox and a Kafka topic, so a stuck order is almost always one of four things: the producer's outbox is not draining, the consumer is not reading, the consumer dead-lettered the message, or the next step waits for a person or a station.

1. Start from the alerts​

Open Prometheus /alerts on http://localhost:9090 (or the ALERTS series in Grafana), or Alertmanager's /api/v2/alerts after the port-forward above, and filter on the three contexts. Alertmanager's only receiver is null: nothing pages anyone, so an alert exists only where you look at it. The alert catalogue lists every rule.

Firing alertLikely hopGo to
WarehouseOutboxLagHigh for order-managementallocated orders are not reaching Kafkastep 3
WarehouseOutboxLagHigh for wes-work-planningreleased work is not reaching Kafkastep 5
WarehouseKong5xxRatioHigh for one of the threethe API itself fails (often a dependency: inventory-storage behind the order-management breaker, Postgres)that context's troubleshooting page
WarehousePodRestarting for one of the threea binary exits on purpose (projector consumer stopped, boot retry exhausted, migration failed) or is OOM-killedkubectl -n warehouse-systems logs --previous on the pod, then the context runbook
nothing firesconsumer lag, a dead-lettered message, or work that waits for a release or a stationfollow steps 2 to 7 in order

fulfillment-execution exports no outbox-lag gauge and no context exports consumer lag, so a stuck order can be silent. Steps 2 to 7 do not depend on an alert.

2. order-management: what state is the order in?​

curl -s http://localhost:8000/api/order-management/orders/<orderId>
Order / line statusMeaningNext
Received, lines Pendingallocation never happened (permissive inventory client, or a hard failure at intake)order-management troubleshooting: cancel and resubmit with a new Idempotency-Key
Backordered linesinventory-storage answered 409 (no usable stock): a business factPOST /orders/<orderId>/allocation-retries once stock exists
Allocated / PartiallyAllocated, not releasedheld at intake (ship-complete rule or network hold)POST /orders/<orderId>/releases when the hold reason is gone
Released / PartiallyReleasedorder-management is done; the order is in wes-work-planning's handsstep 3
Cancellednothing downstream should happennone

3. order-management: did the event leave?​

Released lines are announced through the outbox (OrderAllocated / OrderPartiallyAllocated on warehouse.order-management.events). In order-management's database:

SELECT id, topic, event_type, key, attempts, last_error, created_at
FROM outbox_events
WHERE published_at IS NULL
ORDER BY id
LIMIT 20;
  • Rows with a growing attempts and a last_error: Kafka is unreachable or one row fails every pass. Fix the cause in last_error; the relay resumes on its own.
  • A row with attempts >= 20 (OUTBOX_MAX_ATTEMPTS, default 20): the relay parked it and logged outbox relay: row reached the attempt cap and is no longer claimed at ERROR. Later rows, even for the same order, have overtaken it. Fix the cause, then re-arm it with UPDATE outbox_events SET attempts = 0 WHERE id = <id>; (order-management runbook).
  • No unpublished row for the order: the event left. Go to step 4.

Since the gap-fix wave (D27) the outbox row stores the request's W3C trace context and the relay sends it as Kafka headers, so a consumer that extracts it continues the trace of the POST /orders call. Search Jaeger (http://localhost:16686) for the order-management trace first; when it ends at the relay, the event was not consumed yet.

4. wes-work-planning: did it read the order?​

curl -s "http://localhost:8000/api/wes-work-planning/work-units?reference=<orderId>"

An empty array means no work unit exists for the order. Check, in order:

  1. Consumer lag of the integration consumer group (default wes-work-planning):

    kubectl -n warehouse-systems exec kafka-controller-0 -c kafka -- \
    bash -c 'env KAFKA_HEAP_OPTS=-Xmx128m kafka-consumer-groups.sh \
    --bootstrap-server localhost:9092 --describe --group wes-work-planning'

    Keep the KAFKA_HEAP_OPTS=-Xmx128m prefix: the CLI shares the broker container's memory limit, its full-heap default has OOM-killed the single broker before, and that stops every consumer (warehouse-infra docs/dlq-runbook.md, "Broker access").

    Lag on warehouse.order-management.events with no progress means the consumer stopped. The loop exits on purpose when a DLQ publish or an offset commit fails (log kafka consumer stopped); nothing is lost, restart the pod after fixing the broker.

  2. Dead letters on warehouse.order-management.events.dlq: the handler failed 3 times. The usual cause is a line whose path_id is not in the process-path catalogue (the whole event fails). Read the x-dlq-error header, declare the path in process-path-management, then replay the message.

  3. processed_events already holds the CloudEvents id: the event was applied and every line was a duplicate. Look the work unit up by id instead: GET /work-units/<orderId>-line-<lineNo>.

5. wes-work-planning: was the work released, and did WorkReleased leave?​

Each work unit has a state: Pending → Released → Completed.

  • Pending: nothing releases it on its own. Work is released by a call to POST /paths/<pathId>/work-releases (REST, the MCP tool release_next_work, or the console), earliest CPT first. The call answers 409 wip-limit-reached when the path is at its WIP limit: that happens when completions from fulfillment-execution stop arriving (step 7), because only RecordCompletion frees a slot. Check the path with GET /paths/<pathId>/telemetry.
  • Released: WorkReleased went into wes-work-planning's outbox. Run the same outbox_events query as in step 3 against wes-work-planning's database, and re-arm a parked row the same way (wes-work-planning runbook). wes_outbox_lag_seconds on the warehouse-wes-work-planning dashboard shows the same thing as a gauge.

6. fulfillment-execution: did it create the task?​

curl -s "http://localhost:8000/api/fulfillment-execution/tasks?orderRef=<orderId>-line-<lineNo>"

An empty array means WorkReleased never became a task. The fulfillment-execution troubleshooting page has the full decision tree; the common causes are:

  • A new consumer group (WORK_RELEASED_CONSUMER_GROUP, default fulfillment-execution) starts at the latest offset: events released before the group existed are never read. Re-release the work.
  • Unknown path_id in fulfillment-execution's catalogue: 3 attempts, then warehouse.work-planning.events.dlq. Define the path, then replay.
  • Not ready yet: with PATH_CATALOGUE_SOURCE=kafka the HTTP listener starts before the catalogue replay and /readyz answers 503 until the replay has caught up (ADR 0044).

Check the group the same way as in step 4 with --group fulfillment-execution.

7. fulfillment-execution: is the task moving?​

Task stateMeaningNext
PENDINGno station has pulled itstations must call POST /stations/<stationId>/task-claims; GET /queues/<taskType>/depth shows the backlog. Too few stations with the required capability, or none checked in
CLAIMEDa station holds the leasean expired lease goes back to PENDING on the next lease-expiry sweep (POST /task-lease-expirations, called every minute by the fulfillment-execution-expire-leases CronJob in warehouse-systems)
COMPLETEDTaskCompleted went into the outboxcheck fulfillment-execution's outbox_events as in step 3; this context has no outbox-lag gauge, so the SQL query and the log line outbox relay pass failed are the only signals

When TaskCompleted is published, wes-work-planning applies it and marks the work unit Completed (which frees the WIP slot), and order-management uses PackageManifested and TaskCPTMissed from the same topic to re-promise. A work unit stuck in Released while its task is COMPLETED means wes-work-planning is not consuming warehouse.fulfillment.events: check its consumer group (step 4) or complete the unit by hand with POST /work-units/<id>/completions.

8. After the incident​

  • Re-armed outbox rows publish out of order relative to rows with the same key that overtook them. Consumers dedupe on the CloudEvents id, but a state-carrying consumer may need the context's own read-model rebuild procedure (see each runbook).
  • A DLQ message is never retried by itself. Replay it only after the cause is fixed, or it lands in the DLQ again.
  • Record what happened against the Fleet SLOs: a stuck outbox row or a stopped consumer is an event-delivery SLO breach even when no HTTP call failed.