review feedbacks

This commit is contained in:
haoran 2022-11-29 17:42:18 +00:00 committed by HaoranYi
parent b090bb4f56
commit 75fc87f330
1 changed files with 26 additions and 34 deletions

View File

@ -290,25 +290,21 @@ impl BucketStorage {
.create(true) .create(true)
.open(file.clone()) .open(file.clone())
.map_err(|e| { .map_err(|e| {
if let Some((mmap_count, num_open_files, max_open_files_limit)) = Self::get_mmap_fd_stats() { let mmap_msg = Self::get_mmap_fd_stats()
panic!( .map(|(mmap_count, num_open_files, max_open_files_limit)| {
"Unable to create data file {} in current dir({:?}): {:?}, current mmap_count: {}, current number of open files: {}, max limit of open files: {:?}", format!("current mmap_count: {}, current number of open files: {}, max limit of open files: {:?}",
file.display(),
std::env::current_dir(),
e,
mmap_count, mmap_count,
num_open_files, num_open_files,
max_open_files_limit, max_open_files_limit,
); )
} }).unwrap_or_default();
else {
panic!( panic!(
"Unable to create data file {} in current dir({:?}): {:?}", "Unable to create data file {} in current dir({:?}): {:?}. {}",
file.display(), file.display(),
std::env::current_dir(), std::env::current_dir(),
e, e,
mmap_msg,
); );
}
}) })
.unwrap(); .unwrap();
@ -437,9 +433,9 @@ mod test {
assert_eq!(storage.uid(ix), None); assert_eq!(storage.uid(ix), None);
// test get_mmap_fd_stats // test get_mmap_fd_stats
if let Some((mmap_count, num_open_files, max_open_files_limit)) = let (mmap_count, num_open_files, max_open_files_limit) =
BucketStorage::get_mmap_fd_stats() BucketStorage::get_mmap_fd_stats().unwrap();
{
assert!(mmap_count > 0); assert!(mmap_count > 0);
assert!(num_open_files > 0); assert!(num_open_files > 0);
match max_open_files_limit.soft_limit { match max_open_files_limit.soft_limit {
@ -451,9 +447,5 @@ mod test {
LimitValue::Unlimited => {} LimitValue::Unlimited => {}
LimitValue::Value(x) => assert!(x > 0), LimitValue::Value(x) => assert!(x > 0),
} }
println!("{:?}", num_open_files);
println!("{:?}", max_open_files_limit);
}
} }
} }