Browse Source

fix VolumeTierMoveDatToRemote to close local dat backend after upload

Go calls v.LoadRemoteFile() after saving volume info, which closes
the local DataBackend before transitioning to remote storage. Without
this, the volume holds a stale file handle to the deleted local .dat
file, causing reads to fail until server restart.
pull/8539/head
Chris Lu 2 weeks ago
parent
commit
d02d02893c
  1. 6
      seaweed-volume/src/server/grpc_server.rs
  2. 6
      seaweed-volume/src/storage/volume.rs

6
seaweed-volume/src/server/grpc_server.rs

@ -2888,7 +2888,11 @@ impl VolumeServer for VolumeGrpcService {
)));
}
// Optionally remove local .dat file
// Close local dat file handle (matches Go's v.LoadRemoteFile
// which closes DataBackend before switching to remote)
vol.close_local_dat_backend();
// Optionally remove local .dat file from disk
if !keep_local {
let dat = vol.dat_path();
let _ = std::fs::remove_file(&dat);

6
seaweed-volume/src/storage/volume.rs

@ -2084,6 +2084,12 @@ impl Volume {
}
}
/// Close the local .dat file handle (matches Go's v.DataBackend.Close() in LoadRemoteFile).
/// Called after tier-upload when the local file is being replaced by remote storage.
pub fn close_local_dat_backend(&mut self) {
self.dat_file = None;
}
/// Path to .vif file.
fn vif_path(&self) -> String {
format!("{}.vif", self.data_file_name())

Loading…
Cancel
Save