-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy patherror.rs
More file actions
114 lines (104 loc) · 3.8 KB
/
error.rs
File metadata and controls
114 lines (104 loc) · 3.8 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH.
// All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.
use std::num::NonZeroUsize;
use std::sync::Arc;
use restate_core::{ShutdownError, SyncError};
use restate_metadata_store::ReadWriteError;
use restate_types::errors::MaybeRetryableError;
use restate_types::logs::builder::BuilderError;
use restate_types::logs::metadata::SegmentIndex;
use restate_types::logs::{LogId, Lsn};
use crate::loglet::OperationError;
/// Result type for bifrost operations.
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Clone, thiserror::Error, Debug)]
pub enum Error {
#[error("metadata store doesn't have an entry for log metadata")]
LogsMetadataNotProvisioned,
#[error("unknown log '{0}'")]
UnknownLogId(LogId),
#[error("invalid log sequence number '{0}'")]
InvalidLsn(Lsn),
#[error("operation failed due to an ongoing shutdown")]
Shutdown(#[from] ShutdownError),
#[error(transparent)]
LogletError(#[from] Arc<dyn MaybeRetryableError + Send + Sync>),
#[error("failed syncing logs metadata: {0}")]
MetadataSync(#[from] SyncError),
/// Provider is unknown or disabled
#[error("bifrost provider '{0}' is disabled or unrecognized")]
Disabled(String),
#[error(transparent)]
AdminError(#[from] AdminError),
#[error(transparent)]
MetadataStoreError(#[from] Arc<ReadWriteError>),
#[error("record batch too large: {batch_size_bytes} bytes exceeds limit of {limit} bytes")]
BatchTooLarge {
batch_size_bytes: usize,
limit: NonZeroUsize,
},
#[error("{0}")]
Other(String),
}
#[derive(thiserror::Error, Debug)]
pub enum EnqueueError<T> {
#[error("the operation rejected due to backpressure")]
Full(T),
#[error("appender is draining, closed, or crashed")]
Closed(T),
#[error("record too large: {record_size} bytes exceeds limit of {limit} bytes")]
RecordTooLarge {
record_size: usize,
limit: NonZeroUsize,
},
}
#[derive(Clone, Debug, thiserror::Error)]
pub enum AdminError {
#[error("log {0} is permanently sealed")]
ChainPermanentlySealed(LogId),
#[error("could not seal the loglet or the chain")]
ChainSealIncomplete,
#[error("log {0} already exists")]
LogAlreadyExists(LogId),
#[error("segment conflicts with existing segment with base_lsn={0}")]
SegmentConflict(Lsn),
#[error("segment index found in metadata does not match expected {expected}!={found}")]
SegmentMismatch {
expected: SegmentIndex,
found: SegmentIndex,
},
#[error("loglet params could not be deserialized: {0}")]
ParamsSerde(#[from] Arc<serde_json::Error>),
}
impl From<OperationError> for Error {
fn from(value: OperationError) -> Self {
match value {
OperationError::Shutdown(e) => Error::Shutdown(e),
OperationError::Other(e) => Error::LogletError(e),
}
}
}
impl From<BuilderError> for AdminError {
fn from(value: BuilderError) -> Self {
match value {
BuilderError::LogAlreadyExists(log_id) => AdminError::LogAlreadyExists(log_id),
BuilderError::ChainPermanentlySealed(log_id) => {
AdminError::ChainPermanentlySealed(log_id)
}
BuilderError::ParamsSerde(error) => AdminError::ParamsSerde(Arc::new(error)),
BuilderError::SegmentConflict(lsn) => AdminError::SegmentConflict(lsn),
}
}
}
impl From<ReadWriteError> for Error {
fn from(value: ReadWriteError) -> Self {
Error::MetadataStoreError(Arc::new(value))
}
}