Beispiel #1
0
// ApplySchemaKeyspace applies a schema change to an entire keyspace.
// take a keyspace lock to do this.
// first we will validate the Preflight works the same on all shard masters
// and fail if not (unless force is specified)
// if simple, we just do it on all masters.
// if complex, we do the shell game in parallel on all shards
func (wr *Wrangler) ApplySchemaKeyspace(ctx context.Context, keyspace string, change string, simple, force bool, waitSlaveTimeout time.Duration) (*myproto.SchemaChangeResult, error) {
	actionNode := actionnode.ApplySchemaKeyspace(change, simple)
	lockPath, err := wr.lockKeyspace(ctx, keyspace, actionNode)
	if err != nil {
		return nil, err
	}

	err = schemamanager.Run(
		ctx,
		schemamanager.NewPlainController(change, keyspace),
		schemamanager.NewTabletExecutor(wr.tmc, wr.ts),
	)

	return nil, wr.unlockKeyspace(ctx, keyspace, actionNode, lockPath, err)
}
Beispiel #2
0
// ApplySchemaKeyspace applies a schema change to an entire keyspace.
// take a keyspace lock to do this.
// first we will validate the Preflight works the same on all shard masters
// and fail if not (unless force is specified)
func (wr *Wrangler) ApplySchemaKeyspace(ctx context.Context, keyspace, change string, allowLongUnavailability bool, waitSlaveTimeout time.Duration) error {
	actionNode := actionnode.ApplySchemaKeyspace(change)
	lockPath, err := wr.lockKeyspace(ctx, keyspace, actionNode)
	if err != nil {
		return err
	}
	executor := schemamanager.NewTabletExecutor(wr.tmc, wr.ts)
	if allowLongUnavailability {
		executor.AllowBigSchemaChange()
	}
	err = schemamanager.Run(
		ctx,
		schemamanager.NewPlainController(change, keyspace),
		executor,
	)

	return wr.unlockKeyspace(ctx, keyspace, actionNode, lockPath, err)
}