Error 107: FILE_DOESNT_EXIST
This error occurs when ClickHouse attempts to access a file that does not exist in the filesystem or object storage. It typically indicates missing data part files, corrupted table parts, or issues with remote storage access.
Most common causes
-
Missing data part files
- Data part file deleted or moved during query execution
- Part files missing:
data.bin,columns.txt,checksums.txt,.mrk2files - Part removal race condition (file deleted after being listed but before being read)
-
Corrupted or incomplete table parts
- Broken data parts missing essential files
- Incomplete part downloads in replicated setups
- Checksums file referencing non-existent files
-
Merge or mutation issues
- Parts removed during ongoing merges while queries are reading them
- Mutations creating parts with missing files
- Column alterations leaving excess file references in checksums
-
Object storage (S3/Azure) issues
- S3 key not found errors
- Azure blob does not exist
- Network issues preventing file access
- Object storage eventual consistency problems
-
Filesystem cache problems
- Cached metadata pointing to deleted files
- Cache invalidation race conditions
- Temporary files cleaned up prematurely
-
Replication synchronization issues
- Part not yet downloaded to replica
- Part removed on one replica while being fetched on another
- Metadata inconsistency between replicas
Common solutions
1. Check table integrity
2. Look for stuck merges or mutations
3. Optimize or rebuild the affected table
4. Check replication queue (for replicated tables)
5. Detach and reattach broken parts
6. For S3/object storage issues
- Check S3 bucket permissions and access
- Verify network connectivity
- Check for S3 lifecycle policies deleting objects
- Review object storage logs
Common scenarios
Scenario 1: File missing during query
Cause: Part was removed (merged or deleted) while the query was accessing it.
Solution:
- Retry the query (part removal race condition)
- Check if excessive merges are happening
- Verify table isn't being dropped/recreated
Scenario 2: Missing marks file
Cause: Part is broken or incompletely downloaded.
Solution:
Scenario 3: S3 object not found
Cause: S3 object deleted, never uploaded, or access denied.
Solution:
- Check S3 bucket for the object
- Verify S3 credentials and permissions
- Check S3 lifecycle policies
- For replicated tables, fetch from another replica
Scenario 4: Checksums.txt references excess files
Cause: Column alteration left stale file references in checksums.txt.
Solution:
- This is often a bug in ClickHouse during mutations
- Detach and reattach the part
- Or manually remove problematic parts
Scenario 5: Azure blob missing
Cause: Azure storage object missing or access issues.
Solution:
- Verify Azure storage account access
- Check blob exists in container
- Review Azure storage logs
Prevention tips
- Use replicated tables: Provides redundancy when parts go missing
- Monitor merges: Watch for excessive or slow merge operations
- Regular integrity checks: Run
CHECK TABLEperiodically - Stable object storage: Ensure S3/Azure configurations are stable
- Avoid manual file deletions: Never manually delete part files
- Monitor disk space: Full disks can cause incomplete writes
- Keep ClickHouse updated: Bugs causing missing files are often fixed in newer versions
Debugging steps
-
Identify the missing file:
-
Check if part exists:
-
Check part log for part history:
-
For replicated tables, check all replicas:
-
Check for recent merges:
-
For object storage, check logs:
- S3: Check CloudTrail logs
- Azure: Check Storage Analytics logs
- Look for DELETE operations on the missing object
Special considerations
For SharedMergeTree / ClickHouse Cloud:
- Parts are stored in shared object storage
- Missing files often indicate object storage issues
- Check both local cache and remote storage
For replicated tables:
- One replica's missing part can be fetched from others
- Detaching broken parts often triggers automatic recovery
- Check replication lag before detaching parts
For mutations:
- Mutations create new parts; missing files may indicate mutation failure
- Check
system.mutationsfor failed mutations - Old parts are kept until mutation completes
During part removal:
- Parts are removed after being merged into larger parts
- Race condition can occur if query starts before merge but reads after
- Usually resolved by query retry
If you're experiencing this error:
- Retry the query (it could be a transient race condition)
- Run
CHECK TABLEto identify broken parts - Check
system.part_logfor recent part operations - For replicated tables, detach broken parts to trigger refetch
- For object storage errors, verify storage access and permissions
- If persistent, may indicate data corruption requiring restore from backup