Skip to main content

Troubleshooting

Each row starts from what you observe, names the cause in the code, gives the check that confirms it, and the fix. Environment variables are described in Configuration. Procedures such as DLQ re-drive and read-model rebuild are in the Runbook.

All REST errors are RFC 7807 application/problem+json bodies with type = https://errors.labor-performance.warehouse-systems.dev/<slug> (internal/adapters/inbound/http/errors.go). The slugs are listed in Problem types.

Boot and readiness​

SymptomCauseCheckFix
Pod in CrashLoopBackOff. The last log line is service exited with error with run migrations (after 5 attempts): …The OLTP database is unreachable, the DSN is wrong, or a migration failed. Boot retry gives up after 5 attempts (1+2+4+8 = 15s of backoff plus the attempts themselves).kubectl logs --previous and look for retrying op="run migrations" lines. Try the DSN with psql.Fix the Secret (DATABASE_URL, MIGRATIONS_DATABASE_URL) or the network, then kubectl rollout restart.
Migrations fail intermittently on rollout with unnamed prepared statement does not exist or canceling statement due to statement timeoutMIGRATIONS_DATABASE_URL is unset, so migrations go through PgBouncer transaction pooling and golang-migrate's advisory lock does not hold (ADR 0020).kubectl exec … env | grep MIGRATIONS_DATABASE_URLAdd the MIGRATIONS_DATABASE_URL key (direct DSN) to the database Secret.
Boot fails with Dirty database version N. Fix and force version.An earlier migration failed halfway and golang-migrate marked schema_migrations dirty.SELECT version, dirty FROM schema_migrations;Repair the schema by hand, then migrate -path migrations -database "$MIGRATIONS_DATABASE_URL" force <N>.
labor-projector or labor-reports exits immediately with ANALYTICS_DATABASE_URL is requiredanalytics.enabled=true but neither analytics.database.projectorUrl nor analytics.database.existingSecret is set, so the chart rendered no Secret.kubectl get secret for the analytics Secret.Set the analytics DSN values or the existing Secret.
Pod never becomes Ready, and the startup probe fails for 60sBoot is still inside the retry budget, or the process exits before it listens (see the rows above). /healthz and /readyz are only served after migrations and the DB ping succeed.kubectl describe pod (probe events) plus the logs.Fix the dependency.
/readyz returns 503 dependency-unavailable while /healthz is 200Postgres did not answer a ping or no Kafka broker answered a metadata request (ADR 0034). The problem detail names the dependency. The verdict is cached 3s and each check is bounded to 2s.curl -s :8080/readyz; then psql with the DSN, or kafka-broker-api-versions.sh --bootstrap-server $KAFKA_BROKERS.Fix the dependency. Liveness is unaffected, so nothing restarts, and accepted writes wait in the outbox. Topics are not checked: brokers auto-create them on first write.
/readyz returns 503 {"status":"not_ready"}The pod received SIGTERM and is draining (ADR 0017). This is the only way readiness flips.Pod is Terminating.Expected. The pod exits within the 10s drain and the 30s grace period.
Process exits at once with DATABASE_URL is required: this context runs on real Postgres, KAFKA_BROKERS is required: this context runs on real Kafka or KAFKA_CONSUMER_GROUP is required: this context runs on real Kafka (cmd/mcp: DATABASE_URL only; labor-projector: ANALYTICS_DATABASE_URL, KAFKA_BROKERS)Mandatory configuration is missing (ADR 0034): there is no in-memory mode, no log sink and no localhost default. Every missing variable is listed in the one error.The first log line / exit message.Set the variable (chart: database.url or database.existingSecret, kafka.brokers, config.kafkaConsumerGroup; the render fails without them).
Process exits at once with EVENT_PUBLISHER=log is not supported or unknown EVENT_PUBLISHERThe variable is set to something other than kafka.kubectl exec … env | grep EVENT_PUBLISHERUnset it or set kafka (config.eventPublisher).

Kafka ingestion (warehouse.fulfillment.events)​

SymptomCauseCheckFix
Scorecards stay 404 and task-type performance stays at taskCount: 0 in the clusterThe producer of warehouse.fulfillment.events is not publishing, or KAFKA_BROKERS points at the wrong cluster. (The old "chart leaves KAFKA_BROKERS unset" cause is gone: the chart refuses to render without kafka.brokers.)kubectl exec … env | grep KAFKA_BROKERS; consumer group lag.Fix kafka.brokers or the producer.
Consumer group labor-performance lag growsSlow DB (5s statement_timeout), every message taking all 3 attempts, or too few replicas for the partitions.kafka-consumer-groups.sh --describe --group labor-performance. Look for exhausted retries log lines.Fix the DB, or scale the api (HPA autoscaling.api, up to 4). Each extra replica takes partitions only while there are idle partitions.
Messages land on warehouse.fulfillment.events.dlqEither the message is not a valid CloudEvents 1.0 event (dead-lettered immediately), or RecordTaskPerformance failed 3 times.Read the DLQ headers x-dlq-error and x-dlq-failed-at.Poison message: fix the producer. Transient: fix the cause, then re-drive (Runbook).
Consumer process exits with kafka: publish to dead-letter topic: …The DLQ write itself failed after about 10s of topic-not-ready retries, or the broker refused it. The offset is not committed, so nothing is lost.Broker health, and topic auto-creation on the broker.Fix the broker. The pod restarts and the message is redelivered.
A TaskCompleted is recorded but efficiencyPct is nullNo standard was active for that task type at the event's time, duration_seconds <= 0, or task_type was absent or unrecognised. Values other than PICK, PACK and SLAM are stored as unclassified "".GET /standards/{taskType}. Compare effectiveFrom with the event time.Expected behaviour (ADR 0004). Define the standard before the work happens. Past rows are never re-scored.
skipping idle gap: out-of-order Kafka delivery warningsA completion arrived whose claim instant is at or before the associate's previous completion.Log fields associate_id and task_id.Expected occasionally. That task has no idle period (idle_seconds_before is null).
Same TaskCompleted delivered twice, counted onceIdempotency on the CloudEvents id (processed_events).—Working as designed. Duplicates with a new id are counted again.

Publishing, outbox and analytics​

SymptomCauseCheckFix
Projector, reports and workforce-management see no events at allThe relay is publishing to a broker nobody reads, the projector is down, or rows are stuck in the outbox (next rows). The log publisher no longer exists (ADR 0034).SELECT count(*) FROM outbox_events WHERE published_at IS NULL; and the projector logs.Fix the broker or the projector.
labor_performance.outbox.lag_seconds keeps climbing, with outbox relay pass failed errorsThe broker is unreachable, or one row keeps failing. The relay stops at the failed row to keep per-key order, until that row reaches OUTBOX_MAX_ATTEMPTS (default 20).SELECT id, topic, attempts, last_error FROM outbox_events WHERE published_at IS NULL ORDER BY id LIMIT 5;Fix the broker. Rows publish by themselves on the next pass.
ERROR outbox relay: row reached the attempt cap ..., and outbox.lag_seconds stays high although newer events flowOne row failed OUTBOX_MAX_ATTEMPTS times and is excluded from claims (ADR 0032). The lag gauge still counts it, because it is unpublished.The log line's outbox_id, topic, event_type, key; last_error on the row.Fix the cause, then UPDATE outbox_events SET attempts = 0 WHERE id = ... (Runbook).
GET /reports/performance/freshness → lagSeconds keeps growingThe projector is down or stuck retrying a transient DB error (analytics message handling failed; retrying). It retries forever and never skips.Projector logs, and group labor-performance-analytics lag.Fix the analytical DB. If the read model is corrupt, rebuild it (Runbook).
Report shows meanEfficiencyPct: null beside tasksRecorded > 0Every task in the bucket was unscorable.tasksScored is 0.Expected. Null is never shown as 0%.
Report with taskType=pick returns empty rowsThe rollup key is normalised to upper case and the reader compares exactly.Repeat with taskType=PICK.Send the task type in upper case.
Old outbox_events or idempotency_keys rows never go awayThe TTL or retention is 0 (or negative), which keeps rows forever, or HOUSEKEEPING_INTERVAL=0 disabled the sweeper.Boot log line housekeeping sweeper configured (enabled, idempotency_key_ttl, outbox_retention).Set positive durations. See Configuration.

REST callers​

SymptomCauseFix
400 idempotency-key-required on POST /standardsThe Idempotency-Key header is missing. It is always required, since Postgres is always on (ADR 0016).Send a fresh UUID per logical request.
400 idempotency-key-invalidThe Idempotency-Key is not 1-128 printable ASCII characters (too long, a control character, or non-ASCII). Nothing was executed or stored (ADR 0037).Send a UUID.
409 idempotency-key-reusedThe same key was sent with a different method, path or body (the fingerprint is method + path + SHA-256 of the body, and the key is global). Nothing was executed. Distinguish it from the business 409s by the problem type.Use a new key for a genuinely new request. Never retry blindly with the same key.
A retry returns exactly the first response again, even a 4xxSame key and same request: the stored outcome is replayed, with the response header Idempotency-Replayed: true. A 2xx and a refusal that is final for the request (a validation answer: 400 or 422) are cached for IDEMPOTENCY_KEY_TTL. A 5xx, a panic and a RETRYABLE refusal (concurrent-modification, standard-conflict) roll back and are not stored, so their retry executes again (ADR 0039).Expected. To try again with different values, use a new key.
409 concurrent-modificationTwo DefineStandard calls raced on the same prior standard, and the optimistic version check lost (ADR 0022). RETRYABLE (ADR 0039): nothing was committed and the key was released (no idempotency_keys row).Re-read with GET /standards/{taskType} and retry the same request with the same key: it executes again.
409 standard-conflictThe unique "one open standard per task type, handling unit and site" index (23505) rejected a second open standard: the request lost a race. RETRYABLE, key released, as above.Same as above.
422 non-positive-expected-seconds, negative-travel-component-seconds, travel-component-exceeds-expected-secondsThe LaborStandard invariants rejected the values. These also count as outcome=rejected on the metric.Fix the payload.
400 unknown-task-typeThe task type is not PICK, PACK or SLAM (path or body). Matching is case-sensitive.Use the upper-case enum.
400 invalid-site-codeThe siteCode (body of POST /standards or the GET /standards/{taskType} query) is longer than 32 characters or contains whitespace (ADR 0038).Send the facility's site code as is, or omit it for the site-less standard.
404 standard-not-found with ?siteCode=That site has no standard of its own. The site lookup never falls back to the site-less standard.Read without siteCode, or define the site's standard.
400 malformed-request-bodyThe body is not valid JSON, or it contains a NUL (U+0000, raw or \u0000), which Postgres text cannot store. The key is not consumed.Fix the client.
404 resource-not-found on a path with %00A NUL in the path is rejected before routing.Fix the client.
404 associate-not-foundThe service has never recorded a task for that associate, or the id is empty.Check that ingestion works (see Kafka above).
404 standard-not-foundNo standard is currently open for that task type.POST /standards.
?window=90 returns a 1h windowwindow is a Go duration (90m, 2h). A bad value silently falls back to the 1h default instead of returning 400.Send a unit.
Browser call blocked by CORSThe origin is not in CORS_ALLOWED_ORIGINS. The OLTP API allows only GET/POST, and the reports API only GET.Add the origin (comma-separated, no spaces).

There is no 412 in this service: it uses no If-Match or ETag. There is no circuit breaker either: labor-performance makes no outbound HTTP or MCP calls, so nothing can trip one.

MCP​

SymptomCauseFix
Clients get "session not found" or are re-initialised intermittentlymcp.replicaCount > 1. The go-sdk Streamable HTTP sessions live in memory and the Service has no session affinity.Keep one replica.
A tool returns an error such as associateId is required or unknown task type…Input validation in internal/adapters/inbound/mcp/tools.go. The error is recorded on the mcp.tool <name> span.Fix the arguments. See MCP tools.
cmd/mcp exits at once with DATABASE_URL is requiredThere is no in-memory mode (ADR 0034).Point it at the same OLTP Secret as the api (the chart refuses to render mcp.enabled without one).
Every tool returns not-found or empty dataThe MCP Deployment points at a different database than the api.Point it at the same OLTP Secret as the api.

Problem types​

SlugHTTPRaised by
standard-not-found404GetStandard
associate-not-found404GetAssociateScorecard
concurrent-modification409StandardRepo.Save version check
standard-conflict409One-open-standard unique index
unknown-task-type400shared.NewTaskType
invalid-site-code400shared.NewSiteCode (ADR 0038)
empty-event-id, empty-task-id400performance.New. Mapped for completeness, but only reachable from the Kafka path, which never writes HTTP.
non-positive-expected-seconds, negative-travel-component-seconds, travel-component-exceeds-expected-seconds422standard.New
malformed-request-body400JSON decode, or body read in the idempotency middleware
idempotency-key-required400RequireIdempotencyKey
idempotency-key-invalid400RequireIdempotencyKey
dependency-unavailable503/readyz (Postgres or Kafka check failed)
resource-not-found404NUL in the path (rejectNUL), unknown route (the router's NotFound handler, on both the OLTP and the reports router)
method-not-allowed405A known path called with a method it does not serve (the router's MethodNotAllowed handler)
idempotency-key-reused409RequireIdempotencyKey
invalid-report-query400Reports API
report-store-error500Reports API
internal-error500Any unmapped error

Each problem type also has a replay class (ADR 0039, the table is held equal to the catalogue by a test). On POST /standards a FINAL refusal (every 400 and 422, idempotency-key-reused) is stored and replayed with the same key; a RETRYABLE one is not stored and its key is released, so the same request executes again: concurrent-modification, standard-conflict, standard-not-found, associate-not-found, and every 5xx (internal-error, dependency-unavailable, report-store-error). No problem type is OUTCOME.