Mercurial > lbo > hg > leveldb-rs
changeset 599:19532b6d8f8a
Merge pull request #27 from EmoFuncs/fix_bug_recover_db
fix the panic-when-recovering problem
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Thu, 08 Jun 2023 19:42:32 +0200 |
parents | 7f086f39fb22 (current diff) 46620faa748d (diff) |
children | 3593ae567020 |
files | |
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 19:42:32 2023 +0200 @@ -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 19:42:32 2023 +0200 @@ -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