From d7d4cc8c772e689d7288830b3c8ec3050d22be90 Mon Sep 17 00:00:00 2001 From: Bojan Serafimov Date: Thu, 23 Jun 2022 12:56:21 -0400 Subject: [PATCH] Error instead of panic --- pageserver/src/tenant_threads.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pageserver/src/tenant_threads.rs b/pageserver/src/tenant_threads.rs index 67121d4cea..50d321dc75 100644 --- a/pageserver/src/tenant_threads.rs +++ b/pageserver/src/tenant_threads.rs @@ -7,7 +7,7 @@ use crate::repository::Repository; use crate::tenant_mgr::TenantState; use crate::thread_mgr::ThreadKind; use crate::{tenant_mgr, thread_mgr}; -use anyhow; +use anyhow::{self, Context}; use once_cell::sync::OnceCell; use tokio::sync::mpsc::{self, Sender}; use tracing::*; @@ -75,9 +75,10 @@ static START_COMPACTION_LOOP: OnceCell> = OnceCell::new(); pub fn start_gc_loop(tenantid: ZTenantId) -> anyhow::Result<()> { START_GC_LOOP .get() - .expect("failed to get START_GC_LOOP") + .context("Failed to get START_GC_LOOP")? .blocking_send(tenantid) - .expect("Failed to send to START_GC_LOOP channel"); + .map_err(|e| anyhow::anyhow!(e)) + .context("Failed to send to START_GC_LOOP channel")?; Ok(()) } @@ -87,9 +88,10 @@ pub fn start_gc_loop(tenantid: ZTenantId) -> anyhow::Result<()> { pub fn start_compaction_loop(tenantid: ZTenantId) -> anyhow::Result<()> { START_COMPACTION_LOOP .get() - .expect("failed to get START_COMPACTION_LOOP") + .context("failed to get START_COMPACTION_LOOP")? .blocking_send(tenantid) - .expect("failed to send to START_COMPACTION_LOOP"); + .map_err(|e| anyhow::anyhow!(e)) + .context("failed to send to START_COMPACTION_LOOP")?; Ok(()) }