forked from TrueCloudLab/frostfs-node
[#741] treesvc: Do not update sync height if some node is unavailable
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
b215817e14
commit
b21be1abdd
1 changed files with 14 additions and 1 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"math"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
|
@ -284,10 +285,14 @@ func (s *Service) synchronizeTree(ctx context.Context, cid cid.ID, from uint64,
|
|||
return nil
|
||||
})
|
||||
|
||||
var allNodesSynced atomic.Bool
|
||||
allNodesSynced.Store(true)
|
||||
|
||||
for i, n := range nodes {
|
||||
i := i
|
||||
n := n
|
||||
errGroup.Go(func() error {
|
||||
var nodeSynced bool
|
||||
n.IterateNetworkEndpoints(func(addr string) bool {
|
||||
var a network.Address
|
||||
if err := a.FromString(addr); err != nil {
|
||||
|
@ -316,13 +321,18 @@ func (s *Service) synchronizeTree(ctx context.Context, cid cid.ID, from uint64,
|
|||
// Error with the response, try the next node.
|
||||
s.log.Warn(logs.TreeFailedToRunTreeSynchronizationForSpecificNode, zap.Error(err), zap.String("address", addr))
|
||||
}
|
||||
nodeSynced = err == nil
|
||||
return true
|
||||
})
|
||||
close(nodeOperationStreams[i])
|
||||
if !nodeSynced {
|
||||
allNodesSynced.Store(false)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
if err := errGroup.Wait(); err != nil {
|
||||
allNodesSynced.Store(false)
|
||||
s.log.Warn(logs.TreeFailedToRunTreeSynchronizationOverAllNodes, zap.Error(err))
|
||||
}
|
||||
|
||||
|
@ -332,7 +342,10 @@ func (s *Service) synchronizeTree(ctx context.Context, cid cid.ID, from uint64,
|
|||
} else {
|
||||
newHeight++
|
||||
}
|
||||
if allNodesSynced.Load() {
|
||||
return newHeight
|
||||
}
|
||||
return from
|
||||
}
|
||||
|
||||
// ErrAlreadySyncing is returned when a service synchronization has already
|
||||
|
|
Loading…
Reference in a new issue