---
title: Checkout basket cleanup stalled or failed
summary: Investigate Finance basket-cleanup retries without confusing saga progress with Order status.
version: 1.0.0
type: runbooks
order: 1
badges:
  - content: Runbook
    backgroundColor: orange
    textColor: orange
---

## Trigger / Symptom & Blast Radius

An [[entity|order]] exists in [[service|order-api]] but the customer's [[entity|basket]] remains populated, [[service|order-orchestration]] has not reported a cleanup outcome, a cancellation email arrived for a `New` order, or an order disappeared after a basket-deletion failure. Blast radius is post-checkout cleanup and notification consistency; never infer commercial order status from basket contents, Finance state, or emails.

<Admonition type="danger">
	Do not manually transition orders in [[service|order-api]] or edit [[container|order-database]]
	rows to match a timed-out [[service|order-orchestration]] state. Do not copy customer emails or
	PII into incident tickets.
</Admonition>

## Pre-Flight Check

Query the authoritative order status in [[service|order-api]] and check [[service|order-orchestration]] container health:

```bash
curl -sS -H "Authorization: Bearer <ADMIN_TOKEN>" "https://<GATEWAY_HOST>/ordering/api/v1/orders/<ORDER_ID>"
az containerapp show --name <SERVICE_NAME> --resource-group <RESOURCE_GROUP> --query "properties.runningStatus" -o tsv
```

## Quick Recovery Procedure

<Steps>
<Step title="Correlate checkout event and Finance orchestration">

Inspect OpenTelemetry traces and logs for `<ORDER_ID>` across [[service|order-api]] and [[service|order-orchestration]]:

Confirm [[event|UserCheckedOutIntegrationEvent]] was published to <ResourceLink id="bookworm.{env}.ordering.user-checked-out" type="channel">`bookworm.{env}.ordering.user-checked-out`</ResourceLink>.

Inspect the Durable Task orchestration custom status (`OrderId`, `Status`, `BasketDeleted`, `TimeoutRetryCount`, `FailureReason`).

</Step>
<Step title="Inspect Kafka lag and dead-letter queues">

Check consumer lag and DLQ depth across <ResourceLink id="bookworm.{env}.finance.place-order" type="channel">`bookworm.{env}.finance.place-order`</ResourceLink>, <ResourceLink id="bookworm.{env}.basket.delete-complete" type="channel">`bookworm.{env}.basket.delete-complete`</ResourceLink>, <ResourceLink id="bookworm.{env}.basket.delete-failed" type="channel">`bookworm.{env}.basket.delete-failed`</ResourceLink>, and per-service DLQs (<ResourceLink id="bookworm.{env}.basket.dead-letter-queue" type="channel">`bookworm.{env}.basket.dead-letter-queue`</ResourceLink>, <ResourceLink id="bookworm.{env}.ordering.dead-letter-queue" type="channel">`bookworm.{env}.ordering.dead-letter-queue`</ResourceLink>, <ResourceLink id="bookworm.{env}.notification.dead-letter-queue" type="channel">`bookworm.{env}.notification.dead-letter-queue`</ResourceLink>).

</Step>
<Step title="Interpret orchestration outcome and recover dependencies">

**`BasketDeleted: true` and `Status: Placed`:** Cleanup succeeded; [[service|order-api]] keeps the order `New` until explicit completion or cancellation.

**`Status: BasketDeletionFailed`:** [[service|order-api]] soft-deleted the order upon receiving [[command|DeleteBasketFailedCommand]] without changing `Status` to `Cancelled`.

**Retry timer exhausted (`3` attempts, `30m` each):** Finance marked its own state `Cancelled` and sent [[command|CancelOrderCommand]] to [[service|notification-api]] without canceling the commercial order in [[service|order-api]].

Restore any unhealthy dependency ([[service|basket-api]], [[container|basket-database]], [[service|order-orchestration]], or Kafka) so pending messages drain naturally.

</Step>
</Steps>

## Verification

Confirm the authoritative order endpoint returns HTTP `200` (for active orders) and DLQ depth has stopped growing:

```bash
curl -sS -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer <ADMIN_TOKEN>" "https://<GATEWAY_HOST>/ordering/api/v1/orders/<ORDER_ID>"
```

Expected output:

```text
200
```

## Rollback / Escalation

- **Rollback:** No manual state rollback is required once broker/service connectivity is restored; consumers drain queued events idempotently.
- **Escalation:** Escalate repeated [[command|PlaceOrderCommand]] dispatches or soft-delete discrepancies to [[team|commerce-fulfillment-team]] with `<ORDER_ID>` and orchestration timestamps.

<AccordionGroup>
<Accordion title="Troubleshooting edge cases">

| Symptom                                                      | Cause                                                                  | Fix                                                                                           |
| :----------------------------------------------------------- | :--------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- |
| Order is `New`, basket still populated, retries incrementing | [[service\|basket-api]] or Redis unavailable, or message in Basket DLQ | Restore dependency and follow the Basket cleanup failure runbook                              |
| Cancellation email sent, order still `New`                   | Finance exhausted 30m retry loop without canceling Ordering            | Confirm commercial intent with customer; do not assume order is cancelled                     |
| Order returns `404` after checkout                           | Basket deletion failed and triggered soft delete                       | Confirm `BasketDeletionFailed` in Finance and escalate to [[team\|commerce-fulfillment-team]] |

</Accordion>
</AccordionGroup>

## Related documentation

- [[flow|user-checkout]] — End-to-end checkout and cleanup flow.
- [[adr|adr-005-finance-separate-workflow-and-order-status]] — Why Finance saga state is separate from Order status.
