segment-verify: synchronize refreshing of the nodeAliasMap
This part can be called from multiple goroutines, therefore we should bw prepared for concurrent run. Change-Id: I7acf1a29bdb51427d3d03f501b58b190dcf08412
This commit is contained in:
parent
c031b2ad75
commit
be5302d9cc
@ -140,8 +140,12 @@ func (service *Service) VerifyBatches(ctx context.Context, batches []*Batch) err
|
||||
|
||||
// convertAliasToNodeURL converts a node alias to node url, using a cache if needed.
|
||||
func (service *Service) convertAliasToNodeURL(ctx context.Context, alias metabase.NodeAlias) (_ storj.NodeURL, err error) {
|
||||
service.mu.RLock()
|
||||
nodeURL, ok := service.aliasToNodeURL[alias]
|
||||
service.mu.RUnlock()
|
||||
if !ok {
|
||||
service.mu.Lock()
|
||||
defer service.mu.Unlock()
|
||||
nodeID, ok := service.aliasMap.Node(alias)
|
||||
if !ok {
|
||||
latest, err := service.metabase.LatestNodesAliasMap(ctx)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
@ -94,8 +95,9 @@ type Service struct {
|
||||
verifier Verifier
|
||||
overlay Overlay
|
||||
|
||||
aliasMap *metabase.NodeAliasMap
|
||||
mu sync.RWMutex
|
||||
aliasToNodeURL map[metabase.NodeAlias]storj.NodeURL
|
||||
aliasMap *metabase.NodeAliasMap
|
||||
priorityNodes NodeAliasSet
|
||||
ignoreNodes NodeAliasSet
|
||||
offlineNodes *nodeAliasExpiringSet
|
||||
|
Loading…
Reference in New Issue
Block a user