Quick exit in truncate_wal if nothing to do.

ref https://github.com/neondatabase/neon/issues/4414
This commit is contained in:
Arseny Sher
2023-06-06 15:27:17 +04:00
committed by Arseny Sher
parent dc6a382873
commit c058e1cec2

View File

@@ -379,6 +379,12 @@ impl Storage for PhysicalStorage {
);
}
// Quick exit if nothing to do to avoid writing up to 16 MiB of zeros on
// disk (this happens on each connect).
if end_pos == self.write_lsn {
return Ok(());
}
// Close previously opened file, if any
if let Some(mut unflushed_file) = self.file.take() {
self.fdatasync_file(&mut unflushed_file)?;