Browse Source
fix: volume data integrity check (#6118)
Co-authored-by: wang wusong <wangwusong@virtaitech.com>
pull/6134/head
wusong
2 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
7 additions and
6 deletions
-
weed/storage/volume_checking.go
|
@ -2,10 +2,11 @@ package storage |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/super_block" |
|
|
|
|
|
"io" |
|
|
"io" |
|
|
"os" |
|
|
"os" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/super_block" |
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/backend" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/backend" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/idx" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/idx" |
|
@ -26,11 +27,11 @@ func CheckVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAtNs uin |
|
|
for i := 1; i <= 10 && indexSize >= int64(i)*NeedleMapEntrySize; i++ { |
|
|
for i := 1; i <= 10 && indexSize >= int64(i)*NeedleMapEntrySize; i++ { |
|
|
// check and fix last 10 entries
|
|
|
// check and fix last 10 entries
|
|
|
lastAppendAtNs, err = doCheckAndFixVolumeData(v, indexFile, indexSize-int64(i)*NeedleMapEntrySize) |
|
|
lastAppendAtNs, err = doCheckAndFixVolumeData(v, indexFile, indexSize-int64(i)*NeedleMapEntrySize) |
|
|
if err == io.EOF { |
|
|
|
|
|
healthyIndexSize = indexSize - int64(i)*NeedleMapEntrySize |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
if err != ErrorSizeMismatch { |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
if err == io.EOF { |
|
|
|
|
|
healthyIndexSize = indexSize - int64(i)*NeedleMapEntrySize |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|