Shipping & Tracking runbook
Issues the shipping label of each package (the only place outside customer-ordering that ever sees a ship-to address — stored only as an AES-256-GCM snapshot) and owns every package's journey: one customer-visible timeline consolidated from vendor, linehaul and last-mile facts, ending in delivered, returned or lost. Domain-driven design study: no real company, brand or dataset — all names and figures are synthetic (see the disclaimer in README.md). Contracts: apis/openapi.yaml, apis/asyncapi.yaml; decisions: docs/adr/.
Runtime shape
One api Deployment, one process (cmd/api/main.go, the composition root — there is no in-memory mode, no log sink, no worker that is off):
-
REST on
HTTP_ADDR(default:8080), chi router (internal/adapters/inbound/http/server.go):Route Use case POST /labelsissue a label (calls customer-ordering, seals the snapshot, starts the journey) POST /return-labelsissue the reverse label of a customer return (calls customer-ordering; the destination prefix comes from the local node_destinationsview when the body namesdestinationNodeId, ADR 0018)POST /labels/{labelRef}/voidsvoid before handover GET /journeys/{trackingNumber}the timeline POST /journeys/{trackingNumber}/scansrecord a scan -
The transactional-outbox relay (
internal/adapters/outbound/outbox/relay.go): pollsoutbox_eventseveryOUTBOX_RELAY_INTERVALand publishes to Kafka topicretailnetwork.shipping-and-tracking.events(internal/adapters/outbound/kafka/encoder.go); each row is one pre-encoded CloudEvents message inserted in the SAME transaction as the aggregate. -
Four consumers (
internal/adapters/inbound/kafka/handlers.go):retailnetwork.vendor-connectivity.events,retailnetwork.linehaul-transportation.events,retailnetwork.last-mile-delivery.events,retailnetwork.offer-availability.events. A transient handler failure retries the same message with capped exponential backoff, then dead-letters to<topic>.dlq(consumer.go,deadletter.go); a message that is not a valid CloudEvent, or of a type the consumer does not act on, is skipped with a WARN instead. -
Three scheduler jobs (
cmd/api/main.gostartJobs,internal/scheduler/scheduler.go; every tick logsscheduled job finishedwithjobandresult, a failed tick is logged and retried on the next tick):silence-sweep(SILENCE_SWEEP_INTERVAL, default 5m, runs on start): the ExceptionOnSilence policy — a watched journey silent past its tier/state window (6h same-day, 24h next-day, 48h two-day, 72h standard, 12h out-for-delivery;internal/domain/journey/types.go) gets aNO_SCANexception raised;PackageLost48h after an unanswered exception on an in-transit journey. Log line:raised=<n> lost=<n> conflicts=<n>.ship-to-purgeandhousekeeping(bothHOUSEKEEPING_INTERVAL, default 1h, both run on start):ship-to-purgedeletesship_to_snapshots30 days after the journey closed (ADR 0002 A9);housekeepingpurges the technical tables per ADR 0005 —idempotency_keysafter 24h, already-relayedoutbox_eventsrows after 7d,processed_events(inbox) after 30d (cmd/api/config.goretention consts).
Two optional read-only deployables run beside it, both off by default: cmd/mcp (ADR 0006) and cmd/a2a (ADR 0009, the A2A agent: get_journey over JSON-RPC at / and /a2a, Agent Card at /.well-known/agent-card.json, A2A_ADDR default :8093). Neither dials Kafka nor runs the relay, the consumers or the jobs; cmd/a2a refuses to boot without DATABASE_URL and A2A_AGENT_URL, and with a2a.enabled=true the chart defaults A2A_AGENT_URL to the component's in-cluster Service URL (override with a2a.agentUrl).
Any consumer, job loop or the relay returning on its own makes the process exit non-zero so the orchestrator restarts it (cmd/api/main.go watchWorkers; a worker death logs consumer stopped / outbox relay stopped). Shutdown order: /readyz flips 503 → wait SHUTDOWN_DRAIN_DELAY (5s) → HTTP drain (≤10s) → consumers+jobs (≤10s) → the relay LAST so nothing committed is stranded (≤10s); the chart refuses a terminationGracePeriodSeconds not greater than 30s + the delay (45s default).
Deployment
- Image: one image (
Dockerfile) carries everycmd/*binary in/app/(api,mcp,a2a);ENTRYPOINT ["./api"], exposes 8080, 8090 and 8093, runs as uid 1000, writes nothing to disk. Published toghcr.io/iqvo/shipping-and-trackingby thedocker-publishjob on push tomain(.github/workflows/ci.yml). - Chart:
charts/shipping-and-tracking/, packaged asshipping-and-tracking-<version>.tgzby thereleasejob and pushed tooci://ghcr.io/iqvo. The default component is theapiDeployment (Service port 80 to 8080). Optional components, all off by default:mcp.enabled(command/app/mcp, port 8090),a2a.enabled(command/app/a2a, port 8093) andfrontend.enabled(the nginx pod serving theweb/console remote, reached through the web gateway, never routed by this chart). Kong routes for MCP and A2A aremcp.route.enabled(/api/mcp/shipping-and-tracking) anda2a.route.enabled(/api/a2a/shipping-and-tracking). - Required values: the chart refuses to render without
database.urlordatabase.existingSecret, withoutkafka.brokers,config.customerOrderingUrland the fourconfig.*ConsumerGroupvalues, without the crypto Secret (crypto.existingSecretor both inline values), and with aterminationGracePeriodSecondsnot greater than 30 s plusconfig.shutdownDrainDelay(values.yaml,tests/render_test.sh). - Probes (api):
startupProbeandlivenessProbeon/healthz,readinessProbeon/readyz.cmd/mcpandcmd/a2aprobe/healthzfor all three (they have no readiness dependency check). - Scaling:
replicaCount: 1by default;autoscaling.api.enabledadds an HPA (1 to 4 replicas at 70% CPU). More than one api replica is safe by design (the relay claims rows withSKIP LOCKED, consumer groups are stable, the inbox dedupes inside the handler transaction) but has not been load-tested. - Migrations: embedded in the binary and applied with golang-migrate at every boot; its advisory lock makes concurrent starts safe. There is no separate migration job. Two databases, two lists:
- OLTP database (
internal/adapters/outbound/postgres/migrations/, applied bycmd/api,cmd/mcpandcmd/a2a):0001_schema(eight tables:shipping_labels,ship_to_snapshots,package_journeys,journey_scans,catalog_dimensions,outbox_events,processed_events,idempotency_keys) and0002_idempotency_key_global(theidempotency_keysprimary key becomeskeyalone, ADR 0010; it first deletes rows that reuse a key on two routes, keeping the oldest) and0003_journey_eta(three nullable ETA columns onpackage_journeys, ADR 0013). The later ones follow the same rule, one per ADR; the newest is0008_node_destinations(thenode_destinationsread model, ADR 0018), whose table starts EMPTY and needs the rebuild described under Rebuilding the node destination view. UseMIGRATIONS_DATABASE_URL(direct DSN) whenDATABASE_URLgoes through PgBouncer. - Analytical database (
analytics/migrations/, applied bycmd/st-projectorthroughANALYTICS_DATABASE_URL, a direct DSN;cmd/st-reportsruns no migration):0001_delivery_facts(four tables:analytics_processed_events,package_labels,journey_scans,package_outcomes). It is a projection of the service's own topic, so it can be dropped and rebuilt by replaying the topic (ADR 0012).
- OLTP database (
What readiness waits for
/readyz (api only) is 200 when the cached verdict (3 s TTL, 2 s bound per round) says both Postgres (pool.Ping) and Kafka (a metadata request against KAFKA_BROKERS) answer. It does not wait for the consumers to have joined their groups or for the relay to be caught up. During shutdown it returns 503 {"status":"not_ready"} for SHUTDOWN_DRAIN_DELAY before the listener drains.
Kafka topics and consumer groups
| Direction | Topic | Group (env var) | Dead-letter topic |
|---|---|---|---|
| produce | retailnetwork.shipping-and-tracking.events | none | none |
| consume | retailnetwork.vendor-connectivity.events | VENDOR_CONSUMER_GROUP | retailnetwork.vendor-connectivity.events.dlq |
| consume | retailnetwork.linehaul-transportation.events | LINEHAUL_CONSUMER_GROUP | retailnetwork.linehaul-transportation.events.dlq |
| consume | retailnetwork.last-mile-delivery.events | LASTMILE_CONSUMER_GROUP | retailnetwork.last-mile-delivery.events.dlq |
| consume | retailnetwork.offer-availability.events | CATALOG_CONSUMER_GROUP | retailnetwork.offer-availability.events.dlq |
| consume | retailnetwork.node-topology.events | ST_AREAS_CONSUMER_GROUP (config.areasConsumerGroup; feeds area_modes, pickup_points and node_destinations; each fold has its own inbox identity) | retailnetwork.node-topology.events.dlq |
consume (cmd/st-projector, ADR 0012) | retailnetwork.shipping-and-tracking.events (its own topic) | ANALYTICS_CONSUMER_GROUP (shipping-and-tracking-analytics) | retailnetwork.shipping-and-tracking.analytics.dlq (poison only; transient failures retry forever) |
Source: internal/adapters/inbound/kafka/handlers.go (topics), deadletter.go (DLQSuffix = ".dlq"), internal/adapters/outbound/kafka/encoder.go (produced topic). Group ids are chart values and must stay stable across restarts so a rescheduled pod resumes from its committed offsets.
Dependencies
- Postgres via PgBouncer —
DATABASE_URL(pooled) for the runtime pool;MIGRATIONS_DATABASE_URL(direct DSN, optionalsecretKeyRef, falls back toDATABASE_URL) used only by the boot migrations (cmd/api/main.goopenPool). Schema:internal/adapters/outbound/postgres/migrations/(0001_schema,0002_idempotency_key_global). The analytical database has its own schema inanalytics/migrations/and its own DSNs (see Migrations above). - Kafka —
KAFKA_BROKERS, comma-separated; dialed lazily on first send/read, so a broker outage never blocks boot. Topics are auto-created by the first writer (no manual creation step). - customer-ordering REST —
CUSTOMER_ORDERING_URL; the model's one synchronous call,GET {base}/orders/{orderId}/ship-to(internal/adapters/outbound/customerordering/), made before the label transaction opens. 404 →ports.ErrNotFound; any other failure →ports.ErrShipToUnavailable. - Secrets (local cluster):
shipping-and-tracking-db(DATABASE_URL,MIGRATIONS_DATABASE_URL) andshipping-and-tracking-crypto(SHIP_TO_ENCRYPTION_KEY,STOP_KEY_SECRET). Chart keys:database.existingSecret,crypto.existingSecret.
Health
GET /healthz— liveness only; never flipped by shutdown or by a dependency (internal/adapters/inbound/http/readiness.go). Used by the startup and liveness probes.GET /readyz— 200 only while a Postgres ping AND a Kafka broker metadata request succeed; the verdict is cached 3s and one round of checks is bounded 2s. 503{"status":"not_ready"}while draining; 503 problem+jsondependency-unavailablenaming the failed dependency (postgresorkafka). Used by the readiness probe.- Writes are NOT gated on readiness: a
POST /labelscommits label + encrypted snapshot + outbox row in ONE transaction; only the relay ever touches Kafka. So with Kafka down, REST writes are still accepted (201 forPOST /labels, 200 for the others) and queue inoutbox_events(verified bycmd/api/e2e_integration_test.go: Kafka removed →/readyzgoes 503,/healthzstays 200). With Postgres down, REST writes fail (500internal-error).
Configuration
Every variable cmd/api reads (cmd/api/config.go, header of cmd/api/main.go) and the chart value that sets it (charts/shipping-and-tracking/values.yaml, rendered by templates/deployment.yaml + templates/configmap.yaml; tests/render_test.sh asserts the mapping is total):
| Env var | Chart value | Default / notes |
|---|---|---|
HTTP_ADDR | config.httpAddr | :8080 |
LOG_LEVEL | config.logLevel | info (debug|warn|error) |
OTEL_SERVICE_NAME | otel.serviceName | shipping-and-tracking (-mcp / -a2a suffix for the mcp and a2a components); ADR 0008 |
OTEL_EXPORTER_OTLP_ENDPOINT | otel.endpoint | localhost:4317 without the chart; export never blocks |
SERVICE_VERSION / ENVIRONMENT | image.tag (appVersion when empty) / environment | dev / local without the chart |
EVENT_PUBLISHER | config.eventPublisher | kafka only; log is refused at render and at boot |
KAFKA_BROKERS | kafka.brokers | REQUIRED |
CUSTOMER_ORDERING_URL | config.customerOrderingUrl | REQUIRED, absolute http(s) URL |
CUSTOMER_ORDERING_TIMEOUT | config.customerOrderingTimeout | 3s; bounds one GetShipTo call |
SHIP_TO_ENCRYPTION_KEY | crypto.existingSecret / crypto.shipToEncryptionKey | REQUIRED, base64 of 32 bytes |
STOP_KEY_SECRET | crypto.existingSecret / crypto.stopKeySecret | REQUIRED, ≥16 bytes; HMAC-SHA-256 of the stopKey |
DATABASE_URL | database.existingSecret (database.existingSecretKey) | REQUIRED, pooled DSN |
MIGRATIONS_DATABASE_URL | database.migrationsExistingSecretKey | optional, direct DSN; falls back to DATABASE_URL |
VENDOR_CONSUMER_GROUP | config.vendorConsumerGroup | REQUIRED; likewise LINEHAUL_, LASTMILE_, CATALOG_CONSUMER_GROUP from config.linehaulConsumerGroup, config.lastmileConsumerGroup, config.catalogConsumerGroup — stable service-prefixed ids, never the pod name |
OUTBOX_RELAY_INTERVAL | config.outboxRelayInterval | 1s |
OUTBOX_MAX_ATTEMPTS | config.outboxMaxAttempts | 20; 0 = unlimited |
SILENCE_SWEEP_INTERVAL | config.silenceSweepInterval | 5m |
HOUSEKEEPING_INTERVAL | config.housekeepingInterval | 1h (ship-to purge + technical-table purge) |
SHUTDOWN_DRAIN_DELAY | config.shutdownDrainDelay | 5s; 0 disables; must fit the pod grace period |
Alerts and dashboards
- Grafana dashboard uid
warehouse-shipping-and-tracking; pod-restart alerts exist for this Deployment. - One business metric is instrumented (ADR 0008):
shipping.labels.issuedbyoutcome(issued/rejected) andreason. A risingship-to-unavailablemeans customer-ordering cannot be reached; a risinginternal-errormeans this service is failing. Dashboards come from warehouse-infra.
Failure modes
Pod crash-loops at boot
- Symptom:
CrashLoopBackOff; the container exits 1 immediately, before binding. - Diagnosis:
kubectl -n warehouse-systems logs deploy/shipping-and-tracking --previous— the exit message names the missing variable, never the secret value (cmd/api/config.goloadConfigvalidates everything before anything is opened or bound). - Likely causes: missing/invalid
SHIP_TO_ENCRYPTION_KEY(must be base64 of 32 bytes) orSTOP_KEY_SECRETfrom Secretshipping-and-tracking-crypto— the ship-to snapshot is ALWAYS encrypted, there is no clear-text mode;EVENT_PUBLISHER=log; an empty consumer-group var; a non-absoluteCUSTOMER_ORDERING_URL; missingDATABASE_URL/KAFKA_BROKERS. Slow Postgres also means a slow start: migrations and the first ping retry with bounded backoff (internal/bootretry). - Action: fix the Secret/ConfigMap value, then the next restart succeeds.
Postgres unreachable
- Symptom:
/readyz503 namingpostgres; REST writes fail; relay, consumers and jobs log errors. - Diagnosis: check PgBouncer/Postgres ahead of the service.
- Action: none inside this service — every loop retries; recovery is automatic once the database answers. If migrations can never run, the pod never becomes ready.
Kafka unreachable
- Symptom:
/readyz503 namingkafka;/healthzstays 200;outbox_eventsbacklog grows. - Diagnosis: confirmed Kafka outage (broker list in
KAFKA_BROKERS). - Action: none — REST writes are still accepted and queued in
outbox_events; on recovery the relay drains the backlog inidorder. No committed event is lost while Postgres is up (cmd/api/e2e_integration_test.go).
Outbox relay row parked after max attempts
- Symptom: log line
outbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the cause(internal/adapters/outbound/outbox/relay.go). - Diagnosis:
SELECT id, event_id, topic, attempts, last_error FROM outbox_events WHERE published_at IS NULL AND attempts >= 20;(the cap isOUTBOX_MAX_ATTEMPTS, default 20). - Action: after fixing the cause (usually Kafka), re-arm the row:
UPDATE outbox_events SET attempts = 0 WHERE id = <id>;. The relay republishes the sameevent_id(columnoutbox_events.event_id, minted once at encode time), so consumers stay idempotent.
Consumer lag or retry logs
- Symptom: repeated retry/fetch-error logs for one consumer; group lag grows.
- Diagnosis: an offset commits only after its handler returns nil — a failing message retries in place with capped backoff, then dead-letters to
<topic>.dlq. A consumed topic whose producer has not written yet only logs reader retries: topics are auto-created by the first writer, so a silent vendor/linehaul/last-mile/catalog feed is an upstream gap, not a fault of this service. - Action: inspect
<topic>.dlqfor poison messages; check the producing context before touching this one.
customer-ordering REST unreachable
- Symptom:
POST /labelsanswers 503ship-to-unavailable(internal/adapters/inbound/http/errors.gomapsports.ErrShipToUnavailable). - Diagnosis: customer-ordering down or slow; the call is bounded by
CUSTOMER_ORDERING_TIMEOUT(3s) and precedes the transaction, so it never holds a lock. - Action: only label issuing degrades — void, scans, queries and all consumers work; recovery is automatic, and retrying the same
Idempotency-Keyis safe.
Operational actions
- Restart:
kubectl -n warehouse-systems rollout restart deploy/shipping-and-tracking; history/image:kubectl -n warehouse-systems rollout history deploy/shipping-and-tracking. - Logs (Grafana Loki, label
app=shipping-and-tracking): JSON slog on stdout. Boot errors name the missing variable; job ticks logscheduled job finishedwithjob/result; worker deaths logconsumer stopped/outbox relay stoppedimmediately before the non-zero exit. - Crypto key rotation: every snapshot stores its sealing key's id in
ship_to_snapshots.key_id(first 8 hex chars of the key's SHA-256,internal/adapters/outbound/crypto/crypto.go) precisely so a rotation can tell which key sealed which row; opening with a different key fails (ErrBadKey). No production path reads a snapshot back (write-only; purged 30d after the journey closes — the migration comment says "never read back by a response"), so rotatingSHIP_TO_ENCRYPTION_KEYbreaks no live read path — but pre-rotation snapshots become unopenable by the new key. RotatingSTOP_KEY_SECRETchanges thestop_key/postal prefix derived for NEW labels; existingshipping_labelsrows keep theirs.
Rebuilding the node destination view
node_destinations (ADR 0018) holds, per node of node-topology, the destination prefix of a return label that names its destination by destinationNodeId. It is fed by NodeRegistered, which node-topology emits ONCE per node. Migration 0008 creates the table empty, and every NodeRegistered consumed before it fed only pickup_points, so every node registered before the deploy is unknown to the view until it is rebuilt. This repository has no replay tooling: the rebuild is a change of consumer group.
What the inbox does to a redelivered id. A claim is the pair (consumer, CloudEvents id) in processed_events, written in the transaction of the effect and kept 30 days. The pickup_points fold claims as node-topology; the node_destinations fold claims as node-topology.node-destinations; the area_modes fold claims as node-topology.area-modes since ADR 0019 (before it, as node-topology). On a replay of the topic:
- The
node_destinationsfold has never claimed those ids, so eachNodeRegisteredis applied once; a second delivery of the same id is skipped (TestNoteNodeDestinationSkipsARedeliveredEventID). - The
pickup_pointsfold skips every id it claimed within the last 30 days: the table does not change (TestAReplayedNodeRegisteredFillsTheNodeViewAndLeavesThePickupPointAlone, both ininternal/application/usecases/node_destinations_test.go). - An id older than 30 days is no longer claimed and IS applied again by the
pickup_pointsfold. It applies a replayedNodeRegisteredas a registration applied again: station and prefix are written with the same values and the state is kept, so a point is not demoted toPROPOSED(ADR 0016, addendum 2026-11-18). A replayed status fact sets the state it names, so a point walks through its recorded history and ends in its current state (see Repairing the pickup point view for what that means for a label). This arises only if the topic retains more than 30 days. - A message that was dead-lettered the first time is dead-lettered again: expect duplicates on
retailnetwork.node-topology.events.dlq.
The dependency. The replay only finds what the topic still retains. A node whose NodeRegistered is past the topic's retention cannot be restored this way and stays 409 destination-prefix-unavailable. This service has no other source: it never calls node-topology, and node-topology does not publish a node's registration a second time.
Procedure, to be finished before any caller sends destinationNodeId:
- Deploy the version that carries migration
0008. - For every node id a caller will send, confirm that the topic still holds its registration:
kafka-console-consumer.sh --bootstrap-server "$KAFKA_BROKERS" --topic retailnetwork.node-topology.events --from-beginning --timeout-ms 30000 | grep NodeRegistered | grep '"nodeId":"<node id>"'. No line for a node means step 5 will not find it either: stop and escalate, do not enable the caller for that node. - Set
config.areasConsumerGroup(ST_AREAS_CONSUMER_GROUP) to a group id that has never existed, for exampleshipping-and-tracking-areas-r2, wherever the deployment sets it, and roll out. A group with no committed offset starts at the first retained offset (kafka-go's defaultStartOffset, whichreaderConfigininternal/adapters/inbound/kafka/kafka.goleaves unset), so the consumer reads the whole topic again. - Wait until the new group has no lag:
kafka-consumer-groups.sh --bootstrap-server "$KAFKA_BROKERS" --describe --group shipping-and-tracking-areas-r2. - Verify the view:
SELECT node_id, postal_prefix, updated_at FROM node_destinations WHERE node_id IN (...);. Every node a caller will send must have a row with a non-emptypostal_prefix. An empty prefix means the node's registered postal code has no letter or digit from A-Z 0-9 and must be corrected in node-topology. - Keep the new group id; it is now the stable one. (Going back to the old id is harmless, its committed offsets resume and every id in between is already claimed, but it gains nothing.)
A caller enabled earlier is refused, not stuck: a request for a node the view does not hold answers 409 destination-prefix-unavailable, and that refusal is not stored under the caller's Idempotency-Key (ADR 0018). The caller retries the same request with the same key; it is executed again each time and is served as soon as the node's row exists. Until then no return label can be issued for that node, which is why the rebuild comes first.
Repairing the pickup point view
pickup_points (ADR 0016) holds node-topology's pickup points: serving station, prefix and state. Every version before the fix of 2026-11-18 folded a status fact (NodeActivated, NodeSuspended, NodeRetired) as a whole row, so a database that ran one of them is damaged in three ways:
- every pickup point that received a status fact has
station_node_id = ''andpostal_prefix = ''. A label for it was never issued:POST /labelsanswered 422validation-failedwith the detaildestinationPostalPrefix must be 1 to 16 characters from A-Z 0-9; - every node of another type that received a status fact has a row of its own, with both columns empty;
- a retired point has no row (it was deleted; it is now kept as
RETIRED).
The fix stops the damage and repairs nothing: station and prefix come from NodeRegistered alone, which node-topology emits ONCE per node, and this service has no other source. No migration is involved. This repository has no replay tooling: the repair is the registrations applied again.
What the inbox does to a redelivered id. The pickup-point fold claims every node fact as (node-topology, CloudEvents id) in processed_events; claims are kept 30 days. Since ADR 0019 no other fold claims under that identity (the area_modes fold did before, and now claims as node-topology.area-modes). On a replay of the topic under a new consumer group:
- a
NodeRegisteredwhose claim still stands is SKIPPED, and the blank row stays blank. A new consumer group alone repairs only the points whose registration was consumed more than 30 days ago; - once the claims of that identity are cleared, the replayed
NodeRegisteredrestores station and prefix and keeps the point's state.
Both halves are TestAReplayedRegistrationRepairsABlankedRowOnlyOnceItsClaimIsCleared (internal/adapters/inbound/kafka/handlers_pickup_points_test.go). So the claims of node-topology have to be cleared. Clearing them touches no other fold. What the replay itself does to the other folds of the topic: each claims under its own identity, which is NOT cleared. node_destinations (node-topology.node-destinations) skips what it claimed, and rewrites the same prefix for an id older than 30 days. area_modes (node-topology.area-modes) skips what it claimed under that identity and applies again, under the assignment-version guard, what it had claimed only as node-topology before ADR 0019: that is the replay of Backfilling the delivery station of the areas, so one replay serves both.
What the replay does to a point's state. The status facts are replayed too, in their original order. A point that is ACTIVE now and was suspended once is SUSPENDED between its replayed NodeSuspended and the NodeActivated that followed. A point retired before the fix has no row: its replayed registration inserts it PROPOSED, its NodeActivated makes it ACTIVE and its NodeRetired makes it RETIRED for good. All facts of a node are on one partition and are replayed back to back, so each of these moments is short, but a pickup label asked in one of them gets the answer of that moment. A refusal in such a moment does no lasting harm: 422 pickup-point-unavailable is not stored under the caller's Idempotency-Key, so the caller's retry with the same key is executed again and served. A label issued to a retired point in the moment it is replayed as ACTIVE is a real label, though. Run the repair while no pickup labels are being requested.
The dependency. The replay only finds what the topic still retains. A point whose NodeRegistered is past the topic's retention cannot be repaired this way: its row stays blank (or absent) and its labels stay refused. This service never calls node-topology, and node-topology does not publish a registration a second time.
Procedure
- Deploy the version that carries the fix (no migration).
- List the damage:
SELECT id, state, updated_at FROM pickup_points WHERE postal_prefix = '' ORDER BY id;. For every pickup point among those ids, and for every pickup point that has no row at all, confirm that the topic still holds its registration:kafka-console-consumer.sh --bootstrap-server "$KAFKA_BROKERS" --topic retailnetwork.node-topology.events --from-beginning --timeout-ms 30000 | grep NodeRegistered | grep '"nodeId":"<node id>"'. The line also tells the node's type: an id whosenodeTypeis notPICKUP_POINTis one of the rows that should never have existed. No line for a pickup point means the replay will not repair it: escalate to node-topology's owners, who hold its station and postal code. - Clear the claims of the pickup-point fold:
DELETE FROM processed_events WHERE consumer = 'node-topology';. - Set
config.areasConsumerGroup(ST_AREAS_CONSUMER_GROUP) to a group id that has never existed, for exampleshipping-and-tracking-areas-r4(not an id an earlier rebuild or backfill already used), and roll out. A group with no committed offset starts at the first retained offset, so the consumer reads the whole topic again. - Wait until the new group has no lag:
kafka-consumer-groups.sh --bootstrap-server "$KAFKA_BROKERS" --describe --group shipping-and-tracking-areas-r4. - Verify:
SELECT id, station_node_id, postal_prefix, state FROM pickup_points ORDER BY id;. Every pickup point has a non-emptypostal_prefix, and its state is the one node-topology reports for it. - Remove the rows of nodes that are not pickup points:
DELETE FROM pickup_points WHERE postal_prefix = '';, after checking each remaining id against step 2. A registration always carries a postal code, so after the replay an empty prefix is a node of another type, or a pickup point whose registration the topic no longer holds (the escalation of step 2: deleting that row changes its refusal from 422validation-failedto 422pickup-point-unavailable, nothing else). The fixed fold never writes such a row again. - Keep the new group id; it is now the stable one.
A restored prefix is always usable by a label: node-topology refuses to register a PICKUP_POINT whose postal code is not wholly A-Z 0-9, so a code with a separator such as 07750-000 belongs to a node of another type, which this view does not keep (ADR 0016, addendum 2026-11-18).
Backfilling the delivery station of the areas
area_modes.delivery_station_node_id (ADR 0019, migration 0009) is the station published as destinationStationNodeId on LabelIssued. The migration adds the column NULL: every row stored before it has no station, and a label of its prefix is issued without the field (the legacy payload) until the row is filled. A row fills when a ServiceAreaAssigned of its prefix is applied that brings a station and whose assignmentVersion is greater than, or equal to, the stored one (the guard lets an equal version write only into a NULL station, and never replaces a stored station with an equal version).
Two ways, either is enough:
- Replay the topic. The area fold claims its ids as
node-topology.area-modes, an identity that has never claimed the ids it claimed before ADR 0019 asnode-topology, so a replay applies them again. Setconfig.areasConsumerGroup(ST_AREAS_CONSUMER_GROUP) to a group id that has never existed, for exampleshipping-and-tracking-areas-r3, roll out, and wait until the group has no lag (kafka-consumer-groups.sh --describe). Both other folds of the same topic are idempotent under the replay:node_destinationsskips the ids it claimed under its own identity, andpickup_pointsskips what it claimed within 30 days (the caveat above applies to older ids). It only finds what the topic still retains. - Have node-topology emit the assignment again, at the same
assignmentVersionor a newer one; the event is a new CloudEvents id.
Verify: SELECT postal_prefix, assignment_version, delivery_station_node_id FROM area_modes WHERE delivery_station_node_id IS NULL; lists the prefixes still without a station. A prefix that stays NULL has no retained or re-emitted assignment, or node-topology named no valid station for it. Events already published are never amended: only labels issued after the fill carry the station.