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"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"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
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var allNodesSynced atomic.Bool
|
||||||
|
allNodesSynced.Store(true)
|
||||||
|
|
||||||
for i, n := range nodes {
|
for i, n := range nodes {
|
||||||
i := i
|
i := i
|
||||||
n := n
|
n := n
|
||||||
errGroup.Go(func() error {
|
errGroup.Go(func() error {
|
||||||
|
var nodeSynced bool
|
||||||
n.IterateNetworkEndpoints(func(addr string) bool {
|
n.IterateNetworkEndpoints(func(addr string) bool {
|
||||||
var a network.Address
|
var a network.Address
|
||||||
if err := a.FromString(addr); err != nil {
|
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.
|
// Error with the response, try the next node.
|
||||||
s.log.Warn(logs.TreeFailedToRunTreeSynchronizationForSpecificNode, zap.Error(err), zap.String("address", addr))
|
s.log.Warn(logs.TreeFailedToRunTreeSynchronizationForSpecificNode, zap.Error(err), zap.String("address", addr))
|
||||||
}
|
}
|
||||||
|
nodeSynced = err == nil
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
close(nodeOperationStreams[i])
|
close(nodeOperationStreams[i])
|
||||||
|
if !nodeSynced {
|
||||||
|
allNodesSynced.Store(false)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err := errGroup.Wait(); err != nil {
|
if err := errGroup.Wait(); err != nil {
|
||||||
|
allNodesSynced.Store(false)
|
||||||
s.log.Warn(logs.TreeFailedToRunTreeSynchronizationOverAllNodes, zap.Error(err))
|
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 {
|
} else {
|
||||||
newHeight++
|
newHeight++
|
||||||
}
|
}
|
||||||
return newHeight
|
if allNodesSynced.Load() {
|
||||||
|
return newHeight
|
||||||
|
}
|
||||||
|
return from
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrAlreadySyncing is returned when a service synchronization has already
|
// ErrAlreadySyncing is returned when a service synchronization has already
|
||||||
|
|
Loading…
Reference in a new issue