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: fail fast if idx files are missing
Chris Lu885ca3474892
diff --git a/weed/storage/volume_checking.go b/weed/storage/volume_checking.goindex 8d63c39c10..b769330831 100644--- a/weed/storage/volume_checking.go+++ b/weed/storage/volume_checking.go@@ -2,6 +2,7 @@ package storageimport ("fmt"+ "github.com/chrislusf/seaweedfs/weed/storage/super_block""io""os"@@ -148,3 +149,18 @@ func verifyDeletedNeedleIntegrity(datFile backend.BackendStorageFile, v needle.V}return n.AppendAtNs, err}++func (v *Volume) checkIdxFile() error {+ datFileSize, _, err := v.DataBackend.GetStat()+ if err != nil {+ return fmt.Errorf("get stat %s: %v", v.FileName(".dat"), err)+ }+ if datFileSize <= super_block.SuperBlockSize {+ return nil+ }+ indexFileName := v.FileName(".idx")+ if util.FileExists(indexFileName) {+ return nil+ }+ return fmt.Errorf("idx file %s does not exists", indexFileName)+}diff --git a/weed/storage/volume_loading.go b/weed/storage/volume_loading.goindex 52a50a98c8..bff1055bbe 100644--- a/weed/storage/volume_loading.go+++ b/weed/storage/volume_loading.go@@ -96,6 +96,10 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKindv.dirIdx = v.dir}}+ // check volume idx files+ if err := v.checkIdxFile(); err != nil {+ glog.Fatalf("check volume idx file %s: %v", v.FileName(".idx"), err)+ }var indexFile *os.Fileif v.noWriteOrDelete {glog.V(0).Infoln("open to read file", v.FileName(".idx"))