diff --git a/pageserver/src/tenant/storage_layer.rs b/pageserver/src/tenant/storage_layer.rs index f06f232725..8d369f568c 100644 --- a/pageserver/src/tenant/storage_layer.rs +++ b/pageserver/src/tenant/storage_layer.rs @@ -544,7 +544,7 @@ impl LayerE { } pub(crate) async fn evict_and_wait( - &self, + self: &Arc, _: &RemoteTimelineClient, ) -> Result<(), super::timeline::EvictionError> { use tokio::sync::broadcast::error::RecvError; @@ -606,7 +606,7 @@ impl LayerE { reconstruct_data: &mut ValueReconstructState, ctx: &RequestContext, ) -> anyhow::Result { - let layer = self.get_or_download(Some(ctx)).await?; + let layer = self.get_or_maybe_download(true, Some(ctx)).await?; self.access_stats .record_access(LayerAccessKind::GetValueReconstructData, ctx); @@ -619,7 +619,7 @@ impl LayerE { self: &Arc, ctx: &RequestContext, ) -> anyhow::Result>> { - let layer = self.get_or_download(Some(ctx)).await?; + let layer = self.get_or_maybe_download(true, Some(ctx)).await?; self.access_stats .record_access(LayerAccessKind::KeyIter, ctx); @@ -632,12 +632,7 @@ impl LayerE { self: &Arc, allow_download: bool, ) -> anyhow::Result { - let downloaded = if !allow_download { - self.get() - .ok_or_else(|| anyhow::anyhow!("layer {self} is not downloaded")) - } else { - self.get_or_download(None).await - }?; + let downloaded = self.get_or_maybe_download(allow_download, None).await?; Ok(ResidentLayer { _downloaded: downloaded, @@ -645,6 +640,11 @@ impl LayerE { }) } + pub(crate) async fn get_or_download(self: &Arc) -> anyhow::Result<()> { + self.get_or_maybe_download(true, None).await?; + Ok(()) + } + fn get_or_apply_evictedness( guard: Option>, wanted_evicted: &AtomicBool, @@ -664,11 +664,11 @@ impl LayerE { } /// Cancellation safe. - pub(crate) async fn get_or_download( + async fn get_or_maybe_download( self: &Arc, + allow_download: bool, ctx: Option<&RequestContext>, - ) -> anyhow::Result> { - let allow_download = true; + ) -> Result, DownloadError> { let download = move || async move { // disable any scheduled but not yet running eviction deletions for this self.version.fetch_add(1, Ordering::Relaxed); diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 1725b6aadd..253202f1a2 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -3989,7 +3989,7 @@ impl Timeline { js.spawn( async move { - let res = next.get_or_download(None).await; + let res = next.get_or_download().await; (next, res) } .instrument(span),