Skip to main content

Module error

Module error 

Source
Expand description

§Error Types for the Concurrent B+ Tree

This module defines error types used internally by the B+ tree for handling optimistic concurrency failures.

§Error Handling Strategy

The B+ tree uses optimistic concurrency control, where most operations proceed without blocking and validate their reads at the end. When validation fails, operations don’t panic - they return errors that signal the caller to retry.

§Error Flow

Operation starts
     │
     ▼
Acquire optimistic access
     │
     ▼
Read data (may be inconsistent)
     │
     ▼
Validate reads ──────────► Err(Unwind) ───► Retry operation
     │
     ▼ (Ok)
Perform side effects
     │
     ▼
Return success

§Common Patterns

Most tree operations follow this pattern:

loop {
    let perform = || {
        let guard = self.find_leaf(key, eg)?;  // May return Unwind
        let result = guard.some_operation()?;   // May return Unwind
        guard.recheck()?;                       // May return Unwind
        Ok(result)
    };

    match perform() {
        Ok(result) => return result,
        Err(Error::Unwind) => continue,        // Retry
        Err(Error::Reclaimed) => continue,     // Retry
    }
}

Enums§

Error
Errors that can occur during B+ tree operations.

Type Aliases§

Result
A Result type alias using our custom Error type.