From a439d57050dafd603d24e001215213eb5246a029 Mon Sep 17 00:00:00 2001 From: Yuchen Liang <70461588+yliang412@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:28:31 -0500 Subject: [PATCH] review: cleanup comments + expect_err Co-authored-by: Christian Schwarz --- pageserver/src/virtual_file/owned_buffers_io/write/flush.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pageserver/src/virtual_file/owned_buffers_io/write/flush.rs b/pageserver/src/virtual_file/owned_buffers_io/write/flush.rs index 5b3997963e..7c5c10b918 100644 --- a/pageserver/src/virtual_file/owned_buffers_io/write/flush.rs +++ b/pageserver/src/virtual_file/owned_buffers_io/write/flush.rs @@ -163,13 +163,14 @@ where } // Wait for an available buffer from the background flush task. + // This is the BACKPRESSURE mechanism: if the flush task can't keep up, + // then the write path will eventually wait for it here. let Some(recycled) = self.inner_mut().channel.recv().await else { return self.handle_error().await; }; // The only other place that could hold a reference to the recycled buffer // is in `Self::maybe_flushed`, but we have already replace it with the new buffer. - let recycled = Buffer::reuse_after_flush(recycled.into_raw_slice().into_inner()); Ok((recycled, flush_control)) } @@ -193,7 +194,7 @@ where } async fn handle_error(&mut self) -> std::io::Result { - Err(self.shutdown().await.unwrap_err()) + Err(self.shutdown().await.expect_err("flush task only disconnects duplex if it exits with an error")) } }