Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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