---
title: Order creation conflict or failure
summary: Safely investigate failed or repeated Order creation requests and Redis coordination issues.
version: 1.0.0
type: runbooks
order: 2
badges:
  - content: Runbook
    backgroundColor: orange
    textColor: orange
---

## Trigger / Symptom & Blast Radius

`POST /api/v1/orders` returns `409 Conflict`, times out with an ambiguous outcome, fails during concurrent buyer checkouts, or encounters [[container|order-cache]] connectivity errors. Blast radius is active checkout submissions; committed orders in [[container|order-database]] remain safe.

<Admonition type="danger">
	Never flush [[container|order-cache]] or bulk-delete idempotency or lock keys during an incident.
	Clearing Redis removes active duplicate-request markers and buyer write locks, risking duplicate
	orders across concurrent checkouts.
</Admonition>

## Pre-Flight Check

Before retrying any checkout, query [[service|order-api]] to verify whether the order was already persisted in [[container|order-database]], and check Redis responsiveness:

```bash
curl -sS -H "Authorization: Bearer <ADMIN_TOKEN>" "https://<GATEWAY_HOST>/ordering/api/v1/orders?buyerId=<BUYER_ID>&pageIndex=1&pageSize=10"
redis-cli -u "<REDIS_URL>" PING
```

## Quick Recovery Procedure

<Steps>
<Step title="Capture privacy-safe correlation context">

Record `<BUYER_ID>`, `x-request-id`, UTC timestamp, `<ENV>`, and HTTP status code. Exclude street addresses, emails, and other PII from incident tickets.

</Step>
<Step title="Classify the conflict or error in Ordering logs">

Stream [[service|order-api]] logs filtered by `<REQUEST_ID>` and `<BUYER_ID>`:

```bash
az containerapp logs show --name <SERVICE_NAME> --resource-group <RESOURCE_GROUP> --tail 150
```

**`409 Conflict`:** A 1-hour idempotency marker already exists for `<REQUEST_ID>`. If the order exists in Step 1, return its `orderId`; if no order exists, verify whether the original request is still in flight before retrying.

**Concurrent write lock error:** Another checkout for `<BUYER_ID>` holds the 1-minute buyer write lock. Wait for it to finish and re-query `GET /api/v1/orders`.

**`400 Bad Request`:** Client omitted the required `x-request-id` header.

**`429 Too Many Requests`:** Per-user rate limit exceeded; honor `Retry-After`.

</Step>
<Step title="Restore Redis connectivity if unavailable">

If logs show Redis timeouts, restore Azure Managed Redis connectivity without flushing keys, then re-verify [[container|order-database]] before advising the customer to retry.

</Step>
</Steps>

## Verification

Confirm [[service|order-api]] responds with HTTP `200` and only a single order exists for the checkout attempt:

```bash
curl -sS -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer <ADMIN_TOKEN>" "https://<GATEWAY_HOST>/ordering/api/v1/orders?buyerId=<BUYER_ID>&pageIndex=1&pageSize=1"
```

Expected output:

```text
200
```

## Rollback / Escalation

- **Rollback:** Do not manually delete persisted orders; use standard administrative cancellation (`PATCH /api/v1/orders/{id}/cancel`) if a duplicate order was created externally.
- **Escalation:** Escalate persistent Redis outages to [[team|platform-engineering-team]]; escalate idempotency or lock bugs to [[team|commerce-fulfillment-team]].

## Related documentation

- [[flow|user-checkout]] — Checkout validation and snapshot locking.
- [[adr|adr-001-postgresql-order-system-of-record]] — Authoritative role of [[container|order-database]].
