Overview
RotorTree defines two error types for persistent storage operations:StorageError- Errors from WAL and storage operationsRotorTreeError- Unified error type combining tree and storage errors
StorageError
StorageError represents errors that occur during persistence operations, including I/O failures, corruption detection, and concurrency issues.
Error Variants
Io
Io
Returned when: An I/O operation fails.Wraps standard library I/O errors from file operations.Common causes:
- Permission denied
- Disk full
- File not found
- Network filesystem issues
- Check filesystem permissions
- Verify available disk space
- Retry with exponential backoff for transient errors
CrcMismatch
CrcMismatch
Returned when: CRC32C checksum verification fails at a given offset.Indicates data corruption was detected during WAL recovery.Common causes:
- Disk corruption
- Partial write due to crash
- Hardware failure
- Bit rot
- Restore from backup
- WAL is automatically truncated to last valid frame
- Check hardware health
WalCorrupted
WalCorrupted
Returned when: WAL file is corrupted at the given offset (not a tail truncation).Indicates structural corruption beyond simple incomplete writes.Common causes:
- File tampering
- Severe disk corruption
- Bug in WAL writer
- Restore from backup
- Data after corruption point is lost
ConfigMismatch
ConfigMismatch
Returned when: WAL file header has different N or MAX_DEPTH than expected.The tree configuration doesn’t match the persisted data.Common causes:
- Changing tree parameters between runs
- Opening wrong WAL file
- Using incompatible tree types
- Use correct type parameters matching the WAL
- Migrate data to new configuration if needed
FileLocked
FileLocked
Returned when: Another process holds an exclusive lock on the WAL file.Only one process can open a WAL file at a time.Common causes:
- Another instance already running
- Previous process didn’t exit cleanly
- Stale lock file
- Ensure no other instances are running
- Wait for lock to be released
- Clean up stale processes
Closed
Closed
Returned when: Attempting operations on a closed tree.The tree has been explicitly closed and no further operations are allowed.Common causes:
- Using tree after
close()was called - Concurrent access during shutdown
- Don’t use tree after closing
- Reopen tree if needed
Tree
Tree
Returned when: A tree operation fails during WAL recovery.Wraps a
TreeError that occurred while replaying the WAL.Common causes:- Corrupted WAL entries
- Invalid operations recorded in WAL
- Replay logic bugs
- Check inner
TreeErrorfor specific issue - May indicate WAL corruption
FlushFailed
FlushFailed
Returned when: The background flush thread encountered an I/O error.Asynchronous flushes failed in background thread.Common causes:
- Disk full during async flush
- I/O errors in background
- Filesystem issues
- Check disk space
- Review system logs
- Restart with clean state
CheckpointFailed
CheckpointFailed
Returned when: The background checkpoint thread encountered an error.Checkpointing operation failed in background.Common causes:
- I/O errors during checkpoint
- Filesystem issues
- Insufficient permissions
- Check error detail string
- Review filesystem health
- Verify permissions
MathError
MathError
Returned when: An internal mathematical operation fails.Arithmetic error during storage operations.Recovery strategy:
- Report as a bug if encountered
DataCorruption
DataCorruption
Returned when: Data corruption is detected (e.g., root recomputation mismatch).Semantic corruption detected during verification.Common causes:
- Corruption not caught by CRC
- Logic bugs in storage layer
- Hardware issues
- Restore from backup
- Check hardware health
- Review error detail for diagnostics
SerdeFailed
SerdeFailed
Returned when: Frame deserialization failed despite valid CRC.Valid checksum but incompatible schema or version.Common causes:
- Version mismatch between writer and reader
- Schema evolution issues
- Incompatible serialization format
- Use matching versions
- Migrate data if format changed
RotorTreeError
RotorTreeError is the unified error type returned by high-level RotorTree operations. It combines both tree-level and storage-level errors.
Variants
Tree(TreeError)- A tree-level error (depth exceeded, capacity, etc.)Storage(StorageError)- A storage-level error (I/O, corruption, etc.)
Conversions
RotorTreeError automatically converts from:
Error Handling
Pattern Matching
Handling Corruption
Handling Concurrency
Graceful Degradation
Traits
Both error types implement:Debug- for debugging outputDisplay- for user-friendly error messagesstd::error::Error- for error trait compatibility withsource()support
StorageError implements:
From<std::io::Error>- automatic conversion from I/O errors
See Also
- TreeError - Core tree operation errors
- Persistent Storage - Persistence and WAL
- RotorTree API - Storage configuration
