fix(ecstore): bound readahead on cold shard window reads

This commit is contained in:
overtrue
2026-12-02 07:10:00 +08:00
parent 4014e284da
commit af3b0c5bfc
+4 -3
View File
@@ -15273,11 +15273,12 @@ async fn batch_shard_pread_blocking(requests: Vec<PermittedShardPreadRequest>) -
metrics.as_deref(),
LocalBatchReadStage::Read,
|| {
// Preload the requested window before reading it. Kernel
// readahead is advisory and may still extend past the
// window, so the tail is reclaimed after the read below.
// Preload just this window. Disable automatic readahead
// on this descriptor so pread does not start a second
// read past the window while the explicit hint is in flight.
#[cfg(target_os = "linux")]
if let (Ok(start), Ok(len)) = (u64::try_from(offset), u64::try_from(length)) {
let _ = rustix::fs::fadvise(&file, 0, None, rustix::fs::Advice::Random);
let _ = rustix::fs::fadvise(
&file,
start,