From e0ebdfc7ce82fce9f382031aab738c6d88d3fb23 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 26 Oct 2023 10:59:24 +0100 Subject: [PATCH] pageserver: suppress compaction/gc errors while stopping (#5670) ## Problem Tenant deletions would sometimes be accompanied by compaction stack traces, because `shutdown()` puts the tenant into stopping state before it joins background tasks. ## Summary of changes Treat GC+Compaction as no-ops on a Stopping tenant. --- pageserver/src/tenant.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index f177a17afc..919291a7e7 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -1822,6 +1822,11 @@ impl Tenant { pitr: Duration, ctx: &RequestContext, ) -> anyhow::Result { + // Don't start doing work during shutdown + if let TenantState::Stopping { .. } = self.current_state() { + return Ok(GcResult::default()); + } + // there is a global allowed_error for this anyhow::ensure!( self.is_active(), @@ -1850,6 +1855,12 @@ impl Tenant { cancel: &CancellationToken, ctx: &RequestContext, ) -> anyhow::Result<()> { + // Don't start doing work during shutdown + if let TenantState::Stopping { .. } = self.current_state() { + return Ok(()); + } + + // We should only be called once the tenant has activated. anyhow::ensure!( self.is_active(), "Cannot run compaction iteration on inactive tenant"