Skip to main content

ItzmaError

Enum ItzmaError 

Source
#[non_exhaustive]
pub enum ItzmaError {
Show 35 variants Storage(Error), Serde { path: String, source: Error, }, InvalidNamespaceId(String), NamespaceExists(String), NamespaceNotFound(String), ManifestExists(String), Unrecoverable { reason: String, keys: Vec<String>, }, InvalidSchema(&'static str), DimensionMismatch { expected: usize, got: usize, }, InvalidVector(&'static str), UnknownAttr { field: String, }, AttrTypeMismatch { field: String, expected: &'static str, found: &'static str, }, InvalidAttrs(&'static str), InvalidColumns(&'static str), InvalidQuery(&'static str), InvalidConfig(&'static str), EmptyBatch, WriteContention { attempts: u32, }, ManifestContention { attempts: u32, }, WalGap { expected: u64, found: u64, }, UnsupportedFormat { version: u32, }, WalFormatTooNew { found: u32, supported: u32, }, SegmentFormatTooNew { found: u32, supported: u32, }, WalFormatTooOld { have: u32, need: u32, }, SegmentFormatTooOld { have: u32, need: u32, }, CorruptSegment { path: String, reason: String, }, CorruptIndex { path: String, reason: String, }, CorruptSparseIndex { path: String, reason: String, }, CorruptWal { path: String, reason: String, }, InvalidKey(&'static str), InvalidId(&'static str), KeyConflict { key: String, }, BatchTooLarge { bytes: u64, max: u64, }, ReadBudgetExceeded { path: String, needed: u64, max: u64, }, CorruptManifest(String),
}
Expand description

Everything that can go wrong in itzma-core.

The enum is #[non_exhaustive], so downstream match expressions need a wildcard arm. New variants can then be added without a breaking change.

Input is validated before any storage call, so the input-shaped variants (InvalidNamespaceId, InvalidSchema, DimensionMismatch, InvalidVector, InvalidId, InvalidQuery, EmptyBatch) never leave a partial write behind.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Storage(Error)

The object store failed. Passed through unchanged, and never retried except inside the two contention loops (WriteContention and ManifestContention).

§

Serde

An object was fetched but its JSON could not be decoded (or, on the write side, an entry could not be encoded).

Fields

§path: String

Object key of the offending object, or a short label such as "wal entry" when encoding something that has no key yet.

§source: Error

The underlying serde_json error.

§

InvalidNamespaceId(String)

The namespace id is empty, longer than 64 bytes, or contains anything outside [a-z0-9_-]. Keeping / out of ids keeps namespaces from nesting into each other’s prefixes.

§

NamespaceExists(String)

Namespace::create was called for an id whose manifest already exists.

§

NamespaceNotFound(String)

Namespace::open was called for an id with no manifest.

§

ManifestExists(String)

Namespace::recover was called for an id whose manifest exists, or that another recovery wrote first. Nothing was changed. The namespace is there to open.

§

Unrecoverable

Namespace::recover cannot rebuild the manifest from what the store holds. Nothing was written. reason says what is missing, and keys are the objects to put back from a replica, a versioned bucket or a backup. Once they are back, running recover again can succeed.

Fields

§reason: String

What has no readable copy.

§keys: Vec<String>

Object keys that would fill the gap, at most a handful.

§

InvalidSchema(&'static str)

The schema passed to Namespace::create cannot be used. Today that means dim == 0.

§

DimensionMismatch

A vector’s length differs from the namespace’s dim. Raised for documents on write and for the query vector on read.

Fields

§expected: usize

The namespace’s dim.

§got: usize

The length of the vector that was passed in.

§

InvalidVector(&'static str)

A vector has a NaN or infinite component, or is all zeros under the cosine metric (which has no direction to compare).

§

UnknownAttr

A document’s attributes, or a predicate, name a field the namespace’s attribute schema does not declare.

Fields

§field: String

The field name as given.

§

AttrTypeMismatch

A value or an operator does not fit the declared type of a field. expected is what the schema or the operator needs, found what was given.

Fields

§field: String

The field name.

§expected: &'static str

The type the schema or the operator needs.

§found: &'static str

The type that was found.

§

InvalidAttrs(&'static str)

A document’s attrs are not acceptable under the namespace’s attribute schema for a reason that is not one field’s type: not a JSON object, or a set with too many elements.

§

InvalidColumns(&'static str)

A DocColumns batch is malformed: offsets that do not start at zero, go down or overrun their buffer, a column that does not mark every row, text that is not UTF-8, a repeated or empty column name, or batches of one stream that do not share their columns.

§

InvalidQuery(&'static str)

QueryOptions that cannot be run: a shortlist factor or a probe count of zero.

§

InvalidConfig(&'static str)

A process-wide setting was refused: for instance sizing the compute pools with configure_cpu after they started, or with zero threads.

§

EmptyBatch

upsert or delete was called with nothing to write.

§

WriteContention

A WAL append lost the put-if-absent race 32 times in a row and gave up. Retrying the whole call is safe: nothing was written.

Fields

§attempts: u32

How many sequence numbers were tried.

§

ManifestContention

A manifest compare-and-swap lost the race 32 times in a row and gave up. Compaction’s publish step is bound by the same cap, and so is raising a segment’s generation mark before an index build writes its object; nothing was written then either.

Fields

§attempts: u32

How many read-modify-write rounds were tried.

§

WalGap

The WAL is not a contiguous run of sequence numbers. The write path never leaves a hole, so this means an object was deleted by hand or there is a bug.

Fields

§expected: u64

The sequence number that should have come next.

§found: u64

The sequence number that was there instead.

§

UnsupportedFormat

An object carries a format_version this build does not understand.

Fields

§version: u32

The version found in the object.

§

WalFormatTooNew

The namespace’s manifest says its WAL may hold objects in a format newer than this build reads. Nothing was read or written. Upgrade the build, then retry. Raised for every operation on the namespace, since each one loads the manifest first.

Fields

§found: u32

The wal_format in the manifest.

§supported: u32

The newest WAL format this build reads.

§

SegmentFormatTooNew

The namespace’s manifest says its segments may be in a format newer than this build reads. Nothing was read or written. Upgrade the build, then retry. Raised for every operation on the namespace, like ItzmaError::WalFormatTooNew.

Fields

§found: u32

The segment_format in the manifest.

§supported: u32

The newest segment format this build reads.

§

WalFormatTooOld

The namespace’s WAL format is lower than the operation needs. A keyed write needs level 3, fencing WAL objects in Namespace::gc needs level 4, and a namespace created by an older build is at 2. Nothing was written or changed. Once every build that touches the namespace reads the newer format, raise it with Namespace::upgrade_wal_format.

Fields

§have: u32

The wal_format in the manifest.

§need: u32

The level the operation needs.

§

SegmentFormatTooOld

The namespace’s segment format is lower than the operation needs. Namespace::index needs level 2, because an index is built for the block-addressable layout, and a namespace created by an older build is at level one. Nothing was written or changed. Once every build that touches the namespace reads version 2, raise it with Namespace::upgrade_segment_format.

Fields

§have: u32

The segment_format in the manifest.

§need: u32

The level the operation needs.

§

CorruptSegment

A segment object cannot be used: it is truncated, has the wrong magic, disagrees with its own counts, has ids out of order, or is missing although the manifest lists it. Also raised when a segment’s dimension differs from the namespace schema.

Fields

§path: String

Object key of the segment.

§reason: String

What is wrong with it.

§

CorruptIndex

An index object cannot be used: it is truncated, has the wrong magic, a kind this build does not know, counts, offsets or a head length that disagree with each other, values that are not finite, or a row count or data size that differs from the segment it was built for. A query never falls back to a flat scan over one (exact skips indexes altogether), and index with rebuild replaces it.

Fields

§path: String

Object key of the index, or "(encoding)" on the write side.

§reason: String

What is wrong with it.

§

CorruptSparseIndex

A sparse inverted-index object cannot be used: it is truncated, has the wrong magic, counts or offsets that disagree with each other, or a row count that differs from the segment it was built for. A query never falls back to a flat scan over one, and Namespace::index_sparse with rebuild replaces it.

Fields

§path: String

Object key of the index, or "(encoding)" on the write side.

§reason: String

What is wrong with it.

§

CorruptWal

A binary WAL object (format version 2) cannot be used: it is truncated, names an unknown codec, disagrees with its own lengths or counts, holds a ZSTD frame that does not match its header, has invalid UTF-8 or JSON inside, or has trailing bytes. Also raised on the write side when a length cannot be encoded. An object without the WAL magic is refused the same way.

Fields

§path: String

Object key of the WAL object, or "(encoding)" on the write side.

§reason: String

What is wrong with it.

§

InvalidKey(&'static str)

An idempotency key is empty or longer than 128 bytes. Raised before anything is written.

§

InvalidId(&'static str)

A document id (on upsert) or a delete id is empty or longer than document::MAX_ID_BYTES bytes. Raised before anything is written.

§

KeyConflict

A WAL object already carries this idempotency key but holds a batch of a different size, so the key is being reused for a different write. Nothing was written. A key names one batch.

Fields

§key: String

The key.

§

BatchTooLarge

A write batch is bigger than the writer limit, MAX_BODY_BYTES. Nothing was built or written. Split the load into several batches; each is atomic, the split as a whole is not.

Fields

§bytes: u64

The exact size the batch would have, before compression.

§max: u64

The writer limit.

§

ReadBudgetExceeded

A query or a compaction run would read more than the handle’s read budget. Nothing was written. needed is the total of the objects the read had asked for when it hit the limit, this one included. Compact to shorten the WAL tail, or raise the budget with Namespace::with_read_budget.

Fields

§path: String

Object key of the object that went over.

§needed: u64

The running total, including that object.

§max: u64

The read budget.

§

CorruptManifest(String)

The manifest’s segment list breaks the invariant: ids that do not parse, ranges that do not start at 1 or do not follow one another, or a last range that does not end at wal_folded_through. Also raised when schema.json holds a different schema from the manifest.

Trait Implementations§

Source§

impl Debug for ItzmaError

Source§

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

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

impl Display for ItzmaError

Source§

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

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

impl Error for ItzmaError

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<Error> for ItzmaError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.