Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rdonly patch to tabletgateway for v13 #18

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion go/vt/vtgate/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ var (
initialTabletTimeout = flag.Duration("gateway_initial_tablet_timeout", 30*time.Second, "At startup, the gateway will wait up to that duration to get one tablet per keyspace/shard/tablettype")
// RetryCount is the number of times a query will be retried on error
// Make this unexported after DiscoveryGateway is deprecated
RetryCount = flag.Int("retry-count", 2, "retry count")
RetryCount = flag.Int("retry-count", 2, "retry count")
routeReplicaToRdonly = flag.Bool("gateway_route_replica_to_rdonly", false, "route REPLICA queries to RDONLY tablets as well as REPLICA tablets")
)

// A Gateway is the query processing module for each shard,
Expand Down
14 changes: 14 additions & 0 deletions go/vt/vtgate/tabletgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ func (gw *TabletGateway) withRetry(ctx context.Context, target *querypb.Target,
}

tablets := gw.hc.GetHealthyTabletStats(target)

// temporary hack to enable REPLICA type queries to address both REPLICA tablets and RDONLY tablets
// original commit - https://github.com/tinyspeck/vitess/pull/166/commits/2552b4ce25a9fdb41ff07fa69f2ccf485fea83ac
// discoverygateway patch - https://github.com/slackhq/vitess/commit/47adb7c8fc720cb4cb7a090530b3e88d310ff6d3
if *routeReplicaToRdonly && target.TabletType == topodatapb.TabletType_REPLICA {
// Create a new target for the same original keyspace/shard, but RDONLY tablet type.
rdonlyTarget := &querypb.Target{
Keyspace: target.Keyspace,
Shard: target.Shard,
TabletType: topodatapb.TabletType_RDONLY,
}
tablets = append(tablets, gw.hc.GetHealthyTabletStats(rdonlyTarget)...)
}

if len(tablets) == 0 {
// if we have a keyspace event watcher, check if the reason why our primary is not available is that it's currently being resharded
// or if a reparent operation is in progress.
Expand Down