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 bug: two same volumeId in different collections 1, there will be two leader when master server startup in a few seconds 2, raft server will get a leader even there is only one master, so there is no need to do hard code to set the server to be leader
cheng.li0125fbff5d52f0
diff --git a/weed/topology/topology.go b/weed/topology/topology.goindex 993f444a74..f93d2179c6 100644--- a/weed/topology/topology.go+++ b/weed/topology/topology.go@@ -5,6 +5,7 @@ import ("fmt""math/rand""sync"+ "time""github.com/chrislusf/raft"@@ -65,26 +66,26 @@ func (t *Topology) IsLeader() bool {if t.RaftServer.State() == raft.Leader {return true}- if t.RaftServer.Leader() == "" {- return true- }}return false}func (t *Topology) Leader() (string, error) {l := ""- if t.RaftServer != nil {- l = t.RaftServer.Leader()- } else {- return "", errors.New("Raft Server not ready yet!")- }-- if l == "" {- // We are a single node cluster, we are the leader- return t.RaftServer.Name(), nil+ count := 3+ for count > 0 {+ if t.RaftServer != nil {+ l = t.RaftServer.Leader()+ } else {+ return "", errors.New("Raft Server not ready yet!")+ }+ if l != "" {+ break+ } else {+ time.Sleep(time.Duration(5-count) * time.Second)+ }+ count -= 1}-return l, nil}