diff options
| author | chrislu <chris.lu@gmail.com> | 2024-02-25 08:00:37 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2024-02-25 08:00:37 -0800 |
| commit | a52ce076fc4d699f2155aa1e4e269a71c2674e92 (patch) | |
| tree | 2d6f343a3ec01588eb3c6eaf62f3dd712ce6b83c /weed/storage | |
| parent | 16b4f9d9ab5897e29eab36d78ddf625a050f5a8d (diff) | |
| parent | 7187346cc1630f92c0aa4679965e4bdc0149a6d7 (diff) | |
| download | seaweedfs-a52ce076fc4d699f2155aa1e4e269a71c2674e92.tar.xz seaweedfs-a52ce076fc4d699f2155aa1e4e269a71c2674e92.zip | |
Merge branch 'master' into mq-subscribe
Diffstat (limited to 'weed/storage')
| -rw-r--r-- | weed/storage/backend/memory_map/memory_map_windows.go | 4 | ||||
| -rw-r--r-- | weed/storage/volume_checking.go | 8 | ||||
| -rw-r--r-- | weed/storage/volume_vacuum.go | 20 |
3 files changed, 22 insertions, 10 deletions
diff --git a/weed/storage/backend/memory_map/memory_map_windows.go b/weed/storage/backend/memory_map/memory_map_windows.go index ce0c04318..b120c8dd7 100644 --- a/weed/storage/backend/memory_map/memory_map_windows.go +++ b/weed/storage/backend/memory_map/memory_map_windows.go @@ -301,7 +301,7 @@ func getSystemInfo() (_SYSTEM_INFO, error) { // PSIZE_T lpMinimumWorkingSetSize, // PSIZE_T lpMaximumWorkingSetSize // ); -// https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprocessworkingsetsize +// https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-getprocessworkingsetsize func getProcessWorkingSetSize(process uintptr, dwMinWorkingSet *uint64, dwMaxWorkingSet *uint64) error { r1, _, err := syscall.Syscall(procGetProcessWorkingSetSize.Addr(), 3, process, uintptr(unsafe.Pointer(dwMinWorkingSet)), uintptr(unsafe.Pointer(dwMaxWorkingSet))) @@ -318,7 +318,7 @@ func getProcessWorkingSetSize(process uintptr, dwMinWorkingSet *uint64, dwMaxWor // SIZE_T dwMinimumWorkingSetSize, // SIZE_T dwMaximumWorkingSetSize // ); -// https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessworkingsetsize +// https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-setprocessworkingsetsize func setProcessWorkingSetSize(process uintptr, dwMinWorkingSet uint64, dwMaxWorkingSet uint64) error { r1, _, err := syscall.Syscall(procSetProcessWorkingSetSize.Addr(), 3, process, uintptr(dwMinWorkingSet), uintptr(dwMaxWorkingSet)) diff --git a/weed/storage/volume_checking.go b/weed/storage/volume_checking.go index 0f92a2e93..4d51e081f 100644 --- a/weed/storage/volume_checking.go +++ b/weed/storage/volume_checking.go @@ -118,12 +118,8 @@ func verifyNeedleIntegrity(datFile backend.BackendStorageFile, v needle.Version, return n.AppendAtNs, nil } if fileSize > fileTailOffset { - glog.Warningf("Truncate %s from %d bytes to %d bytes!", datFile.Name(), fileSize, fileTailOffset) - err = datFile.Truncate(fileTailOffset) - if err == nil { - return n.AppendAtNs, nil - } - return n.AppendAtNs, fmt.Errorf("truncate file %s: %v", datFile.Name(), err) + glog.Warningf("data file %s actual %d bytes expected %d bytes!", datFile.Name(), fileSize, fileTailOffset) + return n.AppendAtNs, fmt.Errorf("data file %s actual %d bytes expected %d bytes", datFile.Name(), fileSize, fileTailOffset) } glog.Warningf("data file %s has %d bytes, less than expected %d bytes!", datFile.Name(), fileSize, fileTailOffset) } diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go index 0eaca5ff4..b070fa901 100644 --- a/weed/storage/volume_vacuum.go +++ b/weed/storage/volume_vacuum.go @@ -423,7 +423,10 @@ func (v *Volume) copyDataBasedOnIndexFile(srcDatName, srcIdxName, dstDatName, da if dstDatBackend, err = backend.CreateVolumeFile(dstDatName, preallocate, 0); err != nil { return err } - defer dstDatBackend.Close() + defer func() { + dstDatBackend.Sync() + dstDatBackend.Close() + }() oldNm := needle_map.NewMemDb() defer oldNm.Close() @@ -484,7 +487,20 @@ func (v *Volume) copyDataBasedOnIndexFile(srcDatName, srcIdxName, dstDatName, da if err != nil { return err } - + dstDatSize, _, err := dstDatBackend.GetStat() + if err != nil { + return err + } + if v.nm.ContentSize() > v.nm.DeletedSize() { + expectedContentSize := v.nm.ContentSize() - v.nm.DeletedSize() + if expectedContentSize > uint64(dstDatSize) { + return fmt.Errorf("volume %s unexpected new data size: %d does not match size of content minus deleted: %d", + v.Id.String(), dstDatSize, expectedContentSize) + } + } else { + glog.Warningf("volume %s content size: %d less deleted size: %d, new size: %d", + v.Id.String(), v.nm.ContentSize(), v.nm.DeletedSize(), dstDatSize) + } err = newNm.SaveToIdx(datIdxName) if err != nil { return err |
