Skip to main content

Troubleshooting

Synced from inbound-receiving

This page is a copy of docs/docs/operations/troubleshooting.md on develop, derived from that repository's code. Edit it there, then re-sync.

Symptom → cause → check → fix, built from the failure paths that exist in the code. Problem-document type URIs are https://errors.inbound-receiving.warehouse-systems.dev/<slug> (internal/adapters/inbound/http/errors.go). Log messages are quoted exactly; see Observability for their fields.

Boot and readiness​

SymptomCauseCheckFix
Pod exits at start with DATABASE_URL is required, KAFKA_BROKERS is required, PRODUCT_CONSUMER_GROUP is required or DOCK_DOOR_CONSUMER_GROUP is requiredcmd/api loadConfig refuses an incomplete environment before opening anything (ADR 0011); cmd/mcp needs DATABASE_URLkubectl logs first line; rendered env of the Deploymentset the named variable (the chart refuses to render without it)
Exit with EVENT_PUBLISHER=log is not supported, PRODUCT_MODE=permissive is not supported (or DOCK_DOOR_MODE, or off)a retired value: Postgres and Kafka are the only runtimeenvunset the variable or set it to kafka
Projector/reports exit with ANALYTICS_DATABASE_URL is required ... or KAFKA_BROKERS is required ...required env missingenv of the analytics Deploymentsset analytics.database.* and kafka.enabled
Pod never answers /healthz, restarts after ~15–20 s with run migrations (after 5 attempts): ... or ping postgres (after 5 attempts): ...Postgres unreachable or wrong DSN; the listener starts only after migrations + first pingretrying WARN lines (op, attempt, err)fix DSN/network/credentials; the budget is 5 attempts with 1+2+4+8 = 15 s of backoff and is not configurable
Migration fails with a lock or prepared statement errorDATABASE_URL points at PgBouncer in transaction mode and no MIGRATIONS_DATABASE_URL is setwhich DSN the Secret holdsadd the direct DSN under the MIGRATIONS_DATABASE_URL key (api, mcp) / make ANALYTICS_DATABASE_URL direct (projector)
Migration error Dirty database version 1a previous migration failed half-waySELECT * FROM schema_migrationsfix the cause, set dirty = false on the right version, restart
/readyz is 200 but writes return 422 unknown-sku / unknown-dock-door right after deployreadiness never waits for the local-copy consumers; a new group is still replaying the source topicproduct registered processed / location slot event processed INFO lines still streamingwait for the replay, or run permissive until the copy is filled
/readyz returns 503{"status":"not_ready"}: shutdown has started (pod Terminating, expected). A dependency-unavailable problem (detail: not ready: postgres, kafka): that dependency does not answer (cached 3 s)readiness: dependency is not ready WARN lines with the causerestore the named dependency; the pod turns ready by itself
Pod restarts with product-consumer stopped unexpectedly / outbox relay stopped unexpectedlya worker returned on its own (usually the broker became unreachable); the service exits so the orchestrator restarts itthe ERROR line before the exitrestore Kafka; expected during a broker outage
MCP tools return nothing although REST shows data (local)cmd/mcp points at a different DATABASE_URL than cmd/apithe DSN of eachpoint both at the same Postgres

REST problem types​

Status / slugCauseCheckFix
400 idempotency-key-requiredPOST /asns, /receipts or /receipts/{receiptId}/lines sent without Idempotency-Keyrequest headerssend a unique key (≤ 255 chars) per logical request
400 malformed-requestinvalid JSON, unknown field, unparsable If-Match, body over the limit, or a key longer than 255 charsrequest body/headersfix the request
400 idempotency-key-invalidthe key is not 1-128 printable ASCII charactersthe request's Idempotency-Key headersend a UUID
409 idempotency-key-reusedthe same key was used earlier with a different method + path + body (SHA-256 fingerprint)idempotency_keys.request_hash for that keyuse a new key for a new request; a true retry must resend identical bytes
Retry with the same key returns the old responseintended: a committed key replays its stored status, headers and bodyidempotency_keys.status_codenone; 5xx responses are never stored, so they can be retried with the same key
500 with idempotency key vanished while replaying; retry the request in the logtwo concurrent requests with one key and the first rolled backlog idempotency store failedretry the request
409 concurrent-modificationanother request saved the same aggregate between load and save (version guard)—re-fetch (GET) and retry
412 version-mismatchIf-Match carried a stale versioncompare with the current ETagre-fetch and resend with the new ETag
409 asn-already-existsASN number already registeredGET /asns/{asnNumber}use a new number, or treat as already done
409 asn-in-progress, asn-terminal, asn-not-receivableASN state does not allow the command (cancel while receiving, act on Closed/Cancelled, open a receipt on a non-receivable ASN)GET /asns/{asnNumber} statefollow the lifecycle in Receiving workflow
410 appointment-movedPOST /appointments, /check-ins or /cancellations called: the DockAppointment moved to dock-scheduling (ADR 0019)the detail names the operationcall dock-scheduling (book, cancel) or yard-management (gate check-in)
409 appointment-cancelledPOST /receipts named an appointment that dock-scheduling cancelledGET /appointments/{appointmentId} (deprecated, local copy)open the receipt without it or against a live appointment
409 receipt-already-openthe ASN already has an open receipt (unique partial index receipts_one_open_per_asn)GET /receipts?asnNumber=...&state=Opencontinue the open receipt
409 receipt-closedline received on a closed receiptGET /receipts/{receiptId}open a new receipt only if the ASN is still receivable
422 unknown-skuPRODUCT_MODE=kafka and the SKU is not in known_skusSELECT * FROM known_skus WHERE sku = ...; product consumer logsregister the product in product-master; wait for the event
422 unknown-dock-doorDOCK_DOOR_MODE=kafka and the door is not an Inbound/Both door in dock_doorsGET /docks; dock-door consumer logsregister/flag the door in facility-layout
422 unknown-asn, unknown-appointment, asn-not-on-appointment, line-not-on-asna referenced aggregate or line does not exist / is not coveredthe referenced resourcefix the reference
400 validation slugs (invalid-sku, invalid-quantity, invalid-window, window-in-past, duplicate-sku, …)domain value rejecteddetail of the problemfix the input
500 internal-errorany unmapped error (usually the database)api logs around the requestfix the dependency
Browser call blocked by CORSorigin not in CORS_ALLOWED_ORIGINS (default only http://localhost:5173)browser consoleadd the origin; in kind Kong's CORS plugin handles browsers

Kafka and the outbox​

SymptomCauseCheckFix
Events are not on the topic yet, outbox_events.published_at is NULL and outbox relay pass failed says Unknown Topic Or Partitionthe first write to a topic the broker has not created yet; auto-creation answers once with that errorthe next pass succeedsnone, the relay retries; the row is not lost
Outbox backlog grows; outbox relay pass failed every intervalbroker unreachable or rejecting the head rowSELECT id, event_type, attempts, last_error FROM outbox_events WHERE published_at IS NULL ORDER BY id LIMIT 5fix Kafka; the relay resumes by itself. A row that keeps failing blocks later rows only until it reaches OUTBOX_MAX_ATTEMPTS (default 20); then it is excluded and logged at ERROR
outbox relay: row reached the attempt cap ... ERROR; one event never reaches Kafkaa poison row (too large, rejected by the broker) failed OUTBOX_MAX_ATTEMPTS times and is excluded; later rows, same key included, overtook it (ADR 0007)SELECT id, topic, event_type, key, attempts, last_error FROM outbox_events WHERE published_at IS NULL AND attempts >= 20fix the cause, then UPDATE outbox_events SET attempts = 0 WHERE id = <id> (runbook, "Re-arm a row")
Downstream sees the same event twiceat-least-once relay (crash between send and published_at update)identical CloudEvents idexpected; consumers dedupe on id
Every event appears on two topicsintended: FanoutEncoder writes an integration row and an analytics row with the same idoutbox_events.topicnone
Local-copy consumer lag grows, same partition/offset in handling failed; retrying the same messagea transient error (usually Postgres) — the loop never skipsERROR linesfix the dependency; the message is retried with 200 ms → 5 s backoff
A product/door event seems ignorednot a CloudEvent, malformed payload or invalid value: logged at WARN and committed past (no DLQ for these consumers)skipping ... WARN linesfix the producer; replay by resetting the group offset
A consumer is silent although its topic now has eventsit started before its topic existed and kafka-go does not pick the topic up laterno product registered processed lines; the topic existsrestart the pod (create or seed the topics before the first start). Known limit, still open (ADR 0011): /readyz pings the broker topic-less and the worker does not fail on a missing consumed topic, so nothing alerts on it

Analytics​

SymptomCauseCheckFix
GET /reports/freshness returns nullsthe projector has applied nothing yet (or cmd/api has published nothing)analytics_processed_events row count; outbox_eventswait for events or fix the relay
lag_seconds keeps growingprojector down, blocked on a transient error, or no new eventsprojector logs (analytics consumer handling failed; ...), consumer-group lagfix the analytical database / Kafka. A quiet warehouse also grows the lag
DLQ warehouse.inbound-receiving.analytics.dlq growsdeterministic failures: undecodable payload of a known type, subject not matching the aggregate id, invalid event, or SQLSTATE class 22/23 from the storex-dlq-error header; analytics: dead-lettering ... ERRORfix the cause, re-produce the message (see Runbook)
Projector pod restarts with analytics consumer stopped unexpectedlythe Kafka reader failed outside the retry loopprevious container logsusually broker/network; restart is the intended recovery
400 invalid-report-rangefrom/to not RFC 3339, from >= to, or range > 366 daysquery stringfix the range
500 report-store-erroranalytical query failed or hit the 15 s statement_timeoutreports log report query failedcheck the analytical database; narrow the range
Reports reachable through Kong return 404Kong routes only to the api Service; reports are served by cmd/inbound-reportsService <release>-reportscall the reports Service in-cluster

Housekeeping​

SymptomLikely causeCheckFix
housekeeping sweep failed / analytics housekeeping sweep failed every intervalthe database rejects the DELETE (permissions, lock timeout, outage)the error field; SELECT count(*) FROM idempotency_keys WHERE created_at < now() - interval '24 hours'fix the database; the next tick retries. Serving is not affected
A client retry after a day runs the handler again instead of replayingthe key passed IDEMPOTENCY_KEY_TTL (default 24h) and was sweptidempotency_keys for that key (gone)intended; raise config.idempotencyKeyTTL if clients retry later
outbox_events still growsunpublished rows are never swept (relay backlog or rows excluded at the attempt cap)SELECT count(*) FROM outbox_events WHERE published_at IS NULLfix the relay (see above); re-arm or delete excluded rows

Not present in this service​

  • Circuit breakers: none. There are no synchronous calls to other contexts; outbound dependencies are Postgres and Kafka only.
  • Unbounded tables: none since gap fix D24. idempotency_keys, published outbox_events, processed_events and analytics_processed_events are swept (see Runbook, ADR 0010).