Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add retry mechanism in read blob metadata #1617

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions storage/src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,15 +753,35 @@ impl BlobCompressionContextInfo {
let expected_raw_size = (compressed_size + BLOB_CCT_HEADER_SIZE) as usize;
let mut raw_data = alloc_buf(expected_raw_size);

let read_size = reader
.read_all(&mut raw_data, blob_info.meta_ci_offset())
.map_err(|e| {
eio!(format!(
"failed to read metadata for blob {} from backend, {}",
blob_info.blob_id(),
e
))
})?;
let read_size = (|| {
// The maximum retry times
let mut retry_count = 3;

loop {
match reader.read_all(&mut raw_data, blob_info.meta_ci_offset()) {
Ok(size) => return Ok(size),
Err(e) => {
// Handle BackendError, retry a maximum of three times.
if retry_count > 0 {
warn!(
"failed to read metadata for blob {} from backend, {}, retry read metadata",
blob_info.blob_id(),
e
);
retry_count -= 1;
continue;
}

return Err(eio!(format!(
"failed to read metadata for blob {} from backend, {}",
blob_info.blob_id(),
e
)));
}
}
}
})()?;

if read_size != expected_raw_size {
return Err(eio!(format!(
"failed to read metadata for blob {} from backend, compressor {}, got {} bytes, expect {} bytes",
Expand Down
Loading