Skip to main content

Troubleshooting

Symptom, cause, check, fix, built from the failure modes visible in the code. Log lines are the literal msg values in the source (see Observability for the field names); none was captured from a run. SQL probes assume the schema in the Runbook. This service has no outbound HTTP, MCP or A2A client, so there is no circuit breaker to trip: the dependencies that can fail are Postgres and, for cmd/api, Kafka.

Boot​

SymptomLikely causeCheckFix
cmd/api exits 1: DATABASE_URL is required: this context runs on real Postgres, there is no in-memory modeDATABASE_URL unset or emptyservice exited with error ERROR line; env of the podSet it (Configuration); the chart refuses to render without database.url or database.existingSecret
cmd/api exits 1: KAFKA_BROKERS is required: this context runs on real Kafka (outbox relay, consumers, /readyz)KAFKA_BROKERS unset, blank or only commasenv of the podSet a comma-separated host:port list (kafka.brokers in the chart)
cmd/api exits 1: <TOPIC>_CONSUMER_GROUP is required: the consumer of that topic always runs on real KafkaOne of the nine consumer group variables is empty. The first missing one is reportedenv of the podSet all nine to stable, service-prefixed names
cmd/api exits 1: EVENT_PUBLISHER=log is not supported: this context publishes to real Kafka or EVENT_PUBLISHER: unknown value "x" (want kafka)A deployment still sets a retired publisher modeenv of the podUnset it or set kafka
cmd/a2a exits 1: invalid configuration: ... naming DATABASE_URL and/or A2A_AGENT_URL (both are reported together)Missing variable, or A2A_AGENT_URL is relative, schemeless or not http(s)The error text has the offending valueSet an absolute URL such as http://<release>-a2a.<ns>.svc.cluster.local:8093/; the chart defaults it when a2a.agentUrl is empty
cmd/mcp exits 1: DATABASE_URL is required: this context runs on real PostgresSameenv of the podSet DATABASE_URL
Exits 1 after about 15 s: run migrations (after 5 attempts): ... or ping postgres (after 5 attempts): ...Postgres unreachable, wrong DSN, or the migration itself failsWARN retrying lines carry op and err; connect with psql from the same networkFix the DSN or network. The retry exists for the ~10 s first-dial reset of an Istio-injected pod; it is not a license to boot without a database
Migration fails and every later boot fails the same wayA partial migration left schema_migrations.dirty = true; golang-migrate refuses to continueSELECT version, dirty FROM schema_migrationsRepair the schema by hand, then force the version with the golang-migrate tooling. Take a backup first
Migrations hang or fail through PgBouncerDATABASE_URL is a transaction-pooler address; the advisory lock needs a sessionIs the DSN a pooler?Set MIGRATIONS_DATABASE_URL to a direct connection (database.migrationsExistingSecretKey in the chart)
A tuning variable seems ignored; WARN invalid OUTBOX_RELAY_INTERVAL; using the default (same for OUTBOX_MAX_ATTEMPTS, SWEEP_INTERVAL, ignoring invalid SHUTDOWN_DRAIN_DELAY)Unparseable or non-positive valueThe value and default fieldsUse 500ms, 15s or plain seconds for the relay; a non-negative integer for the cap
Pod restarts with <name> consumer stopped unexpectedly: exiting so the orchestrator restarts the service (also queue-sweep, outbox-relay)A background worker returned on its own: a consumer's reader failed for good (for example 10 consecutive stalled fetches) or the relay/sweep stoppedERROR consumer stopped or outbox relay stopped just beforeFix the dependency (usually Kafka); the restart is deliberate

Probes and traffic​

SymptomLikely causeCheckFix
/readyz is 503 {"status":"not_ready"}The process is shutting down; the drain gate flips only on SIGINT/SIGTERMIs the pod terminating?Nothing to fix; a new pod takes over
/readyz is 503 dependency-unavailable, detail not ready: kafka (or postgres, or both)The broker answered no metadata request, or Postgres did not answer a ping. A missing topic never causes itWARN readiness: dependency is not ready has the cause in errorRestore the broker or database. The process stays up and recovers by itself (verdict cached 3 s, re-checked after)
/readyz 200 but requests fail with 500A query failing for another reason (statement timeout, constraint, bug); readiness only proves a pingERROR request failed (the real error is only logged; the response says an unexpected error occurred)Fix the cause shown in the log
Statements fail with canceling statement due to statement timeoutEvery connection has statement_timeout = 5s (compiled in)The failing request's logs; slow queries on listingInvestigate the query
cmd/mcp / cmd/a2a pods Ready but calls failThey are read-only and dial Postgres only; a bad DATABASE_URL shows at boot. At runtime a database outage makes tool calls return internal-errormcp tool failed with an unexpected error / a2a skill failed with an unexpected errorRestore Postgres. These binaries have no /readyz, so the probe stays green
Agent Card advertises an unreachable URLA2A_AGENT_URL is the in-cluster DNS but the client is outside the clusterGET /.well-known/agent-card.json and read the advertised interface URLSet a2a.agentUrl to the Kong URL (/api/a2a/order-sourcing)

Kafka and the outbox​

SymptomLikely causeCheckFix
Events never reach Kafka; outbox_events.published_at stays NULLThe broker is unreachable (the relay is always on; its writer allows topic auto-creation, so a missing output topic is created on the first write)ERROR outbox relay pass failed with the cause; last_error and attempts on the head row; /readyzRestore the broker. Rows drain in id order
ERROR outbox relay: row reached the attempt cap and is excluded from future claimsA poison row, or an outage longer than OUTBOX_MAX_ATTEMPTS passes (default 20 at 1 s is about 20 s of broker outage)SELECT id, topic, event_type, 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>
A consumer is not consuming; WARN lines about the broker connection, no consumer running for a topicThe consumed topic does not exist yet (its producer has not written; this service never creates a consumed topic), the group coordinator is unreachable, or a consumer group variable is wrongconsumer running lines list topic, group_id, brokers; /readyzFix the broker, or wait for the producer's first event. Retries at boot are expected until every sibling has produced once
Consumer lag grows on one topicOne message is failing transiently and blocks its partition until its 5 attempts end (backoff 200 ms to 5 s)Repeated handling failed; retrying the same message with the same partition and offset; database healthFix the dependency (usually Postgres). After 5 attempts the message goes to the DLQ and the consumer moves on
Messages appear on <topic>.dlqA payload that can never be applied (undecodable data, validation error such as a missing id or bad tier) or a transient failure that outlasted 5 attemptsx-dlq-error header; ERROR dead-lettering linesFix the producer or cause, then re-publish the value to the source topic (Runbook). A message that is not a CloudEvent or has an unhandled type is skipped with a WARN (or silently), not dead-lettered
An event seems ignoredIt was a duplicate (event_id already in processed_events), stale (older revision or instant), or the aggregate had moved on (WARN skipping an event the aggregate can no longer take)Logs with event_id and type; SELECT * FROM processed_events WHERE event_id = '<id>'Expected idempotency. Delete the processed_events row only if you deliberately want to re-apply the event
A node never receives an assignment; the group is UNSOURCEABLE at onceThe local read models cannot satisfy the search. A node is eligible only if it is a fulfilment-centre node run by a vendor, ACTIVE, with a declared operational profile (internal/domain/network/network.go); it must also have a non-suppressed listing with enough available quantity for every line, a scheduled, uncancelled departure with remaining capacity and a cutoff after the handling time, a path to a usable wave of the destination's service area that ends by deliverByLatest; a SAME_DAY group additionally needs a SUB_SAME_DAY or MICRO nodeGET /assignments/{id} shows state, excludedNodes; SELECT count(*) FROM rm_nodes, rm_listings, rm_departures, rm_waves, rm_service_areasFeed the read models: the sibling topics must have been consumed. A revised promise re-searches an UNSOURCEABLE group
Assignments pile up in QUEUED past their releaseAtThe sweep is not running or failingqueue sweep running at boot; ERROR queue sweep pass failed; SELECT count(*) FROM assignments WHERE state = 'QUEUED' AND release_at < now()Check the sweep error (usually Postgres); the process exits if the sweep stops
Released assignment never locksThe vendor has not sent PurchaseOrderAccepted (or the event is dead-lettered)releases of the assignment (outcome PENDING); the vendor-connectivity topic and its .dlqNot a fault of this service; see Integration

REST problem types​

Every error is application/problem+json with type = https://errors.order-sourcing.retail-network.example/<slug>, title, status, detail and instance (the escaped request path). The catalogue is internal/adapters/inbound/http/errors.go.

StatusSlugWhenWhat to do
400malformed-requestBody is not valid JSON for the operation (unknown field, wrong type, trailing data, body over 64 KiB) or the request carries a NUL character in the query string or bodyFix the body against apis/openapi.yaml
400idempotency-key-requiredPOST /assignments/{id}/reoptimisations without an Idempotency-Key headerSend a unique key per logical request
400idempotency-key-invalidThe Idempotency-Key is not 1 to 128 printable ASCII charactersSend a UUID
400invalid-limit / invalid-cursor / unknown-query-parameterGET /assignments with a bad limit, an undecodable cursor, or a parameter it does not declare (after, offset, nextToken)Use limit and the nextCursor of the previous page
409idempotency-key-reusedThe Idempotency-Key was already used with a different method, path or body, and the first answer was stored (a 2xx, malformed-request or assignment-locked). After a RETRYABLE refusal the key is released and a different body under it is a new request, not this errorA new logical request needs a new key; do not retry blindly
404not-foundUnknown assignment idNormal for a wrong id
404resource-not-foundA path that names no resource, or a NUL in the pathFix the path
405method-not-allowedMethod not allowed on the pathUse the documented method
409assignment-lockedRe-optimise on a LOCKED, SHIPPED or DELIVERED assignment (the node never changes after the lock)None; read the assignment
409release-in-flightRe-optimise while a release is PENDING (state RELEASED)Wait for the node's answer
409node-excludedA candidate on a node that refused this promise revisionInternal guard; the search never proposes an excluded node
409stale-assignment-versionassignmentVersion in the body differs from the current versionGET the assignment and retry with its version, or omit the field
409concurrent-updateTwo writers raced on one aggregate; the loser's version guard failed (the use case already retries once). Not stored: the key is releasedRetry with the same Idempotency-Key; a retry that answers without Idempotency-Replayed executed again
409policy-version-not-nextPUT /sourcing-policy when the stored policy version cannot be incremented (it is at 2147483647, or out of range). Cannot occur in normal operation; the request carries no version, so it is not a stale caller. Not stored: the key is releasedGET /sourcing-policy to read the stored version; an operator repairs sourcing_policies, then the same key retries
409illegal-transitionRe-optimise on UNSOURCEABLE or CANCELLEDNone
422validation-failedlimit not 1 to 500, unknown state, assignmentVersion negative, or an Idempotency-Key over 128 charactersUse the detail text
422candidate-breaks-promiseThe search result's ETA is after deliverByLatestInternal guard
500internal-errorUnmapped error or handler panic; detail is always an unexpected error occurredRead the request failed log line
503dependency-unavailableGET /readyz onlySee the /readyz row above

Idempotency in practice​

  • POST /assignments/{id}/reoptimisations and PUT /sourcing-policy are wrapped; GET never needs a key.
  • The key is global (looked up alone); the stored fingerprint is method + path + body hash. A key with a stored answer replays that answer byte for byte with the header Idempotency-Replayed: true; another method, path or body under it is 409 idempotency-key-reused.
  • What is stored is decided by the replay class of the first answer (ADR 0019): a 2xx, malformed-request and assignment-locked are stored. A RETRYABLE refusal (release-in-flight, node-excluded, stale-assignment-version, candidate-breaks-promise, not-found, concurrent-update, policy-version-not-next, illegal-transition, validation-failed), a 5xx or a panic rolls everything back, the key row included, and is never stored: the same key runs the request again (an answer without Idempotency-Replayed was executed), and a different body under that key is a new request.
  • Two concurrent requests with one new key are serialised by a transaction-scoped advisory lock; the second replays the first if it was stored, and runs the request itself if the first ended RETRYABLE or 5xx.
  • An answer older than 24 hours is not replayed (the read check), and a background purge deletes expired rows: at once at start and then hourly, in batches of 500 (cmd/api/main_purge.go, PurgeExpiredIdempotencyKeys; logs idempotency purge with purged, and idempotency purge failed at ERROR, retried at the next tick). A row a request holds is skipped, never waited for.