Skip to main content

chronix_engine/compaction/
error.rs

1//! Compaction error types.
2
3use thiserror::Error;
4
5/// Errors that can occur during compaction.
6#[derive(Debug, Error)]
7pub enum CompactionError {
8    /// No segments to compact.
9    #[error("No segments eligible for compaction")]
10    NoEligibleSegments,
11
12    /// Segment I/O error.
13    #[error("Segment error: {0}")]
14    Segment(#[from] crate::segment::SegmentError),
15
16    /// Encoding error during re-encoding.
17    #[error("Encoding error: {0}")]
18    Encoding(#[from] chronix_encoding::EncodingError),
19
20    /// Index error.
21    #[error("Index error: {0}")]
22    Index(#[from] crate::index::IndexError),
23
24    /// I/O error.
25    #[error("I/O error: {0}")]
26    Io(#[from] std::io::Error),
27
28    /// Internal error.
29    #[error("Internal compaction error: {0}")]
30    Internal(String),
31
32    /// Compaction task exceeded the configured timeout.
33    #[error("Compaction timeout: task exceeded {0}ms limit")]
34    TaskTimeout(u64),
35
36    /// Input segments exceed the configured memory budget.
37    #[error("Compaction input too large: {loaded_bytes} bytes exceeds {limit_bytes} byte limit")]
38    InputTooLarge {
39        /// Bytes already loaded when the limit was hit.
40        loaded_bytes: u64,
41        /// Configured maximum.
42        limit_bytes: u64,
43    },
44}
45
46/// A specialized `Result` type for compaction operations.
47pub type Result<T> = std::result::Result<T, CompactionError>;