From e9048256adca48b29f5d188e35ff209592420749 Mon Sep 17 00:00:00 2001 From: Santiago Carmuega Date: Mon, 9 Jan 2023 17:15:42 -0300 Subject: [PATCH] chore: Trace errors instead of dropping them --- src/rolldb/mod.rs | 2 +- src/rolldb/wal.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/rolldb/mod.rs b/src/rolldb/mod.rs index 903f519f..5973d3f7 100644 --- a/src/rolldb/mod.rs +++ b/src/rolldb/mod.rs @@ -37,7 +37,7 @@ impl RollDB { let db = DB::open_cf(&opts, path, [blocks::CF_NAME, CHAIN_CF, wal::CF_NAME]) .map_err(|_| Error::IO)?; - let wal_seq = wal::find_lastest_seq(&db)?.into(); + let wal_seq = wal::find_latest_seq(&db)?.into(); Ok(Self { db, wal_seq }) } diff --git a/src/rolldb/wal.rs b/src/rolldb/wal.rs index 5d7f39cd..20fe2895 100644 --- a/src/rolldb/wal.rs +++ b/src/rolldb/wal.rs @@ -107,8 +107,11 @@ impl<'a> Iterator for CrawlIterator<'a> { fn next(&mut self) -> Option> { match self.0.next() { - Some(Ok((key, value))) => Some(Value::try_from(value)), - Some(Err(err)) => Some(Err(super::Error::IO)), + Some(Ok((_, value))) => Some(Value::try_from(value)), + Some(Err(err)) => { + tracing::error!(?err); + Some(Err(super::Error::IO)) + } None => None, } } @@ -126,13 +129,16 @@ pub fn crawl_backwards(db: &DB) -> CrawlIterator { CrawlIterator(inner) } -pub fn find_lastest_seq(db: &DB) -> Result { +pub fn find_latest_seq(db: &DB) -> Result { let cf = wal_cf(db); let mut iter = db.iterator_cf(cf, IteratorMode::End); match iter.next() { Some(Ok((key, _))) => Ok(Key::try_from(key)?), - Some(Err(err)) => Err(super::Error::IO), + Some(Err(err)) => { + tracing::error!(?err); + Err(super::Error::IO) + } None => Ok(Key(0)), } }