mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-04 19:17:46 +01:00
* design: durable volume-id allocation boundary (#11763) * master: mirror max volume id to a file outside raft (#11763) The allocation bound lived only in raft state, so a master that lost it rebuilt the bound from whatever volume servers were connected and could reissue ids held by offline servers. NextVolumeId now persists the bound to <mdir>/max_volume_id before the raft apply, and both raft implementations persist on apply and recovery so follower mirrors stay current. The file also carries the topology id, which survives raft state cleanup the same way the snapshot recovery did. * master: serialize and fully sync the max volume id mirror (#11763) * master: rewrite the mirror when the topology id changes at the same bound A same-bound raft apply carrying a new topology id was skipped by the lastPersistedMaxVolumeId check, leaving the mirrored topology id empty until the next allocation. Track the mirrored topology id too and rewrite when either value differs. * drop the design doc from the PR stack
This commit is contained in:
1 parent
ab559bca76
commit
0b3ed4502f
5 files changed
+200
No files matched your search
@@ -149,6 +149,7 @@ func NewHashicorpRaftServer(option *RaftServerOption) (*RaftServer, error) {
|
||||
if err := os.MkdirAll(path.Join(s.dataDir, "snapshots"), os.ModePerm); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
option.Topo.SetMaxVolumeIdFile(filepath.Join(s.dataDir, "max_volume_id"))
|
||||
baseDir := s.dataDir
|
||||
|
||||
ldb, err := boltdb.NewBoltStore(filepath.Join(baseDir, ldbFile))
|
||||
|
||||
@@ -76,6 +76,9 @@ func (s StateMachine) Recovery(data []byte) error {
|
||||
s.topo.SetTopologyId(state.TopologyId)
|
||||
glog.V(0).Infof("Recovered TopologyId: %s", state.TopologyId)
|
||||
}
|
||||
if err := s.topo.PersistMaxVolumeId(state.MaxVolumeId); err != nil {
|
||||
glog.Warningf("persist max volume id %d: %v", state.MaxVolumeId, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -95,6 +98,9 @@ func (s *StateMachine) Apply(l *hashicorpRaft.Log) interface{} {
|
||||
glog.V(0).Infof("Set TopologyId from raft log: %s", state.TopologyId)
|
||||
}
|
||||
}
|
||||
if err := s.topo.PersistMaxVolumeId(state.MaxVolumeId); err != nil {
|
||||
glog.Warningf("persist max volume id %d: %v", state.MaxVolumeId, err)
|
||||
}
|
||||
|
||||
glog.V(1).Infoln("max volume id", before, "==>", s.topo.GetMaxVolumeId())
|
||||
return nil
|
||||
@@ -163,6 +169,7 @@ func NewRaftServer(option *RaftServerOption) (*RaftServer, error) {
|
||||
if err := os.MkdirAll(path.Join(s.dataDir, "snapshot"), os.ModePerm); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
option.Topo.SetMaxVolumeIdFile(path.Join(s.dataDir, "max_volume_id"))
|
||||
|
||||
stateMachine := StateMachine{topo: option.Topo}
|
||||
s.raftServer, err = raft.NewServer(string(s.serverAddr), s.dataDir, transporter, stateMachine, option.Topo, s.serverAddr.ToGrpcAddress())
|
||||
|
||||
Reference in new issue
Block a user