Mercurial > lbo > hg > leveldb-rs
changeset 598:46620faa748d
fix panic when recovering problem
author | EmoFuncs <448947198@qq.com> |
---|---|
date | Thu, 08 Jun 2023 14:38:32 +0800 |
parents | 7f086f39fb22 |
children | 19532b6d8f8a 45b51fa84885 |
files | src/db_impl.rs src/version_set.rs |
diffstat | 2 files changed, 15 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/db_impl.rs Sat May 13 14:55:27 2023 +0200 +++ b/src/db_impl.rs Thu Jun 08 14:38:32 2023 +0800 @@ -806,7 +806,7 @@ // TODO: Do we need to do a memtable compaction here? Probably not, in the sequential // case. assert!(input.current(&mut key, &mut val)); - if cs.compaction.should_stop_before(&key) && cs.builder.is_none() { + if cs.compaction.should_stop_before(&key) && cs.builder.is_some() { self.finish_compaction_output(cs, key.clone())?; } let (ktyp, seq, ukey) = parse_internal_key(&key);
--- a/src/version_set.rs Sat May 13 14:55:27 2023 +0200 +++ b/src/version_set.rs Thu Jun 08 14:38:32 2023 +0800 @@ -676,25 +676,23 @@ return false; } if let Ok(size) = self.opt.env.size_of(Path::new(current_manifest_path)) { - if size > self.opt.max_file_size { + if size >= self.opt.max_file_size { return false; } - } else { - return false; - } - assert!(self.descriptor_log.is_none()); - let s = self - .opt - .env - .open_appendable_file(Path::new(current_manifest_path)); - if let Ok(f) = s { - log!(self.opt.log, "reusing manifest {:?}", current_manifest_path); - self.descriptor_log = Some(LogWriter::new(f)); - self.manifest_num = num; - return true; - } else { - log!(self.opt.log, "reuse_manifest: {}", s.err().unwrap()); + assert!(self.descriptor_log.is_none()); + let s = self + .opt + .env + .open_appendable_file(Path::new(current_manifest_path)); + if let Ok(f) = s { + log!(self.opt.log, "reusing manifest {:?}", current_manifest_path); + self.descriptor_log = Some(LogWriter::new_with_off(f, size)); + self.manifest_num = num; + return true; + } else { + log!(self.opt.log, "reuse_manifest: {}", s.err().unwrap()); + } } } false