From 0d10992e463e9377d9791cdb90c5d13c452aa504 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Tue, 21 Nov 2023 15:30:40 +0200 Subject: [PATCH] Cleanup compact_level0_phase1 fsyncing (#5852) While reviewing code noticed a scary `layer_paths.pop().unwrap()` then realized this should be further asyncified, something I forgot to do when I switched the `compact_level0_phase1` back to async in #4938. This keeps the double-fsync for new deltas as #4749 is still unsolved. --- pageserver/src/tenant/timeline.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index bbb96cb172..7ae7b7e7e4 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -3497,21 +3497,22 @@ impl Timeline { } // FIXME: the writer already fsyncs all data, only rename needs to be fsynced here - let mut layer_paths: Vec = new_layers + let layer_paths: Vec = new_layers .iter() .map(|l| l.local_path().to_owned()) .collect(); // Fsync all the layer files and directory using multiple threads to // minimize latency. - // - // FIXME: spawn_blocking above for this - par_fsync::par_fsync(&layer_paths).context("fsync all new layers")?; + par_fsync::par_fsync_async(&layer_paths) + .await + .context("fsync all new layers")?; - par_fsync::par_fsync(&[self.conf.timeline_path(&self.tenant_id, &self.timeline_id)]) + let timeline_dir = self.conf.timeline_path(&self.tenant_id, &self.timeline_id); + + par_fsync::par_fsync_async(&[timeline_dir]) + .await .context("fsync of timeline dir")?; - - layer_paths.pop().unwrap(); } stats.write_layer_files_micros = stats.read_lock_drop_micros.till_now();