Error

Enum Error 

Source
pub enum Error {
    Io(Error),
    Arrow(ArrowError),
    InvalidArgumentError(String),
    NotFound,
    CatalogError(String),
    ConstraintError(String),
    TransactionContextError(String),
    Internal(String),
    ExprCast(String),
    PredicateBuild(String),
    ReservedTableId(u16),
}
Expand description

Unified error type for all LLKV operations.

This enum encompasses all failure modes across the LLKV stack, from low-level storage errors to high-level transaction conflicts. Each variant includes context-specific information to help diagnose and handle the error appropriately.

§Error Handling Strategy

Errors propagate upward through the call stack using Rust’s ? operator. At API boundaries (e.g., SQL interface), errors are typically converted to user-friendly messages. Internal code can match on specific variants for fine-grained error handling.

§Thread Safety

Error implements Send and Sync, allowing errors to be safely passed between threads. This is important for concurrent query execution and transaction processing.

Variants§

§

Io(Error)

I/O error during file or disk operations.

This error wraps standard library I/O errors and typically occurs during:

  • Opening or creating database files
  • Reading or writing pages to disk
  • Flushing data to persistent storage

The underlying io::Error provides detailed information about the failure (e.g., permission denied, disk full, file not found).

§

Arrow(ArrowError)

Arrow library error during columnar data operations.

This error occurs when:

  • Serializing or deserializing Arrow RecordBatches
  • Converting between Arrow data types
  • Building Arrow arrays with invalid data
  • Schema mismatches during batch operations

Arrow is the underlying columnar memory format used by LLKV, so these errors typically indicate data format incompatibilities or memory allocation failures.

§

InvalidArgumentError(String)

Invalid user input or API parameter.

This error indicates a problem with arguments passed to LLKV APIs:

  • Invalid SQL syntax (e.g., malformed queries)
  • Type mismatches (e.g., comparing incompatible column types)
  • Out-of-range values (e.g., negative row counts)
  • Malformed identifiers (e.g., invalid table names)
  • Schema violations (e.g., missing required columns)

The message string provides specific details about what was invalid and why.

§Recovery

These errors are typically recoverable—fix the input and retry the operation.

§

NotFound

Storage key or entity not found.

This error occurs when attempting to access a non-existent:

  • Table (by name or ID)
  • Column (by name or field ID)
  • Row (by row_id)
  • Chunk or page (by physical key)
  • Descriptor or metadata entry

This is a common error when queries reference dropped tables or columns, or when low-level storage operations fail to locate expected data.

§Recovery

For user-facing errors, present a “table/column not found” message. For internal errors, this may indicate data corruption or a bug.

§

CatalogError(String)

Catalog metadata error.

This error indicates a problem with system catalog operations:

  • Corruption in catalog tables (__llkv_catalog_*)
  • Inconsistency between catalog and actual stored data
  • Failure to read or update table/column metadata
  • Schema evolution issues

Catalog errors are serious as they affect the database’s understanding of its own structure. They may require manual inspection or repair.

§

ConstraintError(String)

Data constraint violation.

This error occurs when an operation would violate data integrity rules:

  • Primary key conflicts (duplicate key on insert)
  • Type constraints (inserting wrong type into column)
  • NOT NULL constraint violations
  • Foreign key violations (if implemented)
  • Check constraint failures (if implemented)

The message describes which constraint was violated and what data caused the issue.

§Recovery

These errors are expected during normal operation (e.g., duplicate key inserts). The application should handle them gracefully and inform the user.

§

TransactionContextError(String)

Transaction execution or isolation error.

This error occurs during MVCC transaction processing:

  • Transaction conflicts during commit (write-write conflicts)
  • Isolation violations (attempting to see uncommitted data)
  • Transaction abort requests
  • Invalid transaction state transitions
  • Exceeding transaction limits

These errors are part of normal transaction processing and indicate that a transaction must be retried or aborted.

§

Internal(String)

Internal error indicating a bug or unexpected state.

This error should never occur during normal operation. It indicates:

  • Violated internal invariants
  • Unexpected state transitions
  • Logic errors in LLKV code
  • Data structure corruption

If you encounter this error, it likely indicates a bug in LLKV that should be reported with reproduction steps.

§Debugging

The message includes details about what assertion failed or what unexpected state was encountered. Enable debug logging for more context.

§

ExprCast(String)

Expression type casting error.

This error occurs when evaluating SQL expressions that require type conversions:

  • Invalid casts (e.g., string to integer when string isn’t numeric)
  • Unsupported type conversions
  • Overflow during numeric conversions

This is typically a user error (invalid SQL expression) rather than a bug.

§

PredicateBuild(String)

Predicate or filter construction error.

This error occurs when building scan predicates or filter expressions:

  • Type mismatches in comparison operations
  • Unsupported predicate types for columnar scans
  • Invalid filter push-down operations

These errors typically occur during query planning when attempting to optimize filters into storage-layer scans.

§

ReservedTableId(u16)

Attempted to use a reserved table ID for a user table.

Currently, only table ID 0 is reserved for the system catalog. This error prevents accidental corruption of system metadata.

User tables receive IDs starting from 1 and incrementing.

Implementations§

Source§

impl Error

Source

pub fn expr_cast<E>(err: E) -> Error
where E: Display,

Create an expression cast error from any displayable error.

This is a convenience method for converting other error types into Error::ExprCast while preserving the original error message.

Source

pub fn predicate_build<E>(err: E) -> Error
where E: Display,

Create a predicate build error from any displayable error.

This is a convenience method for converting other error types into Error::PredicateBuild while preserving the original error message.

Source

pub fn reserved_table_id(table_id: impl Into<u16>) -> Error

Create a reserved table ID error.

Currently only table ID 0 is reserved. This method creates an error when user code attempts to use a reserved ID.

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ArrowError> for Error

Source§

fn from(source: ArrowError) -> Error

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Error

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more