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
fix leader master /dir/lookup api
Lei Liuf2f90436efaf
diff --git a/weed/sequence/memory_sequencer.go b/weed/sequence/memory_sequencer.goindex d727dc7230..e20c29cc73 100644--- a/weed/sequence/memory_sequencer.go+++ b/weed/sequence/memory_sequencer.go@@ -15,12 +15,12 @@ func NewMemorySequencer() (m *MemorySequencer) {return}-func (m *MemorySequencer) NextFileId(count uint64) (uint64, uint64) {+func (m *MemorySequencer) NextFileId(count uint64) uint64 {m.sequenceLock.Lock()defer m.sequenceLock.Unlock()ret := m.counter- m.counter += uint64(count)- return ret, count+ m.counter += count+ return ret}func (m *MemorySequencer) SetMax(seenValue uint64) {diff --git a/weed/sequence/sequence.go b/weed/sequence/sequence.goindex fbdc3b8ef9..2258d001b2 100644--- a/weed/sequence/sequence.go+++ b/weed/sequence/sequence.go@@ -1,7 +1,7 @@package sequencetype Sequencer interface {- NextFileId(count uint64) (uint64, uint64)+ NextFileId(count uint64) uint64SetMax(uint64)Peek() uint64}diff --git a/weed/server/master_server_handlers.go b/weed/server/master_server_handlers.goindex c10f9a5b7b..9bcd35ced7 100644--- a/weed/server/master_server_handlers.go+++ b/weed/server/master_server_handlers.go@@ -65,11 +65,17 @@ func (ms *MasterServer) findVolumeLocation(collection, vid string) operation.Loovar err errorif ms.Topo.IsLeader() {volumeId, newVolumeIdErr := needle.NewVolumeId(vid)- machines := ms.Topo.Lookup(collection, volumeId)- for _, loc := range machines {- locations = append(locations, operation.Location{Url: loc.Url(), PublicUrl: loc.PublicUrl})+ if newVolumeIdErr != nil {+ err = fmt.Errorf("Unknown volume id %s", vid)+ } else {+ machines := ms.Topo.Lookup(collection, volumeId)+ for _, loc := range machines {+ locations = append(locations, operation.Location{Url: loc.Url(), PublicUrl: loc.PublicUrl})+ }+ if locations == nil {+ err = fmt.Errorf("volume id %s not found", vid)+ }}- err = newVolumeIdErr} else {machines, getVidLocationsErr := ms.MasterClient.GetVidLocations(vid)for _, loc := range machines {diff --git a/weed/topology/topology.go b/weed/topology/topology.goindex ea0769248e..b7ebe8af53 100644--- a/weed/topology/topology.go+++ b/weed/topology/topology.go@@ -125,7 +125,7 @@ func (t *Topology) PickForWrite(count uint64, option *VolumeGrowOption) (string,if datanodes.Length() == 0 {return "", 0, nil, fmt.Errorf("no writable volumes available for collection:%s replication:%s ttl:%s", option.Collection, option.ReplicaPlacement.String(), option.Ttl.String())}- fileId, count := t.Sequence.NextFileId(count)+ fileId := t.Sequence.NextFileId(count)return needle.NewFileId(*vid, fileId, rand.Uint32()).String(), count, datanodes.Head(), nil}