---
title: Recover a failed Catalog rating projection
summary: Investigate and compensate when Catalog cannot apply a feedback rating change because the Book is missing.
version: 1.0.0
type: runbooks
order: 1
badges:
  - content: Runbook
    backgroundColor: orange
    textColor: orange
---

## Trigger / Symptom & Blast Radius

[[service|catalog-api]] publishes [[event|BookUpdatedRatingFailedIntegrationEvent]] on <ResourceLink id="bookworm.{env}.catalog.book-update-rating-failed" type="channel">`bookworm.{env}.catalog.book-update-rating-failed`</ResourceLink>, or a created [[entity|feedback]] record in [[service|rating-api]] fails to project onto a [[entity|book]] in [[service|catalog-api]]. Blast radius is limited to orphaned review cleanup for a missing book; never communicate this compensation to customers as a manual deletion.

<Admonition type="danger">
	Never delete feedback records by `bookId` alone. Compensation targets only the exact `FeedbackId`
	reported by [[event|BookUpdatedRatingFailedIntegrationEvent]].
</Admonition>

## Pre-Flight Check

Capture `FeedbackId`, correlation ID, and `<ENV>` from the failure event, then verify whether `<BOOK_ID>` exists in [[service|catalog-api]] and query [[container|rating-database]]:

```bash
curl -sS -o /dev/null -w "%{http_code}\n" "https://<GATEWAY_HOST>/catalog/api/v1/books/<BOOK_ID>"
```

```sql
SELECT c.id, c.bookId, c.rating, c.createdAt FROM c WHERE c.id = "<FEEDBACK_ID>";
```

## Quick Recovery Procedure

<Steps>
<Step title="Confirm the book is actually missing">

If the Catalog check returns **`404 Not Found`**, the book is absent and compensation is valid. Continue to Step 2.

If the Catalog check returns **`200 OK`**, **stop immediately**. Do not delete the feedback record—this indicates a transient database or contract fault. Escalate to [[team|catalog-experience-team]].

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

Check lag and DLQ depth across <ResourceLink id="bookworm.{env}.rating.feedback-create" type="channel">`bookworm.{env}.rating.feedback-create`</ResourceLink>, <ResourceLink id="bookworm.{env}.catalog.book-update-rating-failed" type="channel">`bookworm.{env}.catalog.book-update-rating-failed`</ResourceLink>, <ResourceLink id="bookworm.{env}.catalog.dead-letter-queue" type="channel">`bookworm.{env}.catalog.dead-letter-queue`</ResourceLink>, and <ResourceLink id="bookworm.{env}.rating.dead-letter-queue" type="channel">`bookworm.{env}.rating.dead-letter-queue`</ResourceLink>. Stream [[service|rating-api]] logs for Cosmos DB or Redis errors:

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

</Step>
<Step title="Run recovery through the standard compensation handler">

Restore any unhealthy dependency ([[container|rating-database]], Redis, or Kafka) and replay recoverable messages from <ResourceLink id="bookworm.{env}.rating.dead-letter-queue" type="channel">`bookworm.{env}.rating.dead-letter-queue`</ResourceLink>. The compensation handler deletes the orphaned document and invalidates [[container|rating-cache]] without emitting [[event|FeedbackDeletedIntegrationEvent]].

</Step>
</Steps>

## Verification

Re-run the [[container|rating-database]] query for `<FEEDBACK_ID>` and confirm `0` documents are returned while DLQ depth stops growing:

```sql
SELECT VALUE COUNT(1) FROM c WHERE c.id = "<FEEDBACK_ID>";
```

Expected output:

```json
[0]
```

## Rollback / Escalation

- **Rollback:** Compensation deletes only confirmed orphaned reviews for `404` books; if a book was restored, the customer must re-submit their review.
- **Escalation:** Escalate `200 OK` false-failure events or persistent DLQ errors to [[team|catalog-experience-team]].

## Related documentation

- [[flow|feedback-publication]] — End-to-end review projection and compensation flow.
- [[adr|adr-003-compensate-invalid-feedback-after-catalog-rejection]] — Compensation decision record.
