Skip to content

Commit

Permalink
Revert "fix(restore): improve restore schema for Scylla 5.4.0"
Browse files Browse the repository at this point in the history
This reverts commit 3a10977.
  • Loading branch information
Michal-Leszczynski committed Dec 8, 2023
1 parent 5dd7c22 commit e99eb69
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions pkg/service/restore/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,11 @@ func (w *worker) initTarget(ctx context.Context, properties json.RawMessage) err
remotePath = l.RemotePath("")
locationStatus = status
)
// Restore schema has to download ALL schema to ALL nodes,
// so it can't filter used nodes by location datacenter.
if t.RestoreTables {
if l.DC == "" {
w.logger.Info(ctx, "No datacenter specified for location - using all nodes for this location", "location", l)
} else {
locationStatus = status.Datacenter([]string{l.DC})
}
// In case location does not have specified dc, use nodes from all dcs
if l.DC == "" {
w.logger.Info(ctx, "No datacenter specified for location - using all nodes for this location", "location", l)
} else {
locationStatus = status.Datacenter([]string{l.DC})
}

nodes, err := w.client.GetNodesWithLocationAccess(ctx, locationStatus, remotePath)
Expand All @@ -138,24 +135,15 @@ func (w *worker) initTarget(ctx context.Context, properties json.RawMessage) err
}
return errors.Wrapf(err, "location %s is not accessible", l)
}
if len(nodes) == 0 {
return fmt.Errorf("no nodes with location %s access", l)
}

var hosts []string
for _, n := range nodes {
hosts = append(hosts, n.Addr)
}

if len(hosts) == 0 {
return fmt.Errorf("no nodes with location %s access", l)
}
if t.RestoreSchema && len(hosts) != len(status) {
noAccess := strset.New()
for _, n := range status {
noAccess.Add(n.Addr)
}
noAccess.Remove(hosts...)
return fmt.Errorf("restoring schema requires all nodes to have access to all locations."+
" Nodes %s don't have access to location %s", noAccess.String(), l.String())
}

w.logger.Info(ctx, "Found hosts with location access", "location", l, "hosts", hosts)
locationHosts[l] = hosts
}
Expand Down

0 comments on commit e99eb69

Please sign in to comment.