mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #2644 from kmlebedev/vacum_fsync
updated needle with fsync
This commit is contained in:
commit
f46763d74f
|
@ -289,6 +289,9 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
|
||||||
return fmt.Errorf("ReadNeedleBlob %s key %d offset %d size %d failed: %v", oldDatFile.Name(), key, increIdxEntry.offset.ToActualOffset(), increIdxEntry.size, err)
|
return fmt.Errorf("ReadNeedleBlob %s key %d offset %d size %d failed: %v", oldDatFile.Name(), key, increIdxEntry.offset.ToActualOffset(), increIdxEntry.size, err)
|
||||||
}
|
}
|
||||||
dstDatBackend.Write(needleBytes)
|
dstDatBackend.Write(needleBytes)
|
||||||
|
if err := dstDatBackend.Sync(); err != nil {
|
||||||
|
return fmt.Errorf("cannot sync needle %s: %v", dstDatBackend.File.Name(), err)
|
||||||
|
}
|
||||||
util.Uint32toBytes(idxEntryBytes[8:12], uint32(offset/NeedlePaddingSize))
|
util.Uint32toBytes(idxEntryBytes[8:12], uint32(offset/NeedlePaddingSize))
|
||||||
} else { //deleted needle
|
} else { //deleted needle
|
||||||
//fakeDelNeedle 's default Data field is nil
|
//fakeDelNeedle 's default Data field is nil
|
||||||
|
@ -308,6 +311,12 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
|
||||||
newIdxFileName, err)
|
newIdxFileName, err)
|
||||||
}
|
}
|
||||||
_, err = idx.Write(idxEntryBytes)
|
_, err = idx.Write(idxEntryBytes)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("cannot write indexfile %s: %v", newIdxFileName, err)
|
||||||
|
}
|
||||||
|
if err := idx.Sync(); err != nil {
|
||||||
|
return fmt.Errorf("cannot sync indexfile %s: %v", newIdxFileName, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue