From 15ddab99a9de0a03f61d646fd539cd296913ae63 Mon Sep 17 00:00:00 2001 From: MattHalpinParity Date: Mon, 29 Jul 2024 13:01:25 +0100 Subject: [PATCH 1/3] Fix warning --- admin/src/bench/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/admin/src/bench/mod.rs b/admin/src/bench/mod.rs index 8e91aaa2..e57ab805 100644 --- a/admin/src/bench/mod.rs +++ b/admin/src/bench/mod.rs @@ -106,7 +106,6 @@ pub struct Args { pub append: bool, pub no_check: bool, pub compress: bool, - pub ordered: bool, pub uniform: bool, pub writer_commits_per_sleep: u64, pub writer_sleep_time: u64, @@ -125,7 +124,6 @@ impl Stress { archive: self.archive, no_check: self.no_check, compress: self.compress, - ordered: self.ordered, uniform: self.uniform, writer_commits_per_sleep: self.writer_commits_per_sleep.unwrap_or(100), writer_sleep_time: self.writer_sleep_time.unwrap_or(0), From b4b73752750909451ee61757526c57ae1cb17c6e Mon Sep 17 00:00:00 2001 From: MattHalpinParity Date: Mon, 29 Jul 2024 13:19:34 +0100 Subject: [PATCH 2/3] TableFile::open propagates io errors other than NotFound. fmt. --- src/btree/mod.rs | 2 +- src/file.rs | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/btree/mod.rs b/src/btree/mod.rs index bb1177d2..8596e263 100644 --- a/src/btree/mod.rs +++ b/src/btree/mod.rs @@ -202,7 +202,7 @@ impl BTreeTable { return Ok(None) } let record_id = 0; // lifetime of Btree is the query, so no invalidate. - // keeping log locked when parsing tree. + // keeping log locked when parsing tree. let tree = BTree::new(Some(btree_header.root), btree_header.depth, record_id); tree.get(key, values, log) } diff --git a/src/file.rs b/src/file.rs index e07095cf..3dffb8ca 100644 --- a/src/file.rs +++ b/src/file.rs @@ -68,7 +68,7 @@ pub fn madvise_random(_map: &mut memmap2::MmapMut) {} fn mmap(file: &std::fs::File, len: usize) -> Result { #[cfg(not(test))] const RESERVE_ADDRESS_SPACE: usize = 1024 * 1024 * 1024; // 1 Gb - // Use a different value for tests to work around docker limits on the test machine. + // Use a different value for tests to work around docker limits on the test machine. #[cfg(test)] const RESERVE_ADDRESS_SPACE: usize = 64 * 1024 * 1024; // 64 Mb @@ -85,6 +85,12 @@ fn mmap(file: &std::fs::File, _len: usize) -> Result { const GROW_SIZE_BYTES: u64 = 256 * 1024; +fn test_metadata>(path: P) -> std::io::Result { + std::fs::metadata(path) + //Err(std::io::Error::new(ErrorKind::NotFound, "Test NotFound error")) + //Err(std::io::Error::new(ErrorKind::PermissionDenied, "Test other error")) +} + #[derive(Debug)] pub struct TableFile { pub map: RwLock>, @@ -96,7 +102,12 @@ pub struct TableFile { impl TableFile { pub fn open(filepath: std::path::PathBuf, entry_size: u16, id: TableId) -> Result { let mut capacity = 0u64; - let map = if std::fs::metadata(&filepath).is_ok() { + let map = if let Err(error) = test_metadata(&filepath) { + match error.kind() { + std::io::ErrorKind::NotFound => None, + _ => return try_io!(Err(error)), + } + } else { let file = try_io!(std::fs::OpenOptions::new() .read(true) .write(true) @@ -113,8 +124,6 @@ impl TableFile { } let map = mmap(&file, len as usize)?; Some((map, file)) - } else { - None }; Ok(TableFile { path: filepath, From cd3b0ff93a80affef10db505db98ac601dcd0032 Mon Sep 17 00:00:00 2001 From: MattHalpinParity Date: Mon, 29 Jul 2024 15:01:51 +0100 Subject: [PATCH 3/3] Remove test function --- src/file.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/file.rs b/src/file.rs index 3dffb8ca..116f56f0 100644 --- a/src/file.rs +++ b/src/file.rs @@ -85,12 +85,6 @@ fn mmap(file: &std::fs::File, _len: usize) -> Result { const GROW_SIZE_BYTES: u64 = 256 * 1024; -fn test_metadata>(path: P) -> std::io::Result { - std::fs::metadata(path) - //Err(std::io::Error::new(ErrorKind::NotFound, "Test NotFound error")) - //Err(std::io::Error::new(ErrorKind::PermissionDenied, "Test other error")) -} - #[derive(Debug)] pub struct TableFile { pub map: RwLock>, @@ -102,7 +96,7 @@ pub struct TableFile { impl TableFile { pub fn open(filepath: std::path::PathBuf, entry_size: u16, id: TableId) -> Result { let mut capacity = 0u64; - let map = if let Err(error) = test_metadata(&filepath) { + let map = if let Err(error) = std::fs::metadata(&filepath) { match error.kind() { std::io::ErrorKind::NotFound => None, _ => return try_io!(Err(error)),