From 9708df47d1be0943b6bf548c0dc0f1a06f5fcafa Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 31 Oct 2020 15:50:01 -0700 Subject: [PATCH] ensure offset in the index file is positive --- weed/storage/volume_checking.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/storage/volume_checking.go b/weed/storage/volume_checking.go index 048944199..00e04047f 100644 --- a/weed/storage/volume_checking.go +++ b/weed/storage/volume_checking.go @@ -22,7 +22,7 @@ func CheckAndFixVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAt return 0, nil } healthyIndexSize := indexSize - for i := 1; i <= 10; i++ { + for i := 1; i <= 10 && indexSize >= int64(i)*NeedleMapEntrySize; i++ { // check and fix last 10 entries lastAppendAtNs, err = doCheckAndFixVolumeData(v, indexFile, indexSize-int64(i)*NeedleMapEntrySize) if err == io.EOF {