mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 17:32:56 +00:00
refactor(LayerE): use new internal api
This commit is contained in:
@@ -544,7 +544,7 @@ impl LayerE {
|
||||
}
|
||||
|
||||
pub(crate) async fn evict_and_wait(
|
||||
&self,
|
||||
self: &Arc<Self>,
|
||||
_: &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<ValueReconstructResult> {
|
||||
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<Self>,
|
||||
ctx: &RequestContext,
|
||||
) -> anyhow::Result<Vec<DeltaEntry<ResidentDeltaLayer>>> {
|
||||
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<Self>,
|
||||
allow_download: bool,
|
||||
) -> anyhow::Result<ResidentLayer> {
|
||||
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<Self>) -> anyhow::Result<()> {
|
||||
self.get_or_maybe_download(true, None).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_or_apply_evictedness(
|
||||
guard: Option<heavier_once_cell::Guard<'_, ResidentOrWantedEvicted>>,
|
||||
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<Self>,
|
||||
allow_download: bool,
|
||||
ctx: Option<&RequestContext>,
|
||||
) -> anyhow::Result<Arc<DownloadedLayer>> {
|
||||
let allow_download = true;
|
||||
) -> Result<Arc<DownloadedLayer>, DownloadError> {
|
||||
let download = move || async move {
|
||||
// disable any scheduled but not yet running eviction deletions for this
|
||||
self.version.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user