From f576dc50e88560c73f0a1628843a7506fa3a3b3a Mon Sep 17 00:00:00 2001 From: quantumish Date: Tue, 12 Aug 2025 01:48:54 -0700 Subject: [PATCH] Patch error with hole punching LFC --- pgxn/neon/communicator/src/file_cache.rs | 5 ++--- pgxn/neon/communicator/src/integrated_cache.rs | 6 +++--- .../neon/communicator/src/worker_process/in_progress_ios.rs | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pgxn/neon/communicator/src/file_cache.rs b/pgxn/neon/communicator/src/file_cache.rs index 1f7d9792d9..bfced4ef8b 100644 --- a/pgxn/neon/communicator/src/file_cache.rs +++ b/pgxn/neon/communicator/src/file_cache.rs @@ -9,7 +9,6 @@ //! process. The backend processes *also* read the file (and sometimes also //! write it? ), but the backends use direct C library calls for that. use std::fs::File; -use std::os::linux::fs::MetadataExt; use std::os::unix::fs::FileExt; use std::path::{Path, PathBuf}; use std::sync::Arc; @@ -179,7 +178,7 @@ impl FileCache { nix::FallocateFlags::FALLOC_FL_ZERO_RANGE .union(nix::FallocateFlags::FALLOC_FL_KEEP_SIZE), (block as usize * BLCKSZ) as libc::off_t, - 1 + BLCKSZ as libc::off_t ) { tracing::error!("failed to un-punch hole in LFC at {block}: {e}"); return; @@ -238,7 +237,7 @@ impl FileCache { /// of holes within a file. Whether we need this function at all is unclear, /// as seemingly this part of the codebase only targets a system with ext4? #[cfg(target_os = "macos")] - pub fn undelete_blocks(&self, num_blocks: u64) -> u64 { + pub fn unpunch_blocks(&self, num_blocks: u64) -> u64 { use nix::unistd as nix; let mut free_list = self.free_list.lock().unwrap(); let num_bytes = (free_list.next_free_block * BLOCKSZ) as i64; diff --git a/pgxn/neon/communicator/src/integrated_cache.rs b/pgxn/neon/communicator/src/integrated_cache.rs index 4abcf4f635..cdb21f9eda 100644 --- a/pgxn/neon/communicator/src/integrated_cache.rs +++ b/pgxn/neon/communicator/src/integrated_cache.rs @@ -798,7 +798,7 @@ impl<'t> IntegratedCacheWriteAccess<'t> { err ); } - let remaining = file_cache.undelete_blocks(difference as u64); + let remaining = file_cache.unpunch_blocks(difference as u64); file_cache.grow(remaining as u64); debug_assert!(file_cache.free_space() > remaining); } else if old_num_blocks > num_blocks { @@ -832,7 +832,7 @@ impl<'t> IntegratedCacheWriteAccess<'t> { .fetch_max(old_val.lw_lsn.into_inner().0, Ordering::Relaxed); let cache_block = old_val.cache_block.into_inner(); if cache_block != INVALID_CACHE_BLOCK { - file_cache.delete_block(cache_block); + file_cache.punch_block(cache_block); file_evictions += 1; self.metrics.cache_page_evictions_counter.inc(); } @@ -850,7 +850,7 @@ impl<'t> IntegratedCacheWriteAccess<'t> { while remaining > 0 as u64 { if let Some(i) = self.try_evict_cache_block() { if i != INVALID_CACHE_BLOCK { - file_cache.delete_block(i); + file_cache.punch_block(i); remaining -= 1; } } diff --git a/pgxn/neon/communicator/src/worker_process/in_progress_ios.rs b/pgxn/neon/communicator/src/worker_process/in_progress_ios.rs index da926542cd..5979c9c23b 100644 --- a/pgxn/neon/communicator/src/worker_process/in_progress_ios.rs +++ b/pgxn/neon/communicator/src/worker_process/in_progress_ios.rs @@ -80,9 +80,9 @@ where break; } }; - // tracing::info!("waiting for conflicting IO {request_id} to complete"); + tracing::info!("waiting for conflicting IO {request_id} to complete"); let _ = lock.lock().await; - // tracing::info!("conflicting IO {request_id} completed"); + tracing::info!("conflicting IO {request_id} completed"); } MutexHashMapGuard {