diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-06 16:37:44 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-06 16:37:44 +0200 |
commit | c3c8d59c996061a2a4280820915a6dcd94cf496c (patch) | |
tree | 218100fda6320495466a150580ecaf6e469fbb8e /src/table | |
parent | bbf68aa039678d844e7d88db1a23a128f877ba43 (diff) | |
download | garage-c3c8d59c996061a2a4280820915a6dcd94cf496c.tar.gz garage-c3c8d59c996061a2a4280820915a6dcd94cf496c.zip |
Fix more .unwrap()'s
Diffstat (limited to 'src/table')
-rw-r--r-- | src/table/metrics.rs | 20 | ||||
-rw-r--r-- | src/table/sync.rs | 13 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/table/metrics.rs b/src/table/metrics.rs index 3318de88..13baf4c6 100644 --- a/src/table/metrics.rs +++ b/src/table/metrics.rs @@ -26,10 +26,12 @@ impl TableMetrics { .u64_value_observer( "table.merkle_updater_todo_queue_length", move |observer| { - observer.observe( - merkle_todo.len().unwrap() as u64, // TODO fix unwrap - &[KeyValue::new("table_name", table_name)], - ) + if let Ok(v) = merkle_todo.len() { + observer.observe( + v as u64, + &[KeyValue::new("table_name", table_name)], + ); + } }, ) .with_description("Merkle tree updater TODO queue length") @@ -38,10 +40,12 @@ impl TableMetrics { .u64_value_observer( "table.gc_todo_queue_length", move |observer| { - observer.observe( - gc_todo.len().unwrap() as u64, // TODO fix unwrap - &[KeyValue::new("table_name", table_name)], - ) + if let Ok(v) = gc_todo.len() { + observer.observe( + v as u64, + &[KeyValue::new("table_name", table_name)], + ); + } }, ) .with_description("Table garbage collector TODO queue length") diff --git a/src/table/sync.rs b/src/table/sync.rs index 20066d73..4c83e991 100644 --- a/src/table/sync.rs +++ b/src/table/sync.rs @@ -603,9 +603,16 @@ impl SyncTodo { let retain = nodes.contains(&my_id); if !retain { // Check if we have some data to send, otherwise skip - if data.store.range(begin..end).unwrap().next().is_none() { - // TODO fix unwrap - continue; + match data.store.range(begin..end) { + Ok(mut iter) => { + if iter.next().is_none() { + continue; + } + } + Err(e) => { + warn!("DB error in add_full_sync: {}", e); + continue; + } } } |