From 3a6101bd215ccf4d964ed9bc102d25081ba902f4 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sat, 6 Jul 2024 17:33:12 +0100 Subject: [PATCH] pageserver: initialize layer visbility opportunistically --- pageserver/src/tenant/timeline.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 50598e3398..c865bbbad6 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -2993,6 +2993,17 @@ impl Timeline { .set((calculated_size, metrics_guard.calculation_result_saved())) .ok() .expect("only this task sets it"); + + // As a nice-to-have, calculate layer visibilties. Otherwise this will + // be initialized on first compaction. Doing it as early as possible + // enables code that depends on layer visibility (like uploading heatmaps) + // to execute earlier, rather than waiting for compaction. + match self.update_layer_visibility(&background_ctx).await { + Ok(_) | Err(CompactionError::ShuttingDown) => {} + Err(e) => { + tracing::warn!("Initial layer visibility calculation failed: {e}"); + } + } } pub(crate) fn spawn_ondemand_logical_size_calculation(