зеркало из https://github.com/github/vitess-gh.git
Fixing TabletType:
- removing SNAPSHOT_SOURCE - renaming CHECKER to WORKER
This commit is contained in:
Родитель
f76208ec52
Коммит
7ac9766e46
|
@ -164,25 +164,13 @@ const (
|
|||
// replication sql thread may be stopped
|
||||
TYPE_BACKUP = TabletType("backup")
|
||||
|
||||
// a slaved copy of the data, where mysqld is *not* running,
|
||||
// and we are serving our data files to clone slaves
|
||||
// use 'vtctl Snapshot -server-mode ...' to get in this mode
|
||||
// use 'vtctl SnapshotSourceEnd ...' to get out of this mode
|
||||
TYPE_SNAPSHOT_SOURCE = TabletType("snapshot_source")
|
||||
|
||||
// A tablet that has not been in the replication graph and is restoring
|
||||
// from a snapshot. idle -> restore -> spare
|
||||
// from a snapshot.
|
||||
TYPE_RESTORE = TabletType("restore")
|
||||
|
||||
// A tablet that is running a checker process. It is probably
|
||||
// A tablet that is used by a worker process. It is probably
|
||||
// lagging in replication.
|
||||
TYPE_CHECKER = TabletType("checker")
|
||||
|
||||
// FIXME(szopa): Make TYPE_EXPORT a truly separate type.
|
||||
|
||||
// TYPE_EXPORT is tablet that is running an export process. It
|
||||
// is probably lagging in replication.
|
||||
TYPE_EXPORT = TYPE_CHECKER
|
||||
TYPE_WORKER = TabletType("worker")
|
||||
|
||||
// a machine with data that needs to be wiped
|
||||
TYPE_SCRAP = TabletType("scrap")
|
||||
|
@ -198,9 +186,8 @@ var AllTabletTypes = []TabletType{TYPE_IDLE,
|
|||
TYPE_EXPERIMENTAL,
|
||||
TYPE_SCHEMA_UPGRADE,
|
||||
TYPE_BACKUP,
|
||||
TYPE_SNAPSHOT_SOURCE,
|
||||
TYPE_RESTORE,
|
||||
TYPE_CHECKER,
|
||||
TYPE_WORKER,
|
||||
TYPE_SCRAP,
|
||||
}
|
||||
|
||||
|
@ -213,9 +200,8 @@ var SlaveTabletTypes = []TabletType{
|
|||
TYPE_EXPERIMENTAL,
|
||||
TYPE_SCHEMA_UPGRADE,
|
||||
TYPE_BACKUP,
|
||||
TYPE_SNAPSHOT_SOURCE,
|
||||
TYPE_RESTORE,
|
||||
TYPE_CHECKER,
|
||||
TYPE_WORKER,
|
||||
}
|
||||
|
||||
// IsTypeInList returns true if the given type is in the list.
|
||||
|
@ -248,9 +234,9 @@ func MakeStringTypeList(types []TabletType) []string {
|
|||
// without changes to the replication graph
|
||||
func IsTrivialTypeChange(oldTabletType, newTabletType TabletType) bool {
|
||||
switch oldTabletType {
|
||||
case TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_SPARE, TYPE_BACKUP, TYPE_SNAPSHOT_SOURCE, TYPE_EXPERIMENTAL, TYPE_SCHEMA_UPGRADE, TYPE_CHECKER:
|
||||
case TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_SPARE, TYPE_BACKUP, TYPE_EXPERIMENTAL, TYPE_SCHEMA_UPGRADE, TYPE_WORKER:
|
||||
switch newTabletType {
|
||||
case TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_SPARE, TYPE_BACKUP, TYPE_SNAPSHOT_SOURCE, TYPE_EXPERIMENTAL, TYPE_SCHEMA_UPGRADE, TYPE_CHECKER:
|
||||
case TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_SPARE, TYPE_BACKUP, TYPE_EXPERIMENTAL, TYPE_SCHEMA_UPGRADE, TYPE_WORKER:
|
||||
return true
|
||||
}
|
||||
case TYPE_SCRAP:
|
||||
|
@ -264,22 +250,6 @@ func IsTrivialTypeChange(oldTabletType, newTabletType TabletType) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// IsValidTypeChange returns if we should we allow this transition at
|
||||
// all. Most transitions are allowed, but some don't make sense under
|
||||
// any circumstances. If a transition could be forced, don't disallow
|
||||
// it here.
|
||||
func IsValidTypeChange(oldTabletType, newTabletType TabletType) bool {
|
||||
switch oldTabletType {
|
||||
case TYPE_SNAPSHOT_SOURCE:
|
||||
switch newTabletType {
|
||||
case TYPE_BACKUP, TYPE_SNAPSHOT_SOURCE:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// IsInServingGraph returns if a tablet appears in the serving graph
|
||||
func IsInServingGraph(tt TabletType) bool {
|
||||
switch tt {
|
||||
|
@ -292,7 +262,7 @@ func IsInServingGraph(tt TabletType) bool {
|
|||
// IsRunningQueryService returns if a tablet is running the query service
|
||||
func IsRunningQueryService(tt TabletType) bool {
|
||||
switch tt {
|
||||
case TYPE_MASTER, TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_CHECKER:
|
||||
case TYPE_MASTER, TYPE_REPLICA, TYPE_RDONLY, TYPE_BATCH, TYPE_WORKER:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -325,10 +295,10 @@ func IsInReplicationGraph(tt TabletType) bool {
|
|||
// and actively replicating?
|
||||
// MASTER is not obviously (only support one level replication graph)
|
||||
// IDLE and SCRAP are not either
|
||||
// BACKUP, RESTORE, TYPE_CHECKER may or may not be, but we don't know for sure
|
||||
// BACKUP, RESTORE, TYPE_WORKER may or may not be, but we don't know for sure
|
||||
func IsSlaveType(tt TabletType) bool {
|
||||
switch tt {
|
||||
case TYPE_MASTER, TYPE_IDLE, TYPE_SCRAP, TYPE_BACKUP, TYPE_RESTORE, TYPE_CHECKER:
|
||||
case TYPE_MASTER, TYPE_IDLE, TYPE_SCRAP, TYPE_BACKUP, TYPE_RESTORE, TYPE_WORKER:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -105,7 +105,7 @@ func ChangeType(ctx context.Context, ts topo.Server, tabletAlias topo.TabletAlia
|
|||
return err
|
||||
}
|
||||
|
||||
if !topo.IsTrivialTypeChange(tablet.Type, newType) || !topo.IsValidTypeChange(tablet.Type, newType) {
|
||||
if !topo.IsTrivialTypeChange(tablet.Type, newType) {
|
||||
return fmt.Errorf("cannot change tablet type %v -> %v %v", tablet.Type, newType, tabletAlias)
|
||||
}
|
||||
|
||||
|
|
|
@ -763,7 +763,7 @@ func commandChangeSlaveType(ctx context.Context, wr *wrangler.Wrangler, subFlags
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed reading tablet %v: %v", tabletAlias, err)
|
||||
}
|
||||
if !topo.IsTrivialTypeChange(ti.Type, newType) || !topo.IsValidTypeChange(ti.Type, newType) {
|
||||
if !topo.IsTrivialTypeChange(ti.Type, newType) {
|
||||
return fmt.Errorf("invalid type transition %v: %v -> %v", tabletAlias, ti.Type, newType)
|
||||
}
|
||||
wr.Logger().Printf("- %v\n", fmtTabletAwkable(ti))
|
||||
|
|
|
@ -273,7 +273,7 @@ func (scw *SplitCloneWorker) findTargets(ctx context.Context) error {
|
|||
// find an appropriate endpoint in the source shards
|
||||
scw.sourceAliases = make([]topo.TabletAlias, len(scw.sourceShards))
|
||||
for i, si := range scw.sourceShards {
|
||||
scw.sourceAliases[i], err = FindChecker(ctx, scw.wr, scw.cleaner, scw.cell, si.Keyspace(), si.ShardName())
|
||||
scw.sourceAliases[i], err = FindWorkerTablet(ctx, scw.wr, scw.cleaner, scw.cell, si.Keyspace(), si.ShardName())
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot find checker for %v/%v/%v: %v", scw.cell, si.Keyspace(), si.ShardName(), err)
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ func (sdw *SplitDiffWorker) findTargets(ctx context.Context) error {
|
|||
|
||||
// find an appropriate endpoint in destination shard
|
||||
var err error
|
||||
sdw.destinationAlias, err = FindChecker(ctx, sdw.wr, sdw.cleaner, sdw.cell, sdw.keyspace, sdw.shard)
|
||||
sdw.destinationAlias, err = FindWorkerTablet(ctx, sdw.wr, sdw.cleaner, sdw.cell, sdw.keyspace, sdw.shard)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot find checker for %v/%v/%v: %v", sdw.cell, sdw.keyspace, sdw.shard, err)
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ func (sdw *SplitDiffWorker) findTargets(ctx context.Context) error {
|
|||
// find an appropriate endpoint in the source shards
|
||||
sdw.sourceAliases = make([]topo.TabletAlias, len(sdw.shardInfo.SourceShards))
|
||||
for i, ss := range sdw.shardInfo.SourceShards {
|
||||
sdw.sourceAliases[i], err = FindChecker(ctx, sdw.wr, sdw.cleaner, sdw.cell, sdw.keyspace, ss.Shard)
|
||||
sdw.sourceAliases[i], err = FindWorkerTablet(ctx, sdw.wr, sdw.cleaner, sdw.cell, sdw.keyspace, ss.Shard)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot find checker for %v/%v/%v: %v", sdw.cell, sdw.keyspace, ss.Shard, err)
|
||||
}
|
||||
|
|
|
@ -146,13 +146,13 @@ func (worker *SQLDiffWorker) findTargets(ctx context.Context) error {
|
|||
|
||||
// find an appropriate endpoint in superset
|
||||
var err error
|
||||
worker.superset.alias, err = FindChecker(ctx, worker.wr, worker.cleaner, worker.cell, worker.superset.Keyspace, worker.superset.Shard)
|
||||
worker.superset.alias, err = FindWorkerTablet(ctx, worker.wr, worker.cleaner, worker.cell, worker.superset.Keyspace, worker.superset.Shard)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// find an appropriate endpoint in subset
|
||||
worker.subset.alias, err = FindChecker(ctx, worker.wr, worker.cleaner, worker.cell, worker.subset.Keyspace, worker.subset.Shard)
|
||||
worker.subset.alias, err = FindWorkerTablet(ctx, worker.wr, worker.cleaner, worker.cell, worker.subset.Keyspace, worker.subset.Shard)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ func FindHealthyRdonlyEndPoint(wr *wrangler.Wrangler, cell, keyspace, shard stri
|
|||
}, nil
|
||||
}
|
||||
|
||||
// FindChecker will:
|
||||
// FindWorkerTablet will:
|
||||
// - find a rdonly instance in the keyspace / shard
|
||||
// - mark it as checker
|
||||
// - mark it as worker
|
||||
// - tag it with our worker process
|
||||
func FindChecker(ctx context.Context, wr *wrangler.Wrangler, cleaner *wrangler.Cleaner, cell, keyspace, shard string) (topo.TabletAlias, error) {
|
||||
func FindWorkerTablet(ctx context.Context, wr *wrangler.Wrangler, cleaner *wrangler.Cleaner, cell, keyspace, shard string) (topo.TabletAlias, error) {
|
||||
tabletAlias, err := FindHealthyRdonlyEndPoint(wr, cell, keyspace, shard)
|
||||
if err != nil {
|
||||
return topo.TabletAlias{}, err
|
||||
|
@ -76,7 +76,7 @@ func FindChecker(ctx context.Context, wr *wrangler.Wrangler, cleaner *wrangler.C
|
|||
|
||||
wr.Logger().Infof("Changing tablet %v to 'checker'", tabletAlias)
|
||||
shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
|
||||
err = wr.ChangeType(shortCtx, tabletAlias, topo.TYPE_CHECKER, false /*force*/)
|
||||
err = wr.ChangeType(shortCtx, tabletAlias, topo.TYPE_WORKER, false /*force*/)
|
||||
cancel()
|
||||
if err != nil {
|
||||
return topo.TabletAlias{}, err
|
||||
|
|
|
@ -243,7 +243,7 @@ func (vscw *VerticalSplitCloneWorker) findTargets(ctx context.Context) error {
|
|||
|
||||
// find an appropriate endpoint in the source shard
|
||||
var err error
|
||||
vscw.sourceAlias, err = FindChecker(ctx, vscw.wr, vscw.cleaner, vscw.cell, vscw.sourceKeyspace, "0")
|
||||
vscw.sourceAlias, err = FindWorkerTablet(ctx, vscw.wr, vscw.cleaner, vscw.cell, vscw.sourceKeyspace, "0")
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot find checker for %v/%v/0: %v", vscw.cell, vscw.sourceKeyspace, err)
|
||||
}
|
||||
|
|
|
@ -189,13 +189,13 @@ func (vsdw *VerticalSplitDiffWorker) findTargets(ctx context.Context) error {
|
|||
|
||||
// find an appropriate endpoint in destination shard
|
||||
var err error
|
||||
vsdw.destinationAlias, err = FindChecker(ctx, vsdw.wr, vsdw.cleaner, vsdw.cell, vsdw.keyspace, vsdw.shard)
|
||||
vsdw.destinationAlias, err = FindWorkerTablet(ctx, vsdw.wr, vsdw.cleaner, vsdw.cell, vsdw.keyspace, vsdw.shard)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot find checker for %v/%v/%v: %v", vsdw.cell, vsdw.keyspace, vsdw.shard, err)
|
||||
}
|
||||
|
||||
// find an appropriate endpoint in the source shard
|
||||
vsdw.sourceAlias, err = FindChecker(ctx, vsdw.wr, vsdw.cleaner, vsdw.cell, vsdw.shardInfo.SourceShards[0].Keyspace, vsdw.shardInfo.SourceShards[0].Shard)
|
||||
vsdw.sourceAlias, err = FindWorkerTablet(ctx, vsdw.wr, vsdw.cleaner, vsdw.cell, vsdw.shardInfo.SourceShards[0].Keyspace, vsdw.shardInfo.SourceShards[0].Shard)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot find checker for %v/%v/%v: %v", vsdw.cell, vsdw.shardInfo.SourceShards[0].Keyspace, vsdw.shardInfo.SourceShards[0].Shard, err)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче