mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-30 20:00:36 +00:00
chore(index): add BiError to fulfil the requirement of returning two errors (#3291)
Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
This commit is contained in:
@@ -549,6 +549,13 @@ pub enum Error {
|
||||
source: common_recordbatch::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("BiError, first: {first}, second: {second}"))]
|
||||
BiError {
|
||||
first: Box<Error>,
|
||||
second: Box<Error>,
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||
@@ -650,6 +657,7 @@ impl ErrorExt for Error {
|
||||
StaleLogEntry { .. } => StatusCode::Unexpected,
|
||||
FilterRecordBatch { source, .. } => source.status_code(),
|
||||
Upload { .. } => StatusCode::StorageUnavailable,
|
||||
BiError { .. } => StatusCode::Internal,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ use tokio::io::duplex;
|
||||
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};
|
||||
|
||||
use crate::error::{
|
||||
IndexFinishSnafu, OperateAbortedIndexSnafu, PuffinAddBlobSnafu, PuffinFinishSnafu,
|
||||
BiSnafu, IndexFinishSnafu, OperateAbortedIndexSnafu, PuffinAddBlobSnafu, PuffinFinishSnafu,
|
||||
PushIndexValueSnafu, Result,
|
||||
};
|
||||
use crate::metrics::{
|
||||
@@ -249,8 +249,21 @@ impl SstIndexCreator {
|
||||
self.index_creator.finish(&mut index_writer),
|
||||
puffin_writer.add_blob(blob)
|
||||
);
|
||||
index_finish.context(IndexFinishSnafu)?;
|
||||
puffin_add_blob.context(PuffinAddBlobSnafu)?;
|
||||
|
||||
match (
|
||||
puffin_add_blob.context(PuffinAddBlobSnafu),
|
||||
index_finish.context(IndexFinishSnafu),
|
||||
) {
|
||||
(Err(e1), Err(e2)) => BiSnafu {
|
||||
first: Box::new(e1),
|
||||
second: Box::new(e2),
|
||||
}
|
||||
.fail()?,
|
||||
|
||||
(Ok(_), e @ Err(_)) => e?,
|
||||
(e @ Err(_), Ok(_)) => e?,
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let byte_count = puffin_writer.finish().await.context(PuffinFinishSnafu)?;
|
||||
guard.inc_byte_count(byte_count);
|
||||
|
||||
Reference in New Issue
Block a user