unrelated: layer_manager: avoid arc cloning

This commit is contained in:
Joonas Koivunen
2023-08-18 20:43:11 +03:00
parent fbcd174489
commit f8227da9da
2 changed files with 7 additions and 7 deletions

View File

@@ -3769,7 +3769,7 @@ impl Timeline {
}
guard.finish_compact_l0(
layer_removal_cs,
&layer_removal_cs,
remove_layers,
insert_layers,
&self.metrics,
@@ -4106,7 +4106,7 @@ impl Timeline {
layer_names_to_delete.push(doomed_layer.filename());
result.layers_removed += 1;
}
let apply = guard.finish_gc_timeline(layer_removal_cs, gc_layers, &self.metrics)?;
let apply = guard.finish_gc_timeline(&layer_removal_cs, gc_layers, &self.metrics)?;
if result.layers_removed != 0 {
fail_point!("after-timeline-gc-removed-layers");

View File

@@ -195,7 +195,7 @@ impl LayerManager {
/// Called when compaction is completed.
pub(crate) fn finish_compact_l0(
&mut self,
layer_removal_cs: Arc<tokio::sync::OwnedMutexGuard<()>>,
layer_removal_cs: &Arc<tokio::sync::OwnedMutexGuard<()>>,
compact_from: Vec<Arc<dyn PersistentLayer>>,
compact_to: Vec<Arc<dyn PersistentLayer>>,
metrics: &TimelineMetrics,
@@ -209,7 +209,7 @@ impl LayerManager {
// in the LayerFileManager because compaction kept holding `layer_removal_cs` the entire
// time, even though we dropped `Timeline::layers` inbetween.
Self::delete_historic_layer(
layer_removal_cs.clone(),
&layer_removal_cs,
l,
&mut updates,
metrics,
@@ -223,14 +223,14 @@ impl LayerManager {
/// Called when garbage collect the timeline. Returns a guard that will apply the updates to the layer map.
pub(crate) fn finish_gc_timeline(
&mut self,
layer_removal_cs: Arc<tokio::sync::OwnedMutexGuard<()>>,
layer_removal_cs: &Arc<tokio::sync::OwnedMutexGuard<()>>,
gc_layers: Vec<Arc<dyn PersistentLayer>>,
metrics: &TimelineMetrics,
) -> Result<ApplyGcResultGuard> {
let mut updates = self.layer_map.batch_update();
for doomed_layer in gc_layers {
Self::delete_historic_layer(
layer_removal_cs.clone(),
layer_removal_cs,
doomed_layer,
&mut updates,
metrics,
@@ -254,7 +254,7 @@ impl LayerManager {
/// Remote storage is not affected by this operation.
fn delete_historic_layer(
// we cannot remove layers otherwise, since gc and compaction will race
_layer_removal_cs: Arc<tokio::sync::OwnedMutexGuard<()>>,
_layer_removal_cs: &Arc<tokio::sync::OwnedMutexGuard<()>>,
layer: Arc<dyn PersistentLayer>,
updates: &mut BatchedUpdates<'_>,
metrics: &TimelineMetrics,