In this lesson, you will learn how to identify and resolve metadata inconsistencies by inspecting manifest lists and snapshots to keep your data warehouse healthy.
When working with modern lakehouse formats like Delta Lake or Apache Iceberg, the "truth" of your data lives in the metadata—specifically the transaction logs, manifest files, and snapshots. Sometimes, concurrent write operations or interrupted processes can lead to metadata conflicts or corruption, where the table’s record of files no longer matches the actual data files present in storage.
Identifying the Conflict
The first step in troubleshooting is pinpointing the discrepancy. If your table is failing to return records or throwing "File Not Found" errors, the metadata likely points to a snapshot that references a file that was deleted or never successfully written.
You can inspect the state of your table by reviewing the transaction log history. In Delta Lake, you look at the _delta_log directory. If you suspect corruption, examine the latest JSON log entry:
{"add": {"path": "part-001.parquet", "size": 1024, ...}}
Compare the paths listed in these logs against your actual object storage (e.g., S3 or ADLS). If a manifest file lists a path that doesn’t exist in your storage layer, that is your corruption point.
Resolving the Issue
To resolve these conflicts, you must bring the metadata back into alignment with the physical reality of your files.
- Rollback via Time Travel: If the latest snapshot is corrupted, use your knowledge of Time Travel to restore the table to the last known "good" state. By pointing your table to a previous, valid manifest version, you effectively discard the corrupted metadata updates.
- Re-synchronization: If you are using external query engines that rely on manual manifest files, re-run the manifest generation process. This forces the system to perform a fresh scan of the data files and rebuild the manifest list from scratch, purging references to phantom files.
- Vacuuming: If the metadata is bloated with "hanging" references, running a
VACUUMoperation—provided you are outside the retention window—can clean up orphaned files that no longer exist in your current, healthy snapshots.
Key Takeaway: Metadata corruption occurs when the logical index deviates from physical storage; you can resolve this by reverting to a valid historical snapshot or force-refreshing manifest files to bridge the gap between the log and the data.