# TranslogCorruptedException: translog corruption detected at position 12345 while recovering shard [my_index][0]

- **ID:** `elasticsearch/translog-corruption-on-recovery`
- **Domain:** elasticsearch
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

The translog file for a shard is corrupted due to a disk error, abrupt shutdown, or filesystem inconsistency, preventing shard recovery.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.10.0 | active | — | — |
| 7.17.0 | active | — | — |
| 8.0.0 | active | — | — |

## Workarounds

1. **Truncate the corrupted translog by removing the translog directory for the affected shard (e.g., `rm -rf /var/lib/elasticsearch/nodes/0/indices/<index-uuid>/0/translog`) and then force a recovery from the primary or replica using `POST _cluster/reroute?retry_failed=true`.** (85% success)
   ```
   Truncate the corrupted translog by removing the translog directory for the affected shard (e.g., `rm -rf /var/lib/elasticsearch/nodes/0/indices/<index-uuid>/0/translog`) and then force a recovery from the primary or replica using `POST _cluster/reroute?retry_failed=true`.
   ```
2. **If the shard is a replica, delete it and reallocate: `POST _cluster/reroute { "commands": [ { "cancel": { "index": "my_index", "shard": 0, "node": "node-1" } } ] }` then let Elasticsearch recreate it from the primary.** (80% success)
   ```
   If the shard is a replica, delete it and reallocate: `POST _cluster/reroute { "commands": [ { "cancel": { "index": "my_index", "shard": 0, "node": "node-1" } } ] }` then let Elasticsearch recreate it from the primary.
   ```

## Dead Ends

- **** — Filesystem repair may not fix translog corruption at the application level; Elasticsearch may still see invalid data. (90% fail)
- **** — The corruption persists in the translog file; restarting will trigger the same error during recovery. (95% fail)
