SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
[volume] remove truncate idx file if size not healthy (#6043)
Konstantin Lebedev6d4f5c94ac9f
diff --git a/weed/storage/volume_checking.go b/weed/storage/volume_checking.goindex f5ceffcce8..9bd432f857 100644--- a/weed/storage/volume_checking.go+++ b/weed/storage/volume_checking.go@@ -14,7 +14,7 @@ import ("github.com/seaweedfs/seaweedfs/weed/util")-func CheckAndFixVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAtNs uint64, err error) {+func CheckVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAtNs uint64, err error) {var indexSize int64if indexSize, err = verifyIndexFileIntegrity(indexFile); err != nil {return 0, fmt.Errorf("verifyIndexFileIntegrity %s failed: %v", indexFile.Name(), err)@@ -35,11 +35,7 @@ func CheckAndFixVolumeDataIntegrity(v *Volume, indexFile *os.File) (lastAppendAt}}if healthyIndexSize < indexSize {- glog.Warningf("CheckAndFixVolumeDataIntegrity truncate idx file %s from %d to %d", indexFile.Name(), indexSize, healthyIndexSize)- err = indexFile.Truncate(healthyIndexSize)- if err != nil {- glog.Warningf("CheckAndFixVolumeDataIntegrity truncate idx file %s from %d to %d: %v", indexFile.Name(), indexSize, healthyIndexSize, err)- }+ return 0, fmt.Errorf("CheckVolumeDataIntegrity %s failed: index size %d differs from healthy size %d", indexFile.Name(), indexSize, healthyIndexSize)}return}diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.goindex 7064fdc039..919b6e2a03 100644--- a/weed/storage/volume_loading.go+++ b/weed/storage/volume_loading.go@@ -135,7 +135,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind// capactiy overloading.if !v.HasRemoteFile() {glog.V(0).Infof("checking volume data integrity for volume %d", v.Id)- if v.lastAppendAtNs, err = CheckAndFixVolumeDataIntegrity(v, indexFile); err != nil {+ if v.lastAppendAtNs, err = CheckVolumeDataIntegrity(v, indexFile); err != nil {v.noWriteOrDelete = trueglog.V(0).Infof("volumeDataIntegrityChecking failed %v", err)}