Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
add a hack to enable routing to RDONLY tablets for REPLICA queries
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
  • Loading branch information
demmer committed Mar 5, 2020
1 parent 124cc43 commit aed84ee
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions go/vt/vtgate/gateway/discoverygateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ import (
"vitess.io/vitess/go/vt/vttablet/queryservice"

querypb "vitess.io/vitess/go/vt/proto/query"
"vitess.io/vitess/go/vt/proto/topodata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/topo/topoproto"
)

var (
cellsToWatch = flag.String("cells_to_watch", "", "comma-separated list of cells for watching tablets")
tabletFilters flagutil.StringListValue
refreshInterval = flag.Duration("tablet_refresh_interval", 1*time.Minute, "tablet refresh interval")
refreshKnownTablets = flag.Bool("tablet_refresh_known_tablets", true, "tablet refresh reloads the tablet address/port map from topo in case it changes")
topoReadConcurrency = flag.Int("topo_read_concurrency", 32, "concurrent topo reads")
allowedTabletTypes []topodatapb.TabletType
cellsToWatch = flag.String("cells_to_watch", "", "comma-separated list of cells for watching tablets")
tabletFilters flagutil.StringListValue
refreshInterval = flag.Duration("tablet_refresh_interval", 1*time.Minute, "tablet refresh interval")
refreshKnownTablets = flag.Bool("tablet_refresh_known_tablets", true, "tablet refresh reloads the tablet address/port map from topo in case it changes")
topoReadConcurrency = flag.Int("topo_read_concurrency", 32, "concurrent topo reads")
allowedTabletTypes []topodatapb.TabletType
routeReplicaToRdonly = flag.Bool("gateway_route_replica_to_rdonly", false, "route REPLICA queries to RDONLY tablets as well as REPLICA tablets")
)

const (
Expand Down Expand Up @@ -275,6 +277,12 @@ func (dg *discoveryGateway) withRetry(ctx context.Context, target *querypb.Targe
}

tablets := dg.tsc.GetHealthyTabletStats(target.Keyspace, target.Shard, target.TabletType)

// temporary hack to enable REPLICA type queries to address both REPLICA tablets and RDONLY tablets
if *routeReplicaToRdonly && target.TabletType == topodata.TabletType_REPLICA {
tablets = append(tablets, dg.tsc.GetHealthyTabletStats(target.Keyspace, target.Shard, topodata.TabletType_RDONLY)...)
}

if len(tablets) == 0 {
// fail fast if there is no tablet
err = vterrors.New(vtrpcpb.Code_UNAVAILABLE, "no valid tablet")
Expand Down

0 comments on commit aed84ee

Please sign in to comment.