mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 16:48:58 +00:00
fix:reduce_write_quorum_errs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use crate::error::{Error, Result, StdError};
|
||||
use crate::quorum::{object_ignored_errs, reduce_write_quorum_errs};
|
||||
use bytes::Bytes;
|
||||
use futures::future::join_all;
|
||||
use futures::{Stream, StreamExt};
|
||||
@@ -49,7 +50,7 @@ impl Erasure {
|
||||
writers: &mut [W],
|
||||
// block_size: usize,
|
||||
total_size: usize,
|
||||
_write_quorum: usize,
|
||||
write_quorum: usize,
|
||||
) -> Result<usize>
|
||||
where
|
||||
S: Stream<Item = Result<Bytes, StdError>> + Send + Sync + 'static,
|
||||
@@ -87,17 +88,15 @@ impl Erasure {
|
||||
for (i, w) in writers.iter_mut().enumerate() {
|
||||
match w.write_all(blocks[i].as_ref()).await {
|
||||
Ok(_) => errs.push(None),
|
||||
Err(e) => errs.push(Some(e)),
|
||||
Err(e) => errs.push(Some(Error::new(e))),
|
||||
}
|
||||
}
|
||||
|
||||
// debug!("{} encode_data write errs:{:?}", self.id, errs);
|
||||
// // TODO: reduceWriteQuorumErrs
|
||||
// for err in errs.iter() {
|
||||
// if err.is_some() {
|
||||
// return Err(Error::msg("message"));
|
||||
// }
|
||||
// }
|
||||
let err_idx = reduce_write_quorum_errs(&errs, object_ignored_errs().as_slice(), write_quorum)?;
|
||||
if errs[err_idx].is_some() {
|
||||
let err = errs[err_idx].take().unwrap();
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
Err(e) => return Err(Error::from_std_error(e)),
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ pub fn is_file_not_found(e: &Error) -> bool {
|
||||
DiskError::FileNotFound.is(e)
|
||||
}
|
||||
|
||||
pub fn object_ignored_errs() -> Vec<CheckErrorFn> {
|
||||
vec![is_file_not_found]
|
||||
}
|
||||
|
||||
// 用于检查错误是否被忽略的函数
|
||||
fn is_err_ignored(err: &Error, ignored_errs: &[CheckErrorFn]) -> bool {
|
||||
ignored_errs.iter().any(|&ignored_err| ignored_err(err))
|
||||
@@ -76,7 +80,7 @@ fn reduce_quorum_errs(errs: &Vec<Option<Error>>, ignored_errs: &[CheckErrorFn],
|
||||
|
||||
// 根据读quorum验证错误数量
|
||||
pub fn reduce_read_quorum_errs(
|
||||
errs: &Vec<Option<Error>>,
|
||||
errs: &mut Vec<Option<Error>>,
|
||||
ignored_errs: &[CheckErrorFn],
|
||||
read_quorum: usize,
|
||||
) -> Result<usize, Error> {
|
||||
|
||||
Reference in New Issue
Block a user