fix(blob): invalidate FilePool after GC to prevent stale reads

This commit is contained in:
rustmailer
2026-06-23 23:28:33 +08:00
parent 11e40750fe
commit cd98c050b6
2 changed files with 8 additions and 1 deletions
+8
View File
@@ -299,6 +299,14 @@ impl Engine {
let result = gc::gc_account(&account_dir, self.config.gc_deleted_ratio)?;
// Invalidate FilePool for GC'd segments (they were rewritten via rename)
if let Some(ref stats) = result {
let accounts = self.accounts.read().unwrap();
if let Some(handle) = accounts.get(account_id) {
handle.invalidate_file_cache(stats.segment_id);
}
}
for bid in 0..crate::types::BUCKET_COUNT {
self.cache.invalidate(account_id, bid);
}
-1
View File
@@ -273,7 +273,6 @@ impl SegmentReader {
/// Read a single entry at the given offset using a pre-opened File (via Mutex).
/// This avoids the per-read File::open cost for hot segments.
pub fn read_entry_at_file(&self, offset: u64, file: &Mutex<File>) -> Result<(Entry, u64)> {
use std::io::{Read, Seek, SeekFrom};
let mut file = file.lock().unwrap();