Add a version token on RPCs to read/update volume server states. (#8191)

* Add a version token on `GetState()`/`SetState()` RPCs for volume server states.

* Make state version a property ov `VolumeServerState` instead of an in-memory counter.

Also extend state atomicity to reads, instead of just writes.
This commit is contained in:
Lisandro Pin
2026-02-06 19:58:43 +01:00
committed by GitHub
parent c44716f9af
commit 2cda4289f4
8 changed files with 104 additions and 54 deletions

View File

@@ -160,9 +160,9 @@ func NewStore(
func (s *Store) LoadState() error {
err := s.State.Load()
if s.State.Pb != nil && err == nil {
if s.State.Proto() != nil && err == nil {
select {
case s.StateUpdateChan <- s.State.Pb:
case s.StateUpdateChan <- s.State.Proto():
default:
glog.V(2).Infof("StateUpdateChan full during LoadState, state will be reported in heartbeat")
}
@@ -171,15 +171,15 @@ func (s *Store) LoadState() error {
}
func (s *Store) SaveState() error {
if s.State.Pb == nil {
if s.State.Proto() == nil {
glog.Warningf("tried to save empty state for store %s", s.Id)
return nil
}
err := s.State.Save()
if s.State.Pb != nil && err == nil {
if s.State.Proto() != nil && err == nil {
select {
case s.StateUpdateChan <- s.State.Pb:
case s.StateUpdateChan <- s.State.Proto():
default:
glog.V(2).Infof("StateUpdateChan full during SaveState, state will be reported in heartbeat")
}