mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume: sync to disk before copying volume files
address https://github.com/chrislusf/seaweedfs/issues/2976
This commit is contained in:
parent
3bce568c32
commit
94f824e1ce
|
@ -279,6 +279,7 @@ func (vs *VolumeServer) CopyFile(req *volume_server_pb.CopyFileRequest, stream v
|
||||||
if uint32(v.CompactionRevision) != req.CompactionRevision && req.CompactionRevision != math.MaxUint32 {
|
if uint32(v.CompactionRevision) != req.CompactionRevision && req.CompactionRevision != math.MaxUint32 {
|
||||||
return fmt.Errorf("volume %d is compacted", req.VolumeId)
|
return fmt.Errorf("volume %d is compacted", req.VolumeId)
|
||||||
}
|
}
|
||||||
|
v.SyncToDisk()
|
||||||
fileName = v.FileName(req.Ext)
|
fileName = v.FileName(req.Ext)
|
||||||
} else {
|
} else {
|
||||||
baseFileName := erasure_coding.EcShardBaseFileName(req.Collection, int(req.VolumeId)) + req.Ext
|
baseFileName := erasure_coding.EcShardBaseFileName(req.Collection, int(req.VolumeId)) + req.Ext
|
||||||
|
|
|
@ -190,6 +190,21 @@ func (v *Volume) SetStopping() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *Volume) SyncToDisk() {
|
||||||
|
v.dataFileAccessLock.Lock()
|
||||||
|
defer v.dataFileAccessLock.Unlock()
|
||||||
|
if v.nm != nil {
|
||||||
|
if err := v.nm.Sync(); err != nil {
|
||||||
|
glog.Warningf("Volume Close fail to sync volume idx %d", v.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v.DataBackend != nil {
|
||||||
|
if err := v.DataBackend.Sync(); err != nil {
|
||||||
|
glog.Warningf("Volume Close fail to sync volume %d", v.Id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Close cleanly shuts down this volume
|
// Close cleanly shuts down this volume
|
||||||
func (v *Volume) Close() {
|
func (v *Volume) Close() {
|
||||||
v.dataFileAccessLock.Lock()
|
v.dataFileAccessLock.Lock()
|
||||||
|
|
Loading…
Reference in a new issue