From a8e25ab7c73b1a9fcddbb49f24ee8a93af81b8bf Mon Sep 17 00:00:00 2001 From: Alain Jobart Date: Wed, 6 Aug 2014 09:55:54 -0700 Subject: [PATCH] Adding a check to ShardMultiRestore. --- go/vt/wrangler/split.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/go/vt/wrangler/split.go b/go/vt/wrangler/split.go index afbec3875c..19ec9f7b7d 100644 --- a/go/vt/wrangler/split.go +++ b/go/vt/wrangler/split.go @@ -134,6 +134,10 @@ func (wr *Wrangler) ShardMultiRestore(keyspace, shard string, sources []topo.Tab mrErr := wr.SetSourceShards(keyspace, shard, sources, tables) err = wr.unlockShard(keyspace, shard, actionNode, lockPath, mrErr) if err != nil { + if mrErr != nil { + log.Errorf("unlockShard got error back: %v", err) + return mrErr + } return err } if mrErr != nil { @@ -171,6 +175,12 @@ func (wr *Wrangler) SetSourceShards(keyspace, shard string, sources []topo.Table 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 sourceTablets, err := topo.GetTabletMap(wr.TopoServer(), sources) if err != nil {