> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opal.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Redis crash recovery

> How self-hosted Opal's embedded Redis recovers after a host crash, and how to change its recovery limit.

This page applies only to the embedded Redis in self-hosted Opal. If you use an external Redis, your provider controls these settings.

## How Redis recovers after a crash

If the machine running Redis stops suddenly (a kernel panic, a power loss, or a cloud host failure), the end of Redis's data file can be left damaged, and Redis won't start.

Opal sets `aof-load-corrupt-tail-max-size` to 33554432 bytes (32 MiB). If the damaged end of the file is smaller than this limit, Redis deletes everything from the first damaged byte to the end of the file, starts, and logs `corrupt AOF file tail`. If it's larger, Redis doesn't start and leaves the file as it is. See [If Redis still won't start](#if-redis-still-wont-start).

The deleted data is usually background work queued just before the crash, such as an access change or a notification, and that work may not run. Contact Opal support if an access change made just before a crash didn't take effect.

## Check the setting

Replace `<namespace>` with the namespace you installed Opal in and run:

```bash theme={null}
kubectl exec -n <namespace> opal-web-redis-master-0 -c redis -- \
  sh -c 'REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli CONFIG GET aof-load-corrupt-tail-max-size'
kubectl exec -n <namespace> opal-web-redis-sentinel-event-streaming-node-0 -c redis -- \
  sh -c 'REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli CONFIG GET aof-load-corrupt-tail-max-size'
```

If the command prints `0` or nothing, your Opal version predates this setting. [Update Opal](https://docs.opal.dev/docs/update-self-hosted-opal.md) to get it.

## Change the setting

A higher limit lets Redis recover from more crashes by itself, but each recovery can delete more data. Set the limit to `0` if you want a person to review every damaged file before any data is removed.

Changing the limit restarts both Redis deployments without losing data. Background work pauses while they restart.

> [tab] Admin console
>
> Go to **Config**. Under **Storage**, set **Embedded Redis crash repair limit (bytes)**, then deploy the new version.

> [tab] Helm
>
> Set the same value for both Redis deployments in your `values.yaml`, then run `helm upgrade`:
>
> ```yaml theme={null}
> redis:
>   aofLoadCorruptTailMaxSize: 33554432
> redis-sentinel-event-streaming:
>   aofLoadCorruptTailMaxSize: 33554432
> ```

## After Redis repairs the file

After a host crash, check each Redis pod's log:

```bash theme={null}
kubectl get pods -n <namespace> | grep redis
kubectl logs -n <namespace> <pod> -c redis | grep 'corrupt AOF file tail'
```

Redis's automatic repair can leave an unfinished transaction at the end of the file. For each pod that logged the message, rewrite its data file once Opal is back up. This removes the unfinished transaction, so a later restart doesn't apply part of it:

```bash theme={null}
kubectl exec -n <namespace> <pod> -c redis -- \
  sh -c 'REDISCLI_AUTH="$REDIS_PASSWORD" redis-cli BGREWRITEAOF'
```

## If Redis still won't start

If the damage is larger than the limit, the Redis pod restarts in a loop (`CrashLoopBackOff`). Read the log from its last attempt:

```bash theme={null}
kubectl logs -n <namespace> <pod> -c redis --previous
```

Redis suggests a value for `aof-load-corrupt-tail-max-size`; the limit must be at least one more than that. Before you change anything, take a snapshot of Redis's volume, then contact Opal support. After you raise the limit and deploy, delete the crash-looping pod (`kubectl delete pod -n <namespace> <pod>`) so it picks up the new value; this doesn't touch its volume. Don't delete the volume: that removes all queued work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.