Example #1
0
// maybeRebuildKeyspace handles the initial rebuild of SrvKeyspace if needed.
// This should be run as a background task: we use the batch context to check
// the SrvKeyspace object. If it is not there, we try to rebuild it
// for the current cell only.
func (agent *ActionAgent) maybeRebuildKeyspace(cell, keyspace string) {
	_, err := agent.TopoServer.GetSrvKeyspace(agent.batchCtx, cell, keyspace)
	switch err {
	case nil:
		// SrvKeyspace exists, we're done
		log.Infof("SrvKeyspace(%v,%v) exists, not building it", cell, keyspace)
		return
	case topo.ErrNoNode:
		log.Infof("SrvKeyspace(%v,%v) doesn't exist, rebuilding it", cell, keyspace)
		// SrvKeyspace doesn't exist, we'll try to rebuild it
	default:
		log.Warningf("Cannot read SrvKeyspace(%v,%v) (may need to run 'vtctl RebuildKeyspaceGraph %v'), skipping rebuild: %v", cell, keyspace, keyspace, err)
		return
	}

	if err := topotools.RebuildKeyspace(agent.batchCtx, logutil.NewConsoleLogger(), agent.TopoServer, keyspace, []string{cell}); err != nil {
		log.Warningf("RebuildKeyspace(%v,%v) failed: %v, may need to run 'vtctl RebuildKeyspaceGraph %v')", cell, keyspace, err, keyspace)
	}
}
Example #2
0
// RebuildKeyspaceGraph rebuilds the serving graph data while locking out other changes.
func (wr *Wrangler) RebuildKeyspaceGraph(ctx context.Context, keyspace string, cells []string) error {
	return topotools.RebuildKeyspace(ctx, wr.logger, wr.ts, keyspace, cells)
}