mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-31 12:00:42 +00:00
fix: move metric updates to finish_compact_l0
This commit is contained in:
@@ -3416,10 +3416,6 @@ impl Timeline {
|
||||
} else if LayerMap::is_l0(l.layer_desc()) {
|
||||
return Err(CompactionError::Other(anyhow!("compaction generates a L0 layer file as output, which will cause infinite compaction.")));
|
||||
} else {
|
||||
// update the timeline's physical size
|
||||
self.metrics
|
||||
.resident_physical_size_gauge
|
||||
.add(l.layer_desc().file_size);
|
||||
insert_layers.push(l);
|
||||
}
|
||||
}
|
||||
@@ -3433,7 +3429,12 @@ impl Timeline {
|
||||
|
||||
// deletion will happen later, the layer file manager sets wanted_garbage_collected
|
||||
|
||||
guard.finish_compact_l0(&layer_removal_cs, remove_layers, &insert_layers)?;
|
||||
guard.finish_compact_l0(
|
||||
&layer_removal_cs,
|
||||
remove_layers,
|
||||
&insert_layers,
|
||||
&self.metrics,
|
||||
)?;
|
||||
|
||||
drop_wlock(guard);
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ impl LayerManager {
|
||||
layer_removal_cs: &Arc<tokio::sync::OwnedMutexGuard<()>>,
|
||||
compact_from: Vec<Arc<LayerE>>,
|
||||
compact_to: &[ResidentLayer],
|
||||
metrics: &crate::metrics::TimelineMetrics,
|
||||
) -> Result<()> {
|
||||
let mut updates = self.layer_map.batch_update();
|
||||
for l in compact_to {
|
||||
@@ -213,6 +214,10 @@ impl LayerManager {
|
||||
LayerResidenceStatus::Resident,
|
||||
LayerResidenceEventReason::LayerCreate,
|
||||
);
|
||||
metrics
|
||||
.resident_physical_size_gauge
|
||||
.add(l.layer_desc().file_size);
|
||||
|
||||
Self::insert_historic_layer(l.as_ref().clone(), &mut updates, &mut self.layer_fmgr);
|
||||
}
|
||||
for l in compact_from {
|
||||
|
||||
Reference in New Issue
Block a user