1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use thiserror::Error;
/// Errors returned by the object-log engine, storage adapters, and sequencer.
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ObjectLogError {
/// An object key was empty or contained a `..` path component or `\0`.
#[error("invalid object key: {0}")]
InvalidObjectKey(String),
/// The storage layer was unreachable or returned an I/O error.
#[error("storage unavailable: {0}")]
StorageUnavailable(String),
/// A `get_range` request named a byte range outside the object, or inverted.
#[error("byte range out of bounds: {0}")]
RangeOutOfBounds(String),
/// The index referenced an object that is no longer present in storage.
#[error("missing object: {0}")]
MissingObject(String),
/// A produce batch was malformed (e.g. empty, or below the configured floor).
#[error("invalid produce batch: {0}")]
InvalidBatch(String),
/// The sequencer rejected or failed to process a commit/lookup.
#[error("sequencer error: {0}")]
Sequencer(String),
/// The partition's fence epoch moved past the write's epoch, so the write was
/// not committed. Retrying at the same epoch cannot succeed.
///
/// Produced by a sequencer's [`rejection_error`](crate::Sequencer::rejection_error)
/// (for example [`ManifestSequencer`](crate::ManifestSequencer)); the engine
/// never constructs it.
#[error(
"partition {partition} is fenced at epoch {current}; the write at epoch {epoch} was not committed"
)]
Fenced {
/// Partition whose fence rejected the write.
partition: String,
/// Epoch the write was produced at.
epoch: u64,
/// Fence epoch the partition's index holds.
current: u64,
},
/// A conditional batch was definitely not indexed at its expected log head.
#[error("conditional log head moved from {expected} to {current}")]
HeadRejected {
/// Original required next offset.
expected: i64,
/// Authoritative next offset that did not match.
current: i64,
},
/// Durable-ops budget admission failed (`BudgetMode::FailClosed` or timed out).
#[error("durable-ops budget exceeded: {0}")]
BudgetExceeded(String),
/// An authenticated native payload exceeds the caller's read limit.
#[error("native payload length {actual} exceeds read limit {limit}")]
ReadLimitExceeded {
/// Authenticated payload length, before data hydration.
actual: usize,
/// Caller-supplied maximum payload length.
limit: usize,
},
/// Invalid engine or budget configuration.
#[error("invalid configuration: {0}")]
InvalidConfig(String),
}
impl From<std::io::Error> for ObjectLogError {
fn from(value: std::io::Error) -> Self {
Self::StorageUnavailable(value.to_string())
}
}