Skip to main content

Troubleshooting

Symptom, cause, check, fix, for the failure modes the code on develop can actually produce. Log messages are quoted exactly; their fields are listed on Observability.

Boot and readiness​

SymptomCauseCheckFix
Process exits 1 right after start with DATABASE_URL is required: this context runs on real Postgres, there is no in-memory mode (cmd/mcp too)DATABASE_URL is unset: there is no in-memory mode (ADR 0011)the service exited with error lineset DATABASE_URL (locally: docker compose up -d --wait, see the Quickstart)
Exits with KAFKA_BROKERS is required: this context runs on real Kafka (outbox relay, consumers, /readyz)no brokerssameset KAFKA_BROKERS (localhost:9092 for the fleet broker or the compose broker from a laptop)
Exits with DEMAND_CONSUMER_GROUP is required: the DEMAND_MODE consumer always runs on real Kafka (or PRODUCT_, LAYOUT_, RELOCATION_)the consumer group id is unset; the consumers always runsameset the matching *_CONSUMER_GROUP; there is no default by design
Exits with DEMAND_MODE=permissive is not supported: this context runs on real Kafka (or =off, or any other *_MODE)a legacy consumer mode; only kafka existssameset kafka or unset the variable
Exits with EVENT_PUBLISHER=log is not supported: this context publishes to real Kafka (or EVENT_PUBLISHER: unknown value "..." (want kafka))a legacy publisher; only kafka existssameset kafka or unset the variable
The pod restarts with outbox-relay stopped unexpectedly: exiting so the orchestrator restarts the service (or DEMAND_MODE consumer stopped ...)the relay or a consumer returned on its own, typically after the broker went awaythe preceding outbox relay stopped / consumer stopped ERROR linerestore the broker; the restart resumes from the committed offsets and the unpublished outbox rows
Exits about 15 s after start with run migrations (after 5 attempts): ... or ping postgres (after 5 attempts): ...Postgres unreachable, wrong DSN or credentialsthe preceding retrying WARN lines (op, err)fix DATABASE_URL / MIGRATIONS_DATABASE_URL, network policy, or the database
Exits with Dirty database version 1. Fix and force version.an earlier migration failed half-way and golang-migrate marked schema_migrations dirtySELECT * FROM schema_migrations;repair the schema by hand, then UPDATE schema_migrations SET dirty = false; (or drop and recreate a throwaway database)
Migrations hang or fail with an advisory-lock error behind PgBouncermigrate's session advisory lock under transaction poolingwhich DSN migrations usepoint MIGRATIONS_DATABASE_URL at a direct connection
Pod is running but not ready; GET /readyz is 503 with not ready: kafka (or postgres)/readyz pings Postgres and asks a Kafka broker for metadata; the named dependency does not answer within 2 sthe readiness: dependency is not ready WARN line (dependency, error), container logsrestore the dependency; the verdict is cached for 3 s. A broker that answers with an empty topic list is ready: the service never requires topics
/readyz answers 503 {"status":"not_ready"}shutdown began (SIGTERM); it never flips backshutdown: readiness flipped to not-ready log lineexpected during a rollout; a pod stuck here is waiting out the drain timeouts
worker did not stop before the shutdown drain deadline at shutdowna consumer was mid-retry or the relay mid-pass for more than 10 sthe worker name in the lineharmless: uncommitted messages are redelivered and unpublished rows are resent

Plans that come out empty or partial​

POST /slot-plans succeeds with a plan built from whatever the three local copies hold; it never fails because a copy is empty.

SymptomCauseCheckFix
assignments, moves and unassigned all emptyno ACTIVE demand for the site in the windowGET /sku-velocity?siteId=... returns no items; SELECT count(*) FROM demand_lines WHERE site_id = '...' AND state = 'ACTIVE';run the demand consumer (DEMAND_MODE=kafka), widen lookbackDays, or check the site id
Velocity empty although order-management has ordersDEMAND_SITE_ID is set to another site: those lines are dropped with outcome=ignoredevent processed ... outcome=ignored log linesunset DEMAND_SITE_ID or set it to the right site
Every SKU is NoPhysicalProfilethe product copy has no effective dimensions for them (no ProductDimensionsDeclared/ProductMeasured, or effective_source=none)SELECT sku, volume_mm3, weight_g FROM product_profiles WHERE sku IN (...);run the product consumer (PRODUCT_MODE=kafka); declare or measure the product in product-master
Every SKU is NoEligibleSlot and there is no slot at allno forward slot matches: the zone's site_code differs from the demand site_id, the zone code is not in FORWARD_ZONE_CODES, the slot role is not Storage, or the slot is decommissionedSELECT s.location_code, s.role, s.active, z.site_code, z.zone_code FROM slots s JOIN zones z ON z.zone_id = s.zone_id;run the layout consumer (LAYOUT_MODE=kafka), fix FORWARD_ZONE_CODES, align site ids
Some SKUs are NoEligibleSlot while slots existhazmat or temperature mismatch (a Hazmat SKU only goes to a hazmat zone and vice versa; temperature classes must match, empty = Ambient), or every eligible slot is taken by a better-ranked SKUthe SKU's handling_tags and temperature_class against the zonesadd compatible forward slots
SKUs are NoCapacityFitone unit is larger or heavier than every compatible slot. A slot registered without capacity stores 0, which holds nothingmax_volume_m3, max_weight_kg of the slotsregister capacity in facility-layout
A slot came back in a plan after being decommissionedit cannot: LocationSlotDecommissioned sets active = false for good, and a later registration does not reactivate it (SaveSlot ... WHERE slots.active)SELECT active FROM slots WHERE location_code = '...';if the slot really returned, it needs a new location code
A product update had no effectits version was not newer than the stored one (outcome=stale)event processed ... outcome=staleexpected; product-master versions are authoritative

REST problem types​

Every error is application/problem+json with type = https://errors.slotting-optimization.warehouse-systems.dev/<slug> (internal/adapters/inbound/http/errors.go).

Status and slugCauseFix
400 idempotency-key-requireda POST without Idempotency-Key (400 idempotency-key-invalid when it is not 1-128 printable ASCII) (the middleware is always on: there is no in-memory mode)send a unique key per logical request
400 malformed-request / 404 resource-not-found on a request that carries a NUL character (U+0000)Postgres text cannot hold NUL: the NUL guard refuses it before any idempotency key is recorded (a NUL in the path is a 404, in the body or query a 400)strip the NUL from the path, body and query
409 idempotency-key-reusedsame key, different method, path or body (compared by SHA-256 of the raw body, so whitespace counts)new key for a new request; resend the identical bytes to replay
400 malformed-requestinvalid JSON, an unknown field (DisallowUnknownFields), trailing data, wrong types, or a body over 64 KiBsend only siteId/lookbackDays (generate) or reason (reject)
400 invalid-site-idmalformed siteId (empty, longer than 64 characters, whitespace, control characters or /), or no siteId while neither DEMAND_SITE_ID nor DEFAULT_SITE_ID is setpass siteId or configure a default
400 invalid-lookbacklookbackDays is 0 or outside 1 to 3651 to 365
400 invalid-limitlimit outside 1 to 500, or windowDays of GET /sku-velocity not a positive integer or above 365 (the code reuses this slug for the window)fix the parameter
400 invalid-cursora cursor this API did not hand outrestart paging without a cursor
400 invalid-statestate filter not one of Draft, Approved, Rejected, Supersededfix the filter
400 invalid-plan-idthe path id does not start with plan- or breaks the token rulesuse the planId from the Location header
400 reject-reason-too-longtrimmed reason over 500 charactersshorten it
404 plan-not-foundunknown plan id
409 plan-not-draftapprove or reject on a plan that is already Approved, Rejected or Supersededgenerate a new plan
409 approved-plan-conflicttwo approvals of the same site raced; the loser hit the partial unique index or saw the previous Approved plan changere-read GET /forward-slots, then decide whether to approve again
409 concurrent-modificationthe plan's version changed between load and savere-fetch and retry
500 internal-erroranything unmapped, typically a Postgres outage or a query hitting statement_timeout = 5s. The detail is generic; the cause is in the request failed log linecheck the log and the database

Which refusals are replayed under the same Idempotency-Key​

Only an answer that was final for the request is stored and replayed (ADR 0016). A RETRYABLE refusal — 400 invalid-site-id (no siteId and no default site configured), 409 approved-plan-conflict, 409 concurrent-modification — is NOT stored: its key is released, so a retry with the same key executes the work again, and a different body under that key is a new request, not 409 idempotency-key-reused. A FINAL refusal (plan-not-found, plan-not-draft, every request-validation slug) is stored and replayed byte-identically with Idempotency-Replayed: true; the same key with a different body is then a 409 idempotency-key-reused. A 5xx is never stored. Automation may retry a released key immediately; a person who sees approved-plan-conflict or concurrent-modification should re-read the plan and retry consciously.

There is no 412 in this service: no endpoint takes If-Match or returns an ETag. A browser call blocked before it reaches the API is CORS: add the console's origin to CORS_ALLOWED_ORIGINS.

Kafka​

SymptomCauseCheckFix
Approved plans never reach warehouse.slotting-optimization.eventsthe relay cannot write (broker unreachable or rejecting); the relay is always on and only kafka exists, so rows are never silently logged awayoutbox relay running ... publisher=kafka; outbox relay pass failed lines; unpublished rows in outbox_eventsfix the broker; to resend, see Re-publish plan events
One outbox relay pass failed with [3] Unknown Topic Or Partition right after the first event of a fresh brokerthe output topic does not exist yet; the broker auto-creates it on that first writethe same row succeeds on the next pass (attempts = 2)none
Outbox backlog grows, outbox relay pass failed every intervalbroker unreachable or the write is rejectedSELECT id, attempts, last_error FROM outbox_events WHERE published_at IS NULL ORDER BY id LIMIT 5;fix the broker; rows stay unpublished and are sent in order once it is back. A row that keeps failing is excluded after OUTBOX_MAX_ATTEMPTS (default 20) failures so the rows behind it move on (ADR 0008)
ERROR outbox relay: row reached the attempt cap and is excluded from future claimsone row failed OUTBOX_MAX_ATTEMPTS times (message too large, topic rejected, a long broker outage)the outbox_id, event_type, key and error fields; SELECT id, attempts, last_error FROM outbox_events WHERE id = <outbox_id>;fix the cause, then UPDATE outbox_events SET attempts = 0 WHERE id = <outbox_id>; (Runbook). Later rows of the same plan may already have overtaken it
Consumer group lag grows; handling failed; retrying the same message repeatsa transient error (database down, statement timeout) on one messagethe error fieldfix the dependency; after 5 attempts the message is dead-lettered and the partition moves on
Messages on <topic>.dlqa message failed 5 times with a transient errorthe x-dlq-error and x-dlq-source-* headersfix the cause, then replay it
dead-letter publish failed; retrying the same message foreverthe DLQ topic cannot be written (ACLs, auto-creation disabled)broker logscreate <topic>.dlq or grant access; the partition stays blocked until then, by design
dead-letter publish failed with Topic must not be specified for both Writer and Messagea build from before ADR 0010: the dead-letter writer had a fixed topic and kafka-go refused every dead letter, wedging the partitionthe image tagdeploy a build with ADR 0010 (the writer carries no topic; TestDomainDLQWriter_TopicComesFromTheMessage)
dead-lettering an event that can never be applied / message can never be applied; dead-lettering it without retry (relocation consumer)a StockRelocated without a required field or with an undecodable data (ADR 0010)x-dlq-error on warehouse.inventory.events.dlqa producer defect in inventory-storage; the progress of that move stays missing until it publishes a valid relocation
relocation matched no slot-plan movea relocation of no known move: reason=unknown-plan / unknown-move / sku-mismatch (the move reference names something this context does not have), no-current-plan / no-matching-move (no reference and the bins match no move of the site's Approved plan), plan-not-approved, site-mismatch, reason-not-slotting (the relocation's reason is not SLOTTING; checked first, before any plan is read)the source_ref, plan_id, reason fields; GET /slot-plans/{planId}expected for manual, consolidation and replenishment relocations; for slot-plan moves compare the RELOCATE task's relocation_ref with the plan's moves (move_seq is the 0-based position in the plan's SKU-ordered moves)
GET /slot-plans/{planId} shows movesExecuted: 0 although moves were done on the floorthe StockRelocated consumer is behind (the consumer always runs; it is not switched off)consumer running ... topic=warehouse.inventory.events; group lag of RELOCATION_CONSUMER_GROUPexecution progress
skipping a message that is not a valid CloudEventa producer sent a non-CloudEvents value (e.g. the retired flat envelope)the topic fieldfix the producer; the message is committed past and lost for this copy
skipping an event that can never be appliedthe payload decoded but failed validation (bad SKU, unknown state, version below 1, unknown temperature class, negative capacity)type, event_id, errorfix the producer's data; it is not retried
A new group id replays nothingclaims in processed_events are keyed by consumer name (slotting-demand, slotting-product, slotting-layout, slotting-relocation), not by groupoutcome=duplicate for every messagefollow Rebuild a local copy
A laptop consumer "steals" partitions from the clusterthe same group id on the shared brokerkafka-consumer-groups.sh --describe shows your hostuse a group id nobody else uses

Analytics read side​

SymptomCauseCheckFix
slotting-projector exited with error with ANALYTICS_DATABASE_URL is required: ... or KAFKA_BROKERS is required: ... (slotting-reports exited with error with the first one)the variable is unset; in the chart, analytics.enabled without a DSN source is refused at renderthe pod logset analytics.url or analytics.existingSecret
Projector exits about 15 s after start with run analytics migrations (after 5 attempts): ... or ping analytics database (after 5 attempts): ...the analytical database is unreachable or the DSN is wrong (or goes through PgBouncer: the migration lock needs a direct DSN)the retrying WARN linesfix ANALYTICS_DATABASE_URL
analytics consumer stopped unexpectedly: ... and a restartthe reader failed for good (broker gone)the error textrestore the broker; the restart resumes from the committed offset
GET /reports/freshness answers {"as_of": null, "lag_seconds": null}the projector has applied nothing yet: not deployed, no event since a fresh group started, or every event is being retriedprojector logs, group lag of ANALYTICS_CONSUMER_GROUPdecide a plan, or check the projector
lag_seconds keeps growingthe projector is behind or retrying a transient failure forever (it never dead-letters a transient error), or simply no plan was decided since as_ofgroup lag; ERROR lines of the consumer loopfix the analytical database; if lag is zero, nothing is wrong
analytics: dead-lettering a message that can never be projectedundecodable data, plan_id not equal to subject, a missing id, time, plan or site, or a SQLSTATE 22 / 23 rejectionx-dlq-error on warehouse.slotting-optimization.analytics.dlqa producer defect in cmd/api's encoder; replay after the fix as in Replay a dead-lettered message
400 invalid-report-rangefrom / to not RFC 3339, from not before to, or more than 366 daysthe detailfix the range (omit both for the last 30 days)
400 invalid-report-granularitygranularity other than dayomit it or send day
500 report-store-errorthe analytical query failed (database down, statement_timeout = 15s reached)the report query failed ERROR linefix the database or shorten the range
GET http://localhost:8000/api/slotting-optimization/reports/... is 404 in the kind clusterthe chart renders no Kong route for the reports Service; the request reaches cmd/api, which has no /reports routekubectl get httproute -n warehouse-systemsread the reports in-cluster (port-forward svc/slotting-optimization-reports 8092:80); a route needs a chart change
Plans generated before the analytics stream existed have no approval latencyADR 0006: a plan is only visible from the events the topic still holdsslot_plan_facts.generated_at IS NULLexpected

What does not exist​

There is no circuit breaker and no outbound HTTP client in this service on develop, so none of their failure modes apply. The MCP server (cmd/mcp, ADR 0005) and the reports binary are read-only.