From 12763ca312eaf3389d7f4e34953aa77ba0b60064 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Mon, 21 Aug 2023 14:52:02 +0300 Subject: [PATCH] layere: reset wanted_evicted only if downloading --- pageserver/src/tenant/storage_layer.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pageserver/src/tenant/storage_layer.rs b/pageserver/src/tenant/storage_layer.rs index 45fa100c2d..c0d93ec462 100644 --- a/pageserver/src/tenant/storage_layer.rs +++ b/pageserver/src/tenant/storage_layer.rs @@ -672,10 +672,6 @@ impl LayerE { // disable any scheduled but not yet running eviction deletions for this self.version.fetch_add(1, Ordering::Relaxed); - // what to do if we have a concurrent eviction request when we are downloading? eviction - // api's use ResidentLayer, so evict could be moved there, or we just reset the state here. - self.wanted_evicted.store(false, Ordering::Release); - // no need to make the evict_and_wait wait for the actual download to complete drop(self.status.send(Status::Downloaded)); @@ -695,6 +691,14 @@ impl LayerE { .context("check if layer file is present")?; if let Some(reason) = needs_download { + // what to do if we have a concurrent eviction request when we are downloading? eviction + // api's use ResidentLayer, so evict could be moved there, or we just reset the state here. + // + // only reset this after we've decided we really need to download. otherwise it'd + // be impossible to mark cancelled downloads for eviction, like one could imagine + // we would like to do for prefetching which was not needed. + self.wanted_evicted.store(false, Ordering::Release); + if !can_ever_evict { anyhow::bail!("refusing to attempt downloading {self} because no remote timeline client, reason: {reason}") };