Adding a check to ShardMultiRestore.

This commit is contained in:
Alain Jobart 2014-08-06 09:55:54 -07:00
Родитель a0b4b67be0
Коммит a8e25ab7c7
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -134,6 +134,10 @@ func (wr *Wrangler) ShardMultiRestore(keyspace, shard string, sources []topo.Tab
mrErr := wr.SetSourceShards(keyspace, shard, sources, tables) mrErr := wr.SetSourceShards(keyspace, shard, sources, tables)
err = wr.unlockShard(keyspace, shard, actionNode, lockPath, mrErr) err = wr.unlockShard(keyspace, shard, actionNode, lockPath, mrErr)
if err != nil { if err != nil {
if mrErr != nil {
log.Errorf("unlockShard got error back: %v", err)
return mrErr
}
return err return err
} }
if mrErr != nil { if mrErr != nil {
@ -171,6 +175,12 @@ func (wr *Wrangler) SetSourceShards(keyspace, shard string, sources []topo.Table
return err return err
} }
// If the shard already has sources, maybe it's already been restored,
// so let's be safe and abort right here.
if len(shardInfo.SourceShards) > 0 {
return fmt.Errorf("Shard %v/%v already has SourceShards, not performing the MultiRestore")
}
// read the source tablets // read the source tablets
sourceTablets, err := topo.GetTabletMap(wr.TopoServer(), sources) sourceTablets, err := topo.GetTabletMap(wr.TopoServer(), sources)
if err != nil { if err != nil {