Skip to content
Snippets Groups Projects

Improve query to identify up to date storages for reads distribution

Merged Pavlo Strokov requested to merge ps-improve-reads-dist into master
1 file
+ 7
7
Compare changes
  • Side-by-side
  • Inline
@@ -195,7 +195,7 @@ func (s *memoryReplicationEventQueue) GetOutdatedRepositories(ctx context.Contex
return outdatedRepositories, nil
}
func (s *memoryReplicationEventQueue) GetUpToDateStorages(_ context.Context, virtualStorage, repoPath string, checkNames []string) ([]string, error) {
func (s *memoryReplicationEventQueue) GetUpToDateStorages(_ context.Context, virtualStorage, repoPath string, storageNames []string) ([]string, error) {
s.RLock()
dirtyStorages := make(map[string]struct{})
for dst, event := range s.lastEventByDest {
@@ -205,20 +205,20 @@ func (s *memoryReplicationEventQueue) GetUpToDateStorages(_ context.Context, vir
}
s.RUnlock()
storageNames, found := s.storageNamesByVirtualStorage[virtualStorage]
knownStorageNames, found := s.storageNamesByVirtualStorage[virtualStorage]
if !found {
return nil, nil
}
var result []string
for _, storage := range storageNames {
for _, checkName := range checkNames {
if storage != checkName {
for _, knownStorageName := range knownStorageNames {
for _, storageName := range storageNames {
if knownStorageName != storageName {
continue
}
if _, found := dirtyStorages[storage]; !found {
result = append(result, storage)
if _, found := dirtyStorages[knownStorageName]; !found {
result = append(result, knownStorageName)
}
}
}
Loading