Fixing SetShardTabletControl blacklisted_tables.

Now only use blacklisted_tables, which is the proto field name, as
parameter to SetShardTabletControl.
This commit is contained in:
Alain Jobart 2016-12-09 10:31:16 -08:00
Родитель 2d25adce4a
Коммит 9e098bf634
3 изменённых файлов: 18 добавлений и 14 удалений

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

@ -225,7 +225,10 @@ var commands = []commandGroup{
"Add or remove served type to/from a shard. This is meant as an emergency function. It does not rebuild any serving graph i.e. does not run 'RebuildKeyspaceGraph'."},
{"SetShardTabletControl", commandSetShardTabletControl,
"[--cells=c1,c2,...] [--blacklisted_tables=t1,t2,...] [--remove] [--disable_query_service] <keyspace/shard> <tablet type>",
"Sets the TabletControl record for a shard and type. Only use this for an emergency fix or after a finished vertical split. The *MigrateServedFrom* and *MigrateServedType* commands set this field appropriately already. Always specify the blacklisted_tables flag for vertical splits, but never for horizontal splits."},
"Sets the TabletControl record for a shard and type. Only use this for an emergency fix or after a finished vertical split. The *MigrateServedFrom* and *MigrateServedType* commands set this field appropriately already. Always specify the blacklisted_tables flag for vertical splits, but never for horizontal splits.\n" +
"To set the DisableQueryServiceFlag, keep 'blacklisted_tables' empty, and set 'disable_query_service' to true or false. Useful to fix horizontal splits gone wrong.\n" +
"To change the blacklisted tables list, specify the 'blacklisted_tables' parameter with the new list. Useful to fix tables that are being blocked after a vertical split.\n" +
"To just remove the ShardTabletControl entirely, use the 'remove' flag, useful after a vertical split is finished to remove serving restrictions."},
{"SourceShardDelete", commandSourceShardDelete,
"<keyspace/shard> <uid>",
"Deletes the SourceShard record with the provided index. This is meant as an emergency cleanup function. It does not call RefreshState for the shard master."},
@ -1230,9 +1233,9 @@ func commandSetShardServedTypes(ctx context.Context, wr *wrangler.Wrangler, subF
func commandSetShardTabletControl(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
cellsStr := subFlags.String("cells", "", "Specifies a comma-separated list of cells to update")
tablesStr := subFlags.String("tables", "", "Specifies a comma-separated list of tables to replicate (used for vertical split). Each is either an exact match, or a regular expression of the form /regexp/")
remove := subFlags.Bool("remove", false, "Removes cells for vertical splits. This flag requires the *tables* flag to also be set.")
disableQueryService := subFlags.Bool("disable_query_service", false, "Disables query service on the provided nodes")
blacklistedTablesStr := subFlags.String("blacklisted_tables", "", "Specifies a comma-separated list of tables to blacklist (used for vertical split). Each is either an exact match, or a regular expression of the form '/regexp/'.")
remove := subFlags.Bool("remove", false, "Removes cells for vertical splits.")
disableQueryService := subFlags.Bool("disable_query_service", false, "Disables query service on the provided nodes. This flag requires 'blacklisted_tables' and 'remove' to be unset, otherwise it's ignored.")
if err := subFlags.Parse(args); err != nil {
return err
}
@ -1247,16 +1250,16 @@ func commandSetShardTabletControl(ctx context.Context, wr *wrangler.Wrangler, su
if err != nil {
return err
}
var tables []string
if *tablesStr != "" {
tables = strings.Split(*tablesStr, ",")
var blacklistedTables []string
if *blacklistedTablesStr != "" {
blacklistedTables = strings.Split(*blacklistedTablesStr, ",")
}
var cells []string
if *cellsStr != "" {
cells = strings.Split(*cellsStr, ",")
}
return wr.SetShardTabletControl(ctx, keyspace, shard, tabletType, cells, *remove, *disableQueryService, tables)
return wr.SetShardTabletControl(ctx, keyspace, shard, tabletType, cells, *remove, *disableQueryService, blacklistedTables)
}
func commandSourceShardDelete(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {

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

@ -83,10 +83,10 @@ func (wr *Wrangler) SetShardServedTypes(ctx context.Context, keyspace, shard str
// the TabletControl record for the cells
//
// This takes the keyspace lock as to not interfere with resharding operations.
func (wr *Wrangler) SetShardTabletControl(ctx context.Context, keyspace, shard string, tabletType topodatapb.TabletType, cells []string, remove, disableQueryService bool, tables []string) (err error) {
func (wr *Wrangler) SetShardTabletControl(ctx context.Context, keyspace, shard string, tabletType topodatapb.TabletType, cells []string, remove, disableQueryService bool, blacklistedTables []string) (err error) {
// check input
if disableQueryService && len(tables) > 0 {
return fmt.Errorf("SetShardTabletControl cannot have both DisableQueryService set and tables set")
if disableQueryService && len(blacklistedTables) > 0 {
return fmt.Errorf("SetShardTabletControl cannot have both DisableQueryService and BlacklistedTables set")
}
// lock the keyspace
@ -98,13 +98,13 @@ func (wr *Wrangler) SetShardTabletControl(ctx context.Context, keyspace, shard s
// update the shard
_, err = wr.ts.UpdateShardFields(ctx, keyspace, shard, func(si *topo.ShardInfo) error {
if len(tables) == 0 && !remove {
if len(blacklistedTables) == 0 && !remove {
// we are setting the DisableQueryService flag only
return si.UpdateDisableQueryService(ctx, tabletType, cells, disableQueryService)
}
// we are setting / removing the blacklisted tables only
return si.UpdateSourceBlacklistedTables(ctx, tabletType, cells, remove, tables)
return si.UpdateSourceBlacklistedTables(ctx, tabletType, cells, remove, blacklistedTables)
})
return err
}

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

@ -585,7 +585,8 @@ index by_msg (msg)
self._assert_tablet_controls([topodata_pb2.MASTER, topodata_pb2.REPLICA])
# re-add rdonly:
utils.run_vtctl(['SetShardTabletControl', '--tables=/moving/,view1',
utils.run_vtctl(['SetShardTabletControl',
'--blacklisted_tables=/moving/,view1',
'source_keyspace/0', 'rdonly'], auto_log=True)
self._assert_tablet_controls([topodata_pb2.MASTER, topodata_pb2.REPLICA,
topodata_pb2.RDONLY])